Lab 11 Ai
Lab 11 Ai
1.1 Propositions
A propositional statement or proposition is a statement that is unambiguously either true or false in a
given context. Examples include: “Quaid-e-Azam was born in July” (false), 2 + 3 equals 5 (true), and “Some
humans are reptiles” (false). The truth or falsity of a given proposition is called its truth value. Statements
that involve a subjective judgment, such as “Ali is a good guy”, are not propositional statements.
i. Atomic Propositions
1
Notes: The aima.logic package requires that propositional variables (i.e., those whose values must be True or False)
begin with an uppercase letter and logic variables (i.e., those that can take on any value) begin with a lowercase
letter. See here for a an example of using logic.py on gl. The Python examples below assume you are using Python
3.X and have done "from logic import *". The aima's logic.py package is well commented, so take a look if you have
questions. The answer might be in the comments.
Atomic Proposition: Atomic propositions are the simple propositions. It consists of a single proposition
symbol. These are the sentences which must be either true or false. For example
1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either Positive literal or
negative literal.
2. Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a conjunction. For
example “Ali is intelligent and hardworking”. It can be written as,
P= Ali is intelligent,
Q= Ali is hardworking. → P∧ Q.
3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction, where P and
Q are the propositions. For example: "Qasim is a doctor or Engineer", Here
P= Qasim is Doctor.
Q= Qasim is an Engineer, so we can write it as P ∨ Q.
4. Implication: A sentence such as P → Q, is called an implication. Implications are also known as if-
then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
5. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, for example If I am
breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
Precedence Operators
Use the functions in aima's logic.py to see which of the following are valid, i.e., true in every model. You
will have to
i. convert these sentences to the appropriate string form that the python code uses (see the
comments in the code) and
ii. use the expr() function in logic.py to turn each into an Expr object, and
iii. use the tt_true() function to check for validity. Provide text from a session that shows the
result of checking the validity of each. We've done the first one as an example.
a. P v ¬P
>>> tt_true(expr('P | ~P'))
True
b. P → P
c. P→ (P v Q)
d. (P v Q) → P
Use the functions in logic.py to see which of the following are are satisfiable. We've done the first one as
an example.
a. P ∧ Q
>>> dpll_satisfiable(expr('P & Q'))
{P: True, Q: True}
c. P → ¬ P v P
d. ~ (P v ¬ P)
For each of the following entailment relations, say whether or not it is true. The text on the left of the
entailment symbol (⊨) represents one or more sentences (separated by commas) that constitute a
knowledge base. We've done the first one for you.
a. P ∧ Q ⊨ P
b. P ⊨ P ∧ Q
c. P ⊨ P v Q
d. P ⊨ ¬ ¬ P
e. P → Q ⊨ ¬ P → ¬ Q
f. ¬P⊨P→Q
g. ¬ Q ⊨ P → Q
h. P ∧ (P → Q) ⊨ Q
i. ( ¬ P) ∧ (Q → P) ⊨ ¬ Q