0% found this document useful (0 votes)
4 views

Week 3Propositional Logic

The document discusses Propositional Logic, focusing on Frege's Propositional Calculus which establishes a complete axiomatic system for deriving tautologies using a minimal set of connectives. It outlines the syntax, semantics, and proof methods including natural deduction and forward reasoning, emphasizing the importance of truth values and the classification of formulas into tautologies, satisfiable formulas, and contradictions. Additionally, it presents an example involving Alice's preferences to illustrate the application of propositional logic in reasoning.

Uploaded by

nisha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Week 3Propositional Logic

The document discusses Propositional Logic, focusing on Frege's Propositional Calculus which establishes a complete axiomatic system for deriving tautologies using a minimal set of connectives. It outlines the syntax, semantics, and proof methods including natural deduction and forward reasoning, emphasizing the importance of truth values and the classification of formulas into tautologies, satisfiable formulas, and contradictions. Additionally, it presents an example involving Alice's preferences to illustrate the application of propositional logic in reasoning.

Uploaded by

nisha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Artificial Intelligence:

Knowledge Representation and Reasoning

Propositional Logic

Deepak Khemani
Department of Computer Science & Engineering
IIT Madras
Expressivity: Complete Sets of Connectives Recap
It can be shown that the following sets of connectives are sufficient to express
whatever can be expressed with other connectives.
{∧, ¬}, {∨, ¬}
{⊃, ¬} Gottlob Frege used this set in his Propositional Calculus
In practice we often use the set {∧, ∨, ¬} in our implementations.
Interestingly there are two singleton sets that are complete. They are,

NAND or Not-AND NOR or Not-OR or Joint Denial


α β (α ↑ β) α β (α ↓ β)
true true false true true false
false true true false true false
true false true true false false
false false true false false true

Also known as Sheffer Stroke Also known as Peirce's arrow


Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Frege’s Propositional Calculus
• Given a set of axioms / premises which set of rules suffices to derive all entailments?
• Gottlob Frege showed that just one rule Modus Ponens with the set of connectives
{⊃, ¬} is complete, given the axioms below.
• Frege’s Propositional Calculus is an axiomatic system that can derive all true
statements or tautologies given the following axioms (accepted as true statements):

1. THEN-1 α ⊃ (β ⊃ α) Note that α and β are variables.


2. THEN-2 (α ⊃ (β ⊃ 𝛾)) ⊃ ((α ⊃ β) ⊃ (α ⊃ 𝛾))
3. THEN-3 (α ⊃ (β ⊃ 𝛾)) ⊃ (β ⊃ (α ⊃ 𝛾)) Redundant
4. FRG-1 (α ⊃ β) ⊃ (¬β ⊃ ¬α)
5. FRG-2 ¬¬α → α
6. FRG-3 α → ¬¬α

https://en.wikipedia.org/wiki/Frege_propositional_calculus
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Completeness
• Frege proved that his Propositional Calculus is complete.
• Completeness proofs are beyond the scope of this course.
• Frege’s logic is an Axiomatic System.
• This means that the KB is a set of axioms.
• Axioms are statements that are accepted as true.
• Exercise: Verify that the six axioms in Frege’s calculus are tautologies.
• Therefore, Frege’s calculus can prove all tautologies.
• Recall the Deduction Theorem:
• A, B, C, D ⊨ E iff ⊨ ((A ∧ B ∧ C ∧ D) ⊃ E)
• IF ⊨ ((A ∧ B ∧ C ∧ D) ⊃ E) then ⊢ ((A ∧ B ∧ C ∧ D) ⊃ E)
from Completeness of Frege’s Calculus
after eliminating the ∧ connective
• IF ⊢ ((A ∧ B ∧ C ∧ D) ⊃ E) THEN A, B, C, D ⊢ E
• This means that if A, B, C, D ⊨ E then A, B, C, D ⊢ E

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


PROPOSITIONAL LOGIC

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Propositional Logic
• Propositional Logic (PL) or Propositional Calculus is the simplest of logic languages
• The atomic sentence in PL is a symbol, for example P, that stands for a sentence.
• A symbol can stand for any sentence in a natural language. For example,
• P = All men are mortal
• P = The Moon is made of green cheese.
• P = The Earth is round.
• P = The Earth is flat.
• P = The tomato is a vegetable.
• P = The tomato is a fruit.
• The sentence is atomic or indivisible. We do not peer inside it.
• Logic itself is not concerned with meaning.
• Meaning lies in the mind of the beholder.
• A sentence or a proposition is in principle true or false.
• Truth values are externally supplied.
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Propositional Logic: Syntax
Every vocabulary of any logic language has two parts.

