Knowledge Representation
Knowledge Representation
Propositional Logic-1
By
Dr. Syed Noman Hasany &
Muhammad Ubaid Zaman
What is logic?
• Logic determines whether it is justified to reason
from given assumptions to a conclusion
Not propositions:
• Where are you?
• Oh no!
• Liverpool is not.
Checking Propositions’ Validity
• Valid propositions can be evaluated to either true or
false.
• Conjunction (and): Λ
• Disjunction (or): v
• Negation (not): ¬
• Implication (if..then): →
• Equivalence / Bi-implication(if and only if): ↔
Implication
Example:
Using the implication Truth Table
connective we can express
that if “you give me your p q p→q
mobile phone” then “I will
be your best friend”, as:
p → q---- (q :- p) T T T
where p represents the T F F
proposition “you give me F T T
your mobile phone” and q
represents the proposition F F T
“I will be your best friend”.
Implication
• We need to be careful with → as it may not quite
capture our intuitions about implication.
• In particular (taking the previous example), p
→ q is true in the following situations:
– I study hard and I get rich; or
– I don't study hard and I get rich; or
– I don't study hard and I don't get rich.
• Note the last two situations, where the implication is
true regardless of the truth of p.
• The one thing we can say is that if I've studied hard
but failed to become rich then the proposition is
clearly false.
Equivalence OR Bi-implication
Example:
Using the equivalence Truth Table
connective we can express p q p↔q
that “Asim will get a first class
degree” iff “his average is
higher than 70%”, as: T T T
p↔q T F F
where p represents the F T F
proposition “Asim will get a
first class degree” and q F F T
represents the proposition
“his average is higher than
70%”.
Compound Statements
• Connectives can be combined to form
compound statements or formulae.
• e.g.: ¬(p Λ ¬ q)
pΛq↔r
Example
The truth table for ¬(p Λ ¬q) is as follows:
– E.g: p V q Λ r is same as p V (q Λ r)
Example
The truth table for: p Λ q ↔ r as shown below.
p q r pΛq pΛq↔r
T T T T T
T T F T F
T F T F F
T F F F T
F T T F F
F T F F T
F F T F F
F F F F T
Example
Tautologies, Contradictions and
Contingencies
• For the truth tables of some formulae we find only Ts in the
last column. Such formulae are called “tautologies” (or valid
formulae).
Thus:
p q is equivalent to ¬p V q
p Λ q is equivalent to ¬(¬p V ¬q)
p V q is equivalent to ¬p q
e.g. p q ≡ ¬p V q
etc.
Equivalences
p q p→q
•We can check
T T T
to see if these T F F
statements are equivalent
F T T
by examining
F F T
the appropriate
truth tables
p q ¬p ¬p V q
T T F T
T F F F
F T T T
F F T T
Equivalence Laws-1
• There are a number of laws that state equivalence relations.
The following are a few of the most popular ones:
• Associative laws:
(p V q) V r ≡ p V (q V r)
(p Λ q) Λ r ≡ p Λ (q Λ r)
• Commutative laws:
pVq ≡ qVp
pΛq ≡ qΛp
• Involution law:
¬¬p ≡ p
Equivalence Laws-1
• Distributive laws:
p V (q Λ r) ≡ (p V q) Λ (p V r)
p Λ (q V r) ≡ (p Λ q) V (p Λ r)
• DeMorgan’s laws:
¬(p V q) ≡ ¬p Λ ¬q
¬(p Λ q) ≡ ¬p V ¬q
<C> := | V |→| ↔;
Processing grammar: Example 1
• Process the sentence for syntax check:
• PvQ
– S := <S>
– := <C_S>
– := <S> <C> <S>
– := <A_S> <C> <S>
– := P v <S>
– := P v <A_S>
– := P v Q
Processing grammar: Example 2
• Process the sentence for syntax check:
• P → (⌐Q )
– S := <S>
– := <C_S>
– := <S> <C> <S>
– := <A_S> <C> <S>
– := P → <S>
– := P → (<S>)
– := P → (<C_S>)
– := P → (⌐ <S>)
– := P → (⌐ <A_S>)
– := P → (⌐ Q)
Assign_1: Q.2
Syntax. Say whether each of the following is a sentence of Propositional Logic. Process
grammar to show the validity of sentences for (b) and (c) only.
Assign_1: Q.3
Validity, Satisfiability, Unsatisfiability. For each of the following sentences,
Indicate whether it is valid, satisfiable, or unsatisfiable. (c), (g) and (i)
“The beginning of knowledge is the
discovery of something that we do
not understand.”
– Frank Herbert
Knowledge base system
35
Argument and Proof in Propositional Logic
37
Modus Ponens
• One particularly important derivation rule is modus
ponens, as shown on the previous slide.
38
Modus Ponens Example
• An example argument of the form modus ponens:
Premises:
- If it is raining then ground is wet (p → q),
- It is raining (p),
Conclusion:
- Therefore, the ground is wet (q).
39
Modus Tollens
• Another important derivation rule is modus tollens (which is
also known as the contraposition) and it takes the following
form:
p → q, ¬q ├ ¬p
• Example:
Premises:
- If it is raining then the ground is wet (p → q),
- The ground is not wet (¬q)
Conclusion:
- Therefore, it is not raining (¬p).
40
Entailment
• The notation we use to show that the truth of a given
formula follows from the truth of some other
formula, is known as the entailment relation:
╞
Example: {¬q, p q} ╞ ¬p
41
Entailment
Example: {¬q, p q} ╞ ¬p
• This means that we are left with one assignment, from the
last line of the table, and on examination we can see that all
assignments for the formula are true.
– i.e. ¬q is true, p q is true and ¬p is true.
43
Modus Ponens Argument Soundness
• Is modus ponens argument sound?
– p → q, p ╞ q
p q (p q)
T T T
T F F
F T T
F F T
Entailment and Proof
• To clarify the difference between entailment and proof:
45
Soundness and Completeness
• Two important properties to consider in inference systems are
soundness and completeness.
46
Modus Tollens Exercise
• Is the below argument
entailed?
– {¬p, p q} ╞ ¬q ?
• Answer: p q ¬p ¬q pq
– The above argument is T T F F T
NOT sound because in
row#3&4 of TT both
T F F T F
premises ¬p and p q F T T F T
are true but the F F T T T
conclusion ¬q is false.
Assign_1: Q.4
• Is the below argument entailed?
– {q, p q} ╞ p ?