|
8 | 8 | "source": [ |
9 | 9 | "# Explaining the logic.py module\n", |
10 | 10 | "*Author: Chirag Vartak*<br>\n", |
11 | | - "*Date: 23rd March 2016*" |
| 11 | + "*Date: 23rd March 2016*\n", |
| 12 | + "\n", |
| 13 | + "---" |
12 | 14 | ] |
13 | 15 | }, |
14 | 16 | { |
|
42 | 44 | "The class `PropKB` now.\n", |
43 | 45 | "* `__init__(self, sentence=None)` : The constructor `__init__` creates a single field `clauses` which will be a list of all the sentences of the knowledge base. Note that each one of these sentences will be a 'clause' i.e. a sentence which is made up of only literals and `or`s.\n", |
44 | 46 | "* `tell(self, sentence)` : When you want to add a sentence to the KB, you use the `tell` method. This method takes a sentence, converts it to its CNF, extracts all the clauses, and adds all these clauses to the `clauses` field. So, you need not worry about `tell`ing only clauses to the knowledge base. You can `tell` the knowledge base a sentence in any form that you wish; converting it to CNF and adding the resulting clauses will be handled by the `tell` method.\n", |
45 | | - "* `ask_generator(self, query)` : The `ask_generator` function is to be used by the `ask` function. It calls the `tt_entails` function, which in turn returns `True` if the knowledge base entails query and `False` otherwise. The `ask_generator` itself returns and empty dict `{}` if the knowledge base entails query and `None` otherwise. This might seem weird to you a little bit. After all, it makes more sense just to return a `True` or a `False` instead of the `{}` or `None` But this is to maintain consistency with how things are in First-Order Logic, where, an `ask_generator` function, is supposed to return all the substitutions that make the query true in a dict. I will be mostly be using the `ask` function which returns a `{}` or a `False`, but if you don't like this, you can always use the `ask_if_true` function which returns a `True` or a `False`.\n", |
46 | | - "* `retract(self, sentence)` : This function removes all the clauses of the sentence given from the knowledge base. Like the `tell` function, you don't have to explicitly pass only clauses to remove them from the knowledge base; any sentence will do fine. The function will take care of converting that sentence to clauses." |
| 47 | + "* `ask_generator(self, query)` : The `ask_generator` function is used by the `ask` function. It calls the `tt_entails` function, which in turn returns `True` if the knowledge base entails query and `False` otherwise. The `ask_generator` itself returns an empty dict `{}` if the knowledge base entails query and `None` otherwise. This might seem a little bit weird to you. After all, it makes more sense just to return a `True` or a `False` instead of the `{}` or `None` But this is done to maintain consistency with the way things are in First-Order Logic, where, an `ask_generator` function, is supposed to return all the substitutions that make the query true. Hence the dict, to return all these substitutions. I will be mostly be using the `ask` function which returns a `{}` or a `False`, but if you don't like this, you can always use the `ask_if_true` function which returns a `True` or a `False`.\n", |
| 48 | + "* `retract(self, sentence)` : This function removes all the clauses of the sentence given, from the knowledge base. Like the `tell` function, you don't have to pass clauses to remove them from the knowledge base; any sentence will do fine. The function will take care of converting that sentence to clauses and then remove those." |
47 | 49 | ] |
48 | 50 | }, |
49 | 51 | { |
|
55 | 57 | "## Getting started with Propositional Logic" |
56 | 58 | ] |
57 | 59 | }, |
| 60 | + { |
| 61 | + "cell_type": "markdown", |
| 62 | + "metadata": {}, |
| 63 | + "source": [] |
| 64 | + }, |
| 65 | + { |
| 66 | + "cell_type": "markdown", |
| 67 | + "metadata": {}, |
| 68 | + "source": [ |
| 69 | + "### A note to delete later on\n", |
| 70 | + "\n", |
| 71 | + "1. Markdown is converted to HTML. It's closer to HTML than it is to Latex. Hence, to add special symbols, unicode characters etc., use HTML character reference rather than Latex symbols.\n", |
| 72 | + "2. Propositional symbols in markdown\n", |
| 73 | + " * ¬   `¬`\n", |
| 74 | + " * ∧   `∧`\n", |
| 75 | + " * ∨   `∨`\n", |
| 76 | + " * →   `→`\n", |
| 77 | + " * ↔   `↔`\n", |
| 78 | + "3. And some others\n", |
| 79 | + " * ⊨   `⊨`\n", |
| 80 | + " * ≡   `≡`" |
| 81 | + ] |
| 82 | + }, |
| 83 | + { |
| 84 | + "cell_type": "markdown", |
| 85 | + "metadata": {}, |
| 86 | + "source": [ |
| 87 | + "```python\n", |
| 88 | + "def my_function(string1, string2):\n", |
| 89 | + " for in in range(42):\n", |
| 90 | + " print string1 + string2\n", |
| 91 | + "```\n", |
| 92 | + "\n", |
| 93 | + "```python def __init__(self, sentence)```" |
| 94 | + ] |
| 95 | + }, |
58 | 96 | { |
59 | 97 | "cell_type": "code", |
60 | 98 | "execution_count": null, |
61 | 99 | "metadata": { |
62 | 100 | "collapsed": true |
63 | 101 | }, |
64 | 102 | "outputs": [], |
65 | | - "source": [] |
| 103 | + "source": [ |
| 104 | + "dcsdfdsf" |
| 105 | + ] |
66 | 106 | } |
67 | 107 | ], |
68 | 108 | "metadata": { |
69 | 109 | "kernelspec": { |
70 | | - "display_name": "Python 3", |
| 110 | + "display_name": "Python 2", |
71 | 111 | "language": "python", |
72 | | - "name": "python3" |
| 112 | + "name": "python2" |
73 | 113 | }, |
74 | 114 | "language_info": { |
75 | 115 | "codemirror_mode": { |
76 | 116 | "name": "ipython", |
77 | | - "version": 3 |
| 117 | + "version": 2 |
78 | 118 | }, |
79 | 119 | "file_extension": ".py", |
80 | 120 | "mimetype": "text/x-python", |
81 | 121 | "name": "python", |
82 | 122 | "nbconvert_exporter": "python", |
83 | | - "pygments_lexer": "ipython3", |
84 | | - "version": "3.4.4" |
| 123 | + "pygments_lexer": "ipython2", |
| 124 | + "version": "2.7.11" |
85 | 125 | } |
86 | 126 | }, |
87 | 127 | "nbformat": 4, |
|
0 commit comments