The constant or logical part of the vocabulary


• Symbols that stand for connectives or operators
• “∧”, “∨”, “¬”, and “⊃”…
• Brackets “(“, “)”, “{“, “}”…
• The constant symbols “⊥” and “⊤”
• Called Bottom and Top respectively
• Sentences whose truth value is constant
• Respectively false and true

The variable or domain specific part of the vocabulary


• A countable set of propositional symbols ℙ = {P1, P2, P3, … }
• commonly used symbols {P, Q, R, P1, Q1, R1, …}
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Sentences of Propositional Logic
Sentences of a PL are the well formed formulas or simply formulas.
The set 𝔽 of formulas is defined by structural recursion as follows.

Base: Every proposition symbol is a formula. These are the atomic formulas.
If 𝛂 ∈ ℙ then 𝛂 ∈ 𝔽

Unary connective:
If α ∈ 𝔽 then ¬α ∈ 𝔽

Binary connectives: Let ⚬ be a binary connective


If α ∈ 𝔽 and β ∈ 𝔽 then (α ⚬ β) ∈ 𝔽

The set of formulas 𝔽 is the smallest set satisfying the above.

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


A note of Frege’s Propositional Calculus
When we say that Frege’s Calculus is Propositional
we are not saying that an axiom in the calculus like
THEN-2: (α ⊃ (β ⊃ 𝛾)) ⊃ ((α ⊃ β) ⊃ (α ⊃ 𝛾))
has constituents α, β, and 𝛾 that are from the set ℙ.

Rather, that the atomic sentences in the the logic


are sentences that we do not dissect and peer into.

α, β, and 𝛾 could well have been compound sentences


from a more expressive language,
and

(α ⊃ (β ⊃ 𝛾)) ⊃ ((α ⊃ β) ⊃ (α ⊃ 𝛾)) would still be a tautology.

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


PL: Truth Functional Semantics
A valuation function 𝕍 : ℙ → {true, false} assigns a value to every proposition in ℙ

Note that this may not be specified by the user.

Often, the input KB has a collection of atomic and compound formulas, and the
task is to determine the valuation of some other specific formulas.

Given the valuation function we can lift it to all the formulas 𝕍 : 𝔽 → {true, false}
using the semantics of the logical connectives. For example,

If 𝕍(α) = true and 𝕍(β) = true then 𝕍(α ∧ β) = true


else 𝕍(α ∧ β) = false

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


True or Not True?
There are three categories of sentences or formulas.
• Tautologies: Formulas that are true for every
valuation 𝕍 : ℙ → {true, false}
• Satisfiable formulas: For which there is at least one
valuation that makes it true.
• The well known SAT problem is concerned with finding
such a valuation.
• The set of satisfiable formulas is a proper superset of the
set of tautologies.
• Contradictions: Which are false for every valuation
𝕍 : ℙ → {true, false}.
• Also known as unsatisfiable formulas.
• The set of unsatisfiable formulas is disjoint with the set of
satisfiable formulas.

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Comparing infinite sets!
Satisfiable formulas
Points to ponder
Given even a tiny alphabet {P, Q}… 𝕊
Tautologies

• The set of tautologies 𝕋 is infinite 𝕋


