16 Propositional Logic and AI
16 Propositional Logic and AI
2
LLMs Reliable? X-AI?
3
Propositional Logic for AI
• Symbolic AI emphasizes the use of
symbols and rules to represent
knowledge and reasoning processes
4
Pros of Neuro-Symbolic AI
5
Taking a Step Back
Question
Answer
6
Logic in Artificial Intelligence
7
Natural Language
Example:
A dime is better than nickel.
• A nickel is better than a penny.
• Therefore, a dime is better than a penny.
9
Reasoning about situations
• Constructing arguments about them;
• Doing this formally (usually in symbols) , so
that the arguments are valid and can be
defended rigorously,
or
• executed on a machine, in algorithm
10
Introduction: Logic?
• We will study
– Propositional Logic (PL)
– First-Order Logic (FOL)
• Logic
– is the study of the logic relationships between
objects and
– forms the basis of all mathematical reasoning and
all automated reasoning
(to avoid software/hardware errors
etc.)
11
Introduction: PL?
12
Outline
– Propositions
– Connectives
– Truth tables
13
Introduction: Proposition
• Definition: The value of a proposition is called
its truth value; denoted by
– T or 1 if it is true or
– F or 0 if it is false
• Opinions, interrogative, and imperative are
not propositions
• Truth table p
0
1
14
Propositions: Examples
• The following are propositions
– It is raining : p
– The grass is wet: q
• 2+2=5
• Every integer is divisible by 1
• Gen. Ayub Khan was an excellent leader.
• In 1965, Ayub Khan was Pakistan army chief
16
Logical connectives
• Connectives are used to create a compound
proposition from propositions:
1. Not or Negation (denoted or !)
2. And or logical conjunction (denoted )
3. Or or logical disjunction (denoted )
4. XOR or exclusive or (denoted )
5. Implication (denoted or )
6. Biconditional (denoted or )
We define the meaning (semantics) of the logical
connectives using truth tables
17
Logical Connective: Negation
• p, the negation of a proposition
• p: “Today is Monday”, is also a proposition
• Examples: p will be
– Today is not Monday
– It is not the case that today is Monday, etc.
• Truth table
p p
0 1
1 0
18
Logical Connective: Logical And
• The logical connective And is true only when both of
the propositions are true. It is also called a
conjunction
• Examples
– It is cloudy and it is daytime
– (2+3=5) and (1<2)
– Schroedinger’s cat is dead and Schroedinger is not dead.
• Truth table p q pq
0 0
0 1
1 0 Hint. Schrödinger died in 1961
1 1 19
Logical Connective: Logical Or
• The logical disjunction, or logical Or, is true if
one or both of the propositions are true.
• Examples
– It is cloudy or it is the second lecture
– (2+2=5) (1<2)
• Truth table p q pq pq
0 0 0
0 1 0
1 0 0
1 1 1
20
Logical Connective: Exclusive Or
• The exclusive Or, or XOR, of two propositions is true
when exactly one of the propositions is true and the
other one is false
• Example
– The circuit is either ON or OFF but not both
– Let ab<0, then either a<0 or b<0 but not both
• Truth table p q pq pq pq
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 1
21
Logical Connective: Implication (1)
Examples
– If you buy you air ticket in advance, it is cheaper.
– If x is an integer, then x2 0.
– If it rains, the grass gets wet.
– If the sprinklers operate, the grass gets wet.
– If 2+2=5, then all unicorns are pink.
26
Exercise: Which of the following
implications is true?
• If -1 is a positive number, then 2+2=5
True. The premise is obviously false, thus no matter what the
conclusion is, the implication holds.
• If -1 is a positive number, then 2+2=4
True. Same as above.
• If sin x = 0, then x = 0
False. x can be a multiple of . If we let x=2, then sin x=0 but
x0.
The implication “if sin x = 0, then x = k, for some k” is true.
27
Logical Connective: Biconditional
(1)
• Definition: The biconditional pq is the
proposition that is true when p and q have the
same truth values. It is false otherwise.
• Note that it is equivalent to (pq)(qp)
• Truth table p q pq pq pq pq pq
0 0 0 0 0 1
0 1 0 1 1 1
1 0 0 1 1 0
1 1 1 1 0 1
28
Logical Connective: Biconditional
(2)
• The biconditional pq can be equivalently read
as
– p if and only if q
– p is a necessary and sufficient condition for q
– if p then q, and conversely
– p iff q (Note typo in textbook, page 9, line 3)
• Examples
– x>0 if and only if x2 is positive
– The alarm goes off iff a burglar breaks in
– You will have pudding iff you eat your rice.
29
Exercise: Which of the following
biconditionals is true?
• x2 + y2 = 0 if and only if x=0 and y=0
True. Both implications hold
• x2 0 if and only if x 0
False. The implication “if x 0 then x2 0” holds.
However, the implication “if x2 0 then x 0” is false.
Consider x=-1.
The hypothesis (-1)2=1 0 but the conclusion fails.
30
Converse, Inverse, Contrapositive
31
Truth Tables
• Truth tables are used to show/define the
relationships between the truth values of
– the individual propositions and
– the compound propositions based on them
p q pq pq pq pq pq
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1
32
Constructing Truth Tables
• Construct the truth table for the following
compound proposition
(( p q ) q )
p q pq q (( p q ) q )
0 0 0 1 1
0 1 0 0 0
1 0 0 1 1
1 1 1 0 1
33
Solve Puzzle (an example for conversion
from English to Symbolic logic)
Thank You!
35