0% found this document useful (0 votes)
17 views35 pages

16 Propositional Logic and AI

AI

Uploaded by

Moiz Masood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views35 pages

16 Propositional Logic and AI

AI

Uploaded by

Moiz Masood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

CS-370 Artificial Intelligence

Propositional Logic and AI

Dr. Sohail Iqbal

Text Book: Logic in Computer Science


Ref: Discrete Mathematics by Rosen
1
Current State of AI based on LLMs

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

• This approach posits that symbolic


thought is fundamental to human
intelligence, enabling broad
generalization across tasks

4
Pros of Neuro-Symbolic AI

5
Taking a Step Back

Question

Data Learning Model Inference

Answer

6
Logic in Artificial Intelligence

Aim: To develop languages to model the


situations we encounter as computer science
professionals
such that
We can reason about these situations formally

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.

Example: A dime is better than nothing


• Nothing is better than world peace.
• Therefore, a dime is better than world peace.
(Slippery slope of language)
8
Language
• Language is mechanism for expression
Natural Languages (informal):
• English: Two divides even numbers
• French: Deux divise les nombres pairs.

• Programming languages (formal)


• Python: if n % 2 == 0, n is even

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?

• In Propositional Logic (a.k.a Propositional


Calculus or Sentential Logic), the objects are
called propositions
• Definition: A proposition is a statement that
is either true or false, but not both
• We usually denote a proposition by a letter: p,
q, r, s, …

12
Outline

• Defining Propositional Logic

– 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

• The following are not propositions


– Formal Methods is the best course Opinion
– When is the pretest? Interrogative
– Do your homework
Imperative
15
Are these propositions?

• 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 pq
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 pq pq
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 pq pq pq
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 1
21
Logical Connective: Implication (1)

• Definition: Let p and q be two propositions.


The implication pq is the proposition that is
false when p is true and q is false and true
otherwise
– p is called the hypothesis, antecedent, premise
– q is called the conclusion, consequence
p q pq pq pq pq
• Truth table 0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
22
Necessary & Sufficient (1)

There are four necessary conditions to become


eligible to be the president of Pakistan 23
Necessary & Sufficient (2)

Be eligible to be the president of Pakistan is


sufficient for the four conditions 24
Logical Connective: Implication (2)

The implication of pq can be also read as


• If p then q
• If p, q
• p only if q
• q if p
• q when p
• q whenever p
• q follows from p
• p is a sufficient condition for q (p is sufficient for q)
• q is a necessary condition for p (q is necessary for p)
25
Logical Connective: Implication (3)

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
x0.
The implication “if sin x = 0, then x = k, for some k” is true.

27
Logical Connective: Biconditional
(1)
• Definition: The biconditional pq 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 (pq)(qp)
• Truth table p q pq pq pq pq pq

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 pq 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

• 2 + 2 = 4 if and only if 2<2


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

• Consider the proposition p  q


– Its converse is the proposition q  p
– Its inverse is the proposition p  q
– Its contrapositive is the proposition q  p

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 pq pq pq pq pq

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 pq 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)

Five friends have access to a chat room. Is it


possible to determine who is chatting if the
following information is known:
1. Either Kevin or Heather or both are chatting.
2. Either Randy or Paul but not both are chatting.
3. If Abby is chatting, so is Randy
4. Paul and Kevin are either both chatting, or
neither is.
5. If Heather is chatting than so are Abby and Kevin.
34
Questions & Ideas?

Thank You!

35

You might also like