• (P ∨ ¬P) Unsatisfiable formulas
• (P ∨ ¬P) ∧ (Q ∨ ¬Q)
𝕌
• (P ⊃ (Q ⊃ P)
• If α, β ∈ 𝕋 then (α ∨ β) ∈ 𝕋

• Let 𝕌 be the set of unsatisfiable formulas


• For every α ∈ 𝕋 there is a ¬α ∈ 𝕌

• Let 𝕊 be the set of satisfiable formulas


• For every α ∈ 𝕋 it is true that α ∈ 𝕊
• For every α ∈ 𝕋 there is a β such that
(α ∧ β) ∈ 𝕊 and (α ∧ β) ∉ 𝕋
• For every α ∈ 𝕊 it is true that (α ∨ ¬α) ∈ 𝕋
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Semantics (Propositional Logic)
Atomic sentences in Propositional Logic can stand for anything. Consider,
Alice likes mathematics and she likes stories. If she likes mathematics she likes
algebra. If she likes algebra and likes physics she will go to college. She does not like
stories or she likes physics. She does not like chemistry and history.
Encoding: P = Alice likes mathematics. Q = Alice likes stories. R = Alice likes algebra.
S = Alice likes physics. T = Alice will go to college. U = Alice likes chemistry. V = Alice
likes history.
Then the given facts are, (P ∧ Q)
(P ⊃ R)
((R∧ S) ⊃ T)
(¬Q ∨ S)
(¬U ∧ ¬V)
That is, KB = {(P ∧ Q), (P ⊃ R), ((R∧ S) ⊃ T), (¬Q ∨ S), (¬U ∧ ¬V)}
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Proofs

(in Propositional Logic)

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Theorems and Proofs
• Any formula that is true is called a theorem.
• The process of establishing it to be a theorem is called theorem proving.
• Theorem proving is concerned with the syntactic process of constructing a proof.

There are many algorithms for theorem proving. We shall look at a few.

• Direct proof or Natural Deduction (also called Hilbert style proofs)


• Indirect proof or proof by contradiction
• The Tableaux Method
• The Resolution Refutation Method (covered later in First Order Logic)

We begin with Natural Deduction.

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Will Alice go to college?
Encoding: P = Alice likes mathematics. Q = Alice likes stories. R = Alice likes
algebra. S = Alice likes physics. T = Alice will go to college. U = Alice likes
chemistry. V = Alice likes history.
Given the knowledge base
1. (P ∧ Q)
2. (P ⊃ R)
3. ((R∧ S) ⊃ T)
4. (¬Q ∨ S)
5. (¬U ∧ ¬V)
We often have a query or a goal.
Is T true? Will Alice go to college?
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Natural Deduction
In a direct proof we choose rules of inference and add the consequents to the KB.
Remember the geometry proofs done in school?

1. (P ∧ Q) premise Alice likes mathematics and she likes stories.


2. (P ⊃ R) premise If she likes mathematics she likes algebra.
3. ((R ∧ S) ⊃ T) premise • From α∧β.
4. (¬Q ∨ S) premise • Infer α
5. P 1, simplification Simplification (S)
6. Q 1, simplification Strictly speaking first replace (P ∧ Q) with (Q ∧ P)
7. R 2, 5, modus ponens
8. S 4, 6, disjunctive syllogism
9. (R ∧ S) 7, 8, conjunction
10.T 3, 9, modus ponens

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


The Proof as a Directed Acyclic Graph (DAG)
P⊃R P∧Q ¬Q ∨ S (R ∧ S) ⊃ T ¬U ∧ ¬V

P Simplification Q

MP R S DS

Conjunction R ∧ S

T MP
The proof is the product that is published.
Finding the proof is a search process that logicians do not publish!
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Finding Proofs
The proof of α is the end product,
that is a justification of the sentence α being true

It represents a chain of inferences linking


the given facts
to the desired goal or conclusion

Proofs are found by a process of search


Remember the 4-colour theorem?

The irrelevant inferences are discarded


and only the final proof is communicated

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Forward Reasoning
A data driven chain of inferences
From facts to goals

Forward Chaining
Pick a rule with matching facts
Add the consequent to the KB
Till the goal is added to the KB

The key question is


which rule and what facts?

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


The Deduction Theorem
One problem with natural deduction is that one has to choose a rule in each cycle.
This naturally results in search.
The Deduction Theorem allows us different approaches to constructing proofs.

𝚪, 𝛂 ⊨ 𝛃 iff 𝚪 ⊨ (𝛂 ⊃ 𝛃) where 𝚪 is a set of formulas

For a sound and complete logic system this translates to

𝚪, 𝛂 ⊢ 𝛃 iff 𝚪 ⊢ (𝛂 ⊃ 𝛃) where 𝚪 is a set of formulas

Instead of guessing and adding 𝛂 to the premises,


we can equivalently directly prove (𝛂 ⊃ 𝛃).

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Show that (Premises ⊃ Conclusions) is a tautology

Given (P ∧ Q)
(P ⊃ R)
((R ∧ S) ⊃ T)
(¬Q ∨ S)

To prove T

Is equivalent to proving the following tautology with no premises

To prove ([(P ∧ Q) ∧ (P ⊃ R) ∧ ((R∧ S) ⊃ T) ∧ (¬Q ∨ S)] ⊃ T)

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


To prove (Premises ⊃ Conclusions) assume Premises
Conversely, to prove a tautological implication (𝛂 ⊃ 𝛃)
1. Create an assumption box
2. Add the antecedent(s) 𝛂
3. Prove the consequent 𝛃
4. Exit the assumption box

To show (((P ⊃ Q) ∧ (R ∧ S)) ⊃ (¬Q ⊃ ¬P))


1. ((P ⊃ Q) ∧ (R ∧ S)) Assumption
2. (P ⊃ Q) 1, Simplification
3. ((P ⊃ Q) ⊃ (¬Q ⊃ ¬P)) Instance of FRG-1
4. (¬Q ⊃ ¬P) 2,3, MP

∴ (((P ⊃ Q) ∧(R ∧ S)) ⊃ (¬Q ⊃ ¬P))

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


A Tautological Implication
To show ((P ∧ Q) ⊃ R) ⊃ (P ⊃ (Q⊃ R)) create three assumption boxes.

1. ((P ∧ Q) ⊃ R) Assumption
2. P Assumption
3. Q Assumption
4. (P ∧ Q) 2, 3, Conjunction
5. R 1, 4, MP
6. (Q ⊃ R) 3, 5, Deduction theorem
7. (P ⊃ (Q ⊃ R)) 2, 6, Deduction theorem

((P ∧ Q) ⊃ R) ⊃ (P ⊃ (Q⊃ R)) 1, 7, Deduction theorem

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Derived Rules of Inference
• Any (long) proof can be added as a new rule of inference.
• For example, if you prove (𝛂 ⊃ 𝛄) given (𝛂 ⊃ 𝛃) and (𝛃 ⊃ 𝛄) then you can add
(𝛂 ⊃ 𝛃), (𝛃 ⊃ 𝛄) ⊢ (𝛂 ⊃ 𝛄) as a derived rule of inference to the original set
with only M.P. defined by Frege in his Begriffsschrift written in 1879.
From α⊃β
1. (𝛂 ⊃ 𝛃) premise and β⊃γ
2. (𝛃 ⊃ 𝛄) premise Infer α⊃γ
3. (𝛃 ⊃ 𝛄) → (𝛂 ⊃ (𝛃 ⊃ 𝛄)) THEN-1: α ⊃ (β ⊃ α) Hypothetical
Syllogism (HS)
4. (𝛂 ⊃ (𝛃 ⊃ 𝛄)) 2, 3, MP
5. (𝛂 ⊃ (𝛃 ⊃ 𝛄)) ⊃ ((𝛂 ⊃ 𝛃) ⊃ (𝛂 ⊃ 𝛄) THEN-2
6. ((𝛂 ⊃ 𝛃) ⊃ (𝛂 ⊃ 𝛄) 4, 5, MP
7. (𝛂 ⊃ 𝛄) 1, 6, MP

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Model Checking
SAT: find a satisfying valuation for a formula.
A valuation is also called an interpretation.
If the interpretation makes the formula true we say that it is a model for the formula.

If ¬𝛂 has a model then 𝛂 may have a model too (for example, ¬(P ⊃ Q)).
If ¬𝛂 does not have a model (is unsatisfiable) then 𝛂 is a tautology.

To establish that 𝛂 is a tautology look for a model for ¬𝛂.


For example,

Look for a model for ¬[(P ∧ (P ⊃ Q)) ⊃ Q)].


Q must be false and hence (P ∧ (P ⊃ false)) must be true.
P must be true, but then (true ⊃ false) cannot be true.
Ergo, [(P ∧ (P ⊃ Q)) ⊃ Q)] is a tautology.
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Proof by Contradiction
To show that ¬((α1 ∧ α2 ∧ … ∧ αn) ⊃ β) is unsatisfiable, one can add the
negation of the goal to the set of premises.
¬((α1 ∧ α2 ∧ … ∧ αn) ⊃ β) ≡ ¬(¬(α1 ∧ α2 ∧ … ∧ αn) ∨ β)
≡ ((α1 ∧ α2 ∧ … ∧ αn) ∧ ¬β)

If the resulting set of formulas ((α1 ∧ α2 ∧ … ∧ αn) ∧ ¬β) is unsatisfiable


so is the original formula ¬((α1 ∧ α2 ∧ … ∧ αn) ⊃ β).

Then ((α1 ∧ α2 ∧ … ∧ αn) ⊃ β) is a tautology

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Model Checking: The Tableau Method
Given any 𝛂 the Tableau Method looks for a model for ¬𝛂.
It does so by eliminating logical connectives and collecting sets of propositions or
their negations (these are also called literals) that are a model for a given formula.

For example,
• In a model for (P ∧ Q) both P and Q must be present.
• In a model for (P ⊃ Q) either Q must be present or ¬P must be present.
• There are two possibilities of finding a model.

If an interpretation has both P and ¬P then it cannot be a model.

If there is no model for ¬𝛂 then 𝛂 is a tautology.

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Tableau Rules
The following rules are used to breakdown a compound formula (for four connectives)

Connective ¬ ∧ ∨ ⊃
¬X (X ∧ Y) (X ∨ Y) (X ⊃ Y)
Formula
¬X X ¬X Y
X Y
Y

Negated ¬¬X ¬(X ∧ Y) ¬(X ∨ Y) ¬(X ⊃ Y)


Formula
X ¬X X
¬X ¬Y ¬Y
¬Y

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Constructing the Tableau
• Add the negated goal to the set of premises / axioms in the tableau
• Pick an unused formula in the tableau and eliminate the main connective
• Mark the formula as used (it can be removed)
• the constituents are added to each ”column” below it
• Each column is an interpretation
• Termination of a column :
IF a column has both X and ¬X it cannot be a model
• It is unsatisfiable
• it can be closed
ELSE IF it has no more connectives
• it is satisfiable and is a model

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Modus Ponens [(P ∧ (P ⊃ Q)) ⊃ Q)] is sound
1 ¬[(P ∧ (P ⊃ Q)) ⊃ Q)] Eliminate the main connective ⊃

