Logic in Computer Science: BITS Pilani

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Logic in Computer Science

Prof. Tathagata Ray


Associate Professor, BITS Pilani, Hyderabad Campus
rayt@hyderabad.bits-pilani.ac.in
BITS Pilani
Hyderabad Campus
Natural Deduction

• In natural deduction we use a collection of rules.

• By applying these rules in succession, we may infer a


conclusion from a set of premises.

• Suppose we have a set of formulas/premises 𝜙1 , 𝜙2 , . . , 𝜙𝑛 ,


and another formula ψ, which we call conclusion.
• By applying proof rules to the premises, we hope to get
some more formulas, and by applying more proof rules to
those, to eventually obtain the conclusion.
• 𝜙1 , 𝜙2 , . . , 𝜙𝑛 ⊢ 𝜓
• This expression is called a sequent.
• A sequent is valid if a proof for it can be found.
BITS Pilani, Hyderabad Campus
Our first rule: The rule of
Conjunction
The rule of conjunction(∧): We can conclude 𝜙 ∧ 𝜓 given
that we have already concluded 𝜙 and 𝜓 separately.

How to write? premises

𝜙 𝜓 And introduction
∧𝑖
𝜙∧𝜓
conclusion

BITS Pilani, Hyderabad Campus


The rule of Conjunction

• Just like the rule to introduce conjunction, there are two


rules to eliminate

𝜙∧𝜓
• ∧ 𝑒1 : if you have a proof of 𝜙 ∧ 𝜓, then by applying
𝜙
this rule you can get a proof of 𝜙.

𝜙∧𝜓
• ∧ 𝑒2 : if you have a proof of 𝜙 ∧ 𝜓, then by applying
𝜓
this rule you can get a proof of 𝜓.

Be careful with the pattern and invoke the right rule

BITS Pilani, Hyderabad Campus


Example

• Prove 𝑝 ∧ 𝑞, 𝑟 ⊢ 𝑞 ∧ 𝑟 is valid.

• 1: 𝑝 ∧ 𝑞 premise
• 2: 𝑟 premise
• 3: 𝑞 ∧ 𝑒2 1
• 4: 𝑞 ∧ 𝑟 ∧ 𝑖 3,2

BITS Pilani, Hyderabad Campus


Exercise

• Prove 𝑝 ∧ 𝑞 ∧ 𝑟, 𝑠 ∧ 𝑡 ⊢ 𝑞 ∧ 𝑠 is valid.

• 1: (𝑝 ∧ 𝑞) ∧ 𝑟 premise
• 2: 𝑠 ∧ 𝑡 premise
• 3: 𝑝 ∧ 𝑞 ∧ 𝑒1 1
• 4: 𝑞 ∧ 𝑒2 3
• 5: 𝑠 ∧ 𝑒1 2
• 6: 𝑞 ∧ 𝑠 ∧ 𝑖 4,5

BITS Pilani, Hyderabad Campus


Exercise

Prove 𝑞 ∧ 𝑠 ⊢ 𝑠 ∧ 𝑞 is valid.

BITS Pilani, Hyderabad Campus


The rules of double negation

• Intuitively, there is no difference between a formula 𝜙


and its double negation ¬¬𝜙.

• The sentence “It is not true that it does not rain” is


crooked way to say “It rains”.

¬¬𝜙
• Rule: ¬¬𝑒
𝜙

𝜙
• Rule: ¬¬𝑖
¬¬𝜙

BITS Pilani, Hyderabad Campus


Example

• Prove the validity of the following sequent.


• 𝑝, ¬¬(𝑞 ∧ 𝑟) ⊢ ¬¬𝑝 ∧ 𝑟
• Proof:
• 1. 𝑝 premise
• 2. ¬¬(𝑞 ∧ 𝑟) premise
• 3. ¬¬ 𝑝 ¬¬𝑖 1
• 4. (𝑞 ∧ 𝑟) ¬¬𝑒 2
• 5. 𝑟 ∧ 𝑒2 4
• 6. ¬¬ 𝑝 ∧ 𝑟 ∧ 𝑖 3,5

BITS Pilani, Hyderabad Campus


Rule for eliminating
implication
• There is one rule to introduce ⟶ and one to eliminate it.

• The elimination rule is called “modus ponens”/implies-


elimination/arrow-elimination.

𝜙 𝜙⟶𝜓
• Rule: ⟶𝑒
𝜓

BITS Pilani, Hyderabad Campus


Example

• Proof the validity of the following sequent


• 𝑝 → 𝑞 ⟶ 𝑟 , 𝑝 ⟶ 𝑞, 𝑝 ⊢ 𝑟
• Proof
• 1. 𝑝 → (𝑞 ⟶ 𝑟) premise
• 2. 𝑝 ⟶ 𝑞 premise
• 3. 𝑝 premise
• 4. (𝑞 ⟶ 𝑟) ⟶ 𝑒 1,3
• 5. 𝑞 ⟶ 𝑒 2,3
• 6. 𝑟 ⟶ 𝑒 4,5

BITS Pilani, Hyderabad Campus


Modus Tollens

𝜙⟶𝜓 ¬𝜓
• 𝑀𝑇
¬𝜙

• If Abrahm Lincoln was Ethiopian then he was African.


Abraham Lincoln was not african; therefore he was not
Ethiopian.

BITS Pilani, Hyderabad Campus


Example

• Proof the validity of the following sequent


• 𝑝 → 𝑞 ⟶ 𝑟 , 𝑝, ¬𝑟 ⊢ ¬𝑞
• Proof
• 1. 𝑝 → (𝑞 ⟶ 𝑟) premise
• 2. 𝑝 premise
• 3. ¬𝑟 premise
• 4. (𝑞 ⟶ 𝑟) ⟶ 𝑒 1,2
• 5. ¬𝑞 MT 4,3

BITS Pilani, Hyderabad Campus


Example

• Proof the validity of the following sequent


• ¬𝑝 → 𝑞, ¬𝑞 ⊢ 𝑝
• Proof
• 1.¬𝑝 → 𝑞 premise
• 2.¬𝑞 premise
• 3. ¬¬𝑝 MT 1,2
• 4. 𝑝 ¬¬𝑒 3

BITS Pilani, Hyderabad Campus


Example

• Proof the validity of the following sequent


• 𝑝 → ¬𝑞, 𝑞 ⊢ ¬𝑝
• Proof
• 1.𝑝 → ¬𝑞 premise
• 2.𝑞 premise
• 3. ¬¬𝑞 ¬¬𝑖 2
• 4.¬𝑝 MT 1,3

BITS Pilani, Hyderabad Campus


Summary
Rule Name
𝜙 𝜓 And introduction
∧𝑖
𝜙∧𝜓

𝜙∧𝜓 And Elimination 1


∧ 𝑒1
𝜙
𝜙∧𝜓 And Elimination 2
∧ 𝑒2
𝜓
¬¬𝜙 Double –negation elimination
¬¬𝑒
𝜙
𝜙 Double-negation introduction
¬¬𝑖
¬¬𝜙
𝜙 𝜙 ⟶𝜓 Rule for eliminating implication(Modus
⟶𝑒 Ponens)
𝜓
𝜙 ⟶ 𝜓 ¬𝜓 Modus Tollens (MT)
𝑀𝑇
¬𝜙
BITS Pilani, Hyderabad Campus

You might also like