2 (P ∧ (P ⊃ Q))
¬Q

P
3 (P ⊃ Q))

¬P Q

Closed because P and ¬P are in the column


Likewise for Q and ¬Q. No model exists.
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Is Abduction [(Q ∧ (P ⊃ Q)) ⊃ P)] valid?
1 ¬[(Q ∧ (P ⊃ Q)) ⊃ P)]

2 (Q ∧ (P ⊃ Q))
¬P

Q
3 (P ⊃ Q))

¬P Q
No more connectives to eliminate
{¬P, Q} is a model for ¬[(Q ∧ (P ⊃ Q)) ⊃ P)]
Abduction is not a sound rule of inference
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Will Alice go to college?
Processing the formulas in
1. (P ∧ Q) premise the order presented.
2. (P ⊃ R) premise
3. ((R ∧ S) ⊃ T) premise We are unable to find an
4. (¬Q ∨ S) premise interpretation in which the
premises are true and the
¬T negated conclusion
conclusion is false.
P
Q

¬P R

T 5. ¬(R ∧ S) S

¬Q ¬R ¬S

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Order of eliminating connectives
Certain connectives introduce branching in the tableau
They are best tackled after the ones that do not.
Consider the following two proofs.

3 P∨Q 1 P∨Q
R∨S 2 R∨S
1 ¬P ∧ ¬S 3 ¬P ∧ ¬R
2 ¬(Q ∨ S) ¬(Q ∨ S)
4
¬P
¬R P Q
¬Q
¬S R S R S
¬P ¬P ¬P ¬P
P Q ¬R ¬R ¬R ¬R
¬Q
The tree on the left is smaller! ¬S
Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Proving Frege’s THEN-2 Axiom
1. ¬[(P ⊃ (Q ⊃ R))] ⊃ [(P ⊃ Q) ⊃ (P ⊃ R)] Negated axiom
2. (P ⊃ (Q ⊃ R)) After 1
3. ¬[(P ⊃ Q) ⊃ (P ⊃ R)] After 1

4. ¬P After 2 5. (Q ⊃ R)) After 2


6. (P ⊃ Q) After 3 8. (P ⊃ Q) After 3
7. ¬(P ⊃ R) After 3 9. ¬(P ⊃ R) After 3

10. ¬P 6 11. Q 6 14.¬Q 5 15. R 5


12. P 7 13. P 7

16. ¬P 8 17. Q 8 18. ¬P 8 19. Q 8


20. P 9 21. P 9 22. P 9
23. ¬R 9

from Logical Labyrinths by Raymond Smullyan


Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning
Proving Frege’s THEN-2 Axiom
1. ¬[(P ⊃ (Q ⊃ R))] ⊃ [(P ⊃ Q) ⊃ (P ⊃ R)] Negated axiom
2. (P ⊃ (Q ⊃ R)) After 1
3. ¬[(P ⊃ Q) ⊃ (P ⊃ R)] After 1
4. (P ⊃ Q) After 3
5. ¬(P ⊃ R) After 3 Processing linear rules
6. P After 5 before branching rules
7. ¬R After 5 results in a smaller tableau

8. ¬P After 2 9. (Q ⊃ R)) After 2

10. ¬P 4 11. Q 4

12.¬Q 9 13. R 9

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning


Next

First Order Logic

Deepak Khemani Artificial Intelligence: Knowledge Representation and Reasoning

You might also like