#3 formal methods – propositional logic
Post on 15-Feb-2017
1.191 Views
Preview:
TRANSCRIPT
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
1
Prepared by: Sharif Omar Salem – ssalemg@gmail.com
Formal Methods :Propositional Logic
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
2
Prepositional logic is a formal system of representing knowledge
Prepositional logic has:Syntax – what the allowable expressions are. Structure of the
sentence.Semantics – what the expressions mean. MeaningProof theory – how conclusions are drawn from a set of
statements. Reasoning.
Introduction
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
3
Symbols represent factsE.g. “Penguins need a cold environment” is a factThat could be represented by the symbol P
Each fact is called an atomic formulas or atoms
Atomic propositions can be combined using logical connectives –
Order of precedence: ¬ ∧ ∨ → ↔
Propositional Logic - Syntax
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
These symbols P, Q,………. etc used to represent propositions, are called atomic formulas, or simply atoms.
To express more complex propositions such as the following compound proposition, we use logical connectives such as → (if-then or imply):“if car brake pedal is pressed, then car stops within five
seconds.”This compound proposition is expressed in propositional
logic as: P → Q
Atomic formula (Atoms)
4
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
We can combine propositions and logical connectives to form complicated formulas.
Well-Formed Formulas: Well-formed formulas in propositional logic are defined recursively as follows:1. An atom is a formula.2. If F is a formula, then (¬F) is a formula, where ¬ is the not operator. 3. If F and G are formulas, then (F G), (F G), (F → G),and (F ↔G) are ∧ ∨
formulas. ( is the and operator, is the or operator , ↔ stands for if and ∧ ∨only if or iff.)
4. All formulas are generated using the above rules.
Well-Formed formulas (WFF)
5
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
6
Logic is made up sentencesP might be a sentenceP Q is also a sentence∧
If we know the truth values of P and Q, we can work out the truth value of the sentence.
If P and Q are both true then P Q is true, otherwise it is false∧Can use truth tables to ascertain the truth of a sentence
Semantics/ Interpretation
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
An interpretation of a propositional formula G is an assignment of truth values to the atoms A1,... , An in G in which every Ai is assigned either T or F, but not both.
The Figure shows the truth table for several simple formulas.
Semantics/ Interpretation
7
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
A literal is an atomic formula or the negation of an atomic formula. A clause is a wff express a fact (premises or conclusion).A clause set is a group of clause express an argument.A formula is in conjunctive normal form (CNF) if it is a conjunction
of disjunction of literals.
A formula is in disjunctive normal form (DNF) if it is a disjunction of conjunction of literals.
Some other definitions
8
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
9
P - represents the fact “Penguins eat fish”Q - represents the fact “Penguins like fish”
P Q – Penguins eat fish ∧ and penguins like fishP Q – Penguins eat fish ∨ or penguins like fish¬ Q – Penguins do not like fishP → Q
Penguins eat fish therefore penguins like fish.If penguins eat fish then penguins like fish.
P ↔ Q Penguins eat fish therefore penguins like fish
and penguins like fish therefore penguins eat fish.
Propositional Logic – example
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
10
If the train arrives late and there is no taxi at the station, then john is late for this meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station.
Propositional Logic – Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
11
If the train arrives late and there is no taxi at the station, then john is late for this meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station.
Propositional Logic – Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
12
If the train arrives late and there is no taxi at the station, then john is late for this meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station.
Propositional Logic – Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
13
If the train arrives late and there is no taxi at the station, then john is late for this meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station.
Propositional Logic – Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
14
Definition of Argument:An argument is a sequence of statements in which the conjunction of
the initial statements (called the premises/hypotheses) is said to imply the final statement (called the conclusion).
An argument can be presented symbolically as
(P1 Λ P2 Λ ... Λ Pn) Qwhere P1, P2, ..., Pn represent the hypotheses and Q represents the conclusion.
Deriving a logical conclusion by combining many propositions and using formal logic: hence, determining the truth of arguments.
This formula representing the whole argument as hypothesis and conclusion is known as NATURAL DEDUCTION
Propositional Logic – Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
15
What is a valid argument? An argument is valid if Q (conclusion) logically follow from P1, P2, ..., Pn
(hypotheses)Informal answer: Whenever the truth of hypotheses leads to the conclusion
A formula is valid iff it is true under all its interpretations. (Called Tautology) A formula is invalid iff it is not valid.
A valid argument is intrinsically true, i.e. (P1 Λ P2 Λ ... Λ Pn) Q is a tautology.
Note: We need to focus on the relationship of the conclusion to the hypotheses and not just any knowledge we might have about the conclusion Q.
Propositional Logic –Valid Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
16
Example:P1: Neil Armstrong was the first human to step on the moon.P2 : Mars is a red planet
And the conclusionQ: No human has ever been to Mars.This wff P1 Λ P2 Q is not a tautology ( Not True)
Truth of Hypothesis doesn’t lead to the conclusion. Mean the argument is not valid.
Propositional Logic –Valid Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
17
Example:P1: Tokyo is located in Japan.P2 : Japan is not located in Europe.
And the conclusionQ: Tokyo is not located in EuropeThis wff P1 Λ P2 Q is a tautology ( Always True)
Truth of Hypothesis leads to the conclusion. Mean the argument is valid.
Propositional Logic –Valid Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
18
Russia was a superior power, and either France was not
strong or Napoleon made an error. Napoleon did not make
an error, but if the army did not fail, then France was strong.
Hence the army failed and Russia was a superior power.
Converting it to a propositional form using letters A, B, C and D
A: Russia was a superior powerB: France was strong B: France was not strongC: Napoleon made an error C: Napoleon did not make an
errorD: The army failed D: The army did not fail
Translating Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
19
A: Russia was a superior powerB: France was strong B: France was not strongC: Napoleon made an error C: Napoleon did not make an errorD: The army failed D: The army did not fail
Combining, the statements using logic(A Λ (B V C)) hypothesisC hypothesis(D B) hypothesis(D Λ A) conclusion
Combining them, the propositional form is (A Λ (B V C)) Λ C Λ (D B) (D Λ A)
Translating Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
20
Example:
Real Madrid is a superior power team, and either FC Barcelona is not
strong or Juardiola make an error. Juardiola does not make an error, but
if FC Barcelona wins the game, then FC Barcelona is strong. Hence FC
Barcelona loses the game and Real Madrid is a superior power team.
Converting atomic prepositions to propositional symbolsConverting it to a propositional form using letters W, X, Y and Z
W: Real Madrid is a superior power team.X: FC Barcelona is strong X: FC Barcelona is not strongY: Juardiola make an error Y: Juardiola do not make an errorZ: FC Barcelona loses the game Z: FC Barcelona wins the game
Translating Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
21
W: Real Madrid is a superior power team.X: FC Barcelona is strong X: FC Barcelona is not strongY: Juardiola make an error Y: Juardiola do not make an errorZ: FC Barcelona loses the game Z: FC Barcelona wins the game
Convert verbal argument to propositional logic (hypothesis, conclusion and form)(W Λ (X V Y)) hypothesisY hypothesis(Z X) hypothesis (Z Λ W) conclusion
Argument form is (W Λ (X V Y)) Λ Y Λ (Z X) (Z Λ W)
Translating Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
22
Example:
If the program is efficient, it executes quickly. Either the program is
efficient, or it has a bug. However, the program does not execute
quickly. Therefore it has a bug.
Converting Key statements to propositional symbolsE: The program is efficient.Q: The program executes quickly Q: The program does not execute quicklyB: The program has a bug
Translating Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
23
Convert verbal argument to propositional logic (hypothesis, conclusion and form)E Q hypothesisE B ˅ hypothesisQ’ hypothesis B conclusion
Argument form is(E Q) (E B) Q’ ˄ ˅ ˄ B
Translating Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
24
If the room temperature is hot, then the air conditioner is on. If
the room temperature is cold, then the heater is on. If the
room temperature is neither hot nor cold, then the room
temperature is comfortable. Therefore, If neither the air
conditioner nor the heater is on, then the room temperature
is comfortable.
Translate the argument using propositional Logic.
Excersise
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
25
How to prove Validity of an argument?Truth Table proof
Equivalency Laws deduction proof
Resolution Theorem proof
Propositional Logic –Proof Theory
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
26
If the room temperature is hot, then the air conditioner is on. If the room temperature is cold, then the heater is on. If the room temperature is neither hot nor cold, then the room temperature is comfortable. Therefore, If neither the air conditioner nor the heater is on, then the room temperature is comfortable.Converting Key statements to propositional symbols
H = the room temperature is hot C = the room temperature is cold M = the room temperature is comfortable A = the air conditioner is on G = the heater is on.
Convert propositional logic (hypothesis/conclusion/form) Hypothesis1: F1= H A Hypothesis2: F2= C G Hypothesis3: F3= ¬(H ˅ C) M Conclusion: F4= ¬(A ˅ G) M
Truth Table proof
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
27
Argument Formula: F1 F2˄ F3˄ F4 (H A) (˄ C G) [˄ ¬(H ˅ C) M] [¬(A ˅ G) M]
Truth Table proof
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
28
To prove this proposition with the truth-table technique. You have
to exhaustively checks every interpretation of the formula F4 to
determine if it evaluates to T. The truth table shows that every
interpretation of F4 evaluates to T, thus F4 is valid.
Truth Table proof
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
29
Definition of Proof Sequence:It is a sequence of wffs in which each wff is either a hypothesis or
the result of applying one of the formal system’s derivation rules to earlier wffs in the sequence.
Derivation rules for propositional logic areEquivalence Rules.Inference Rules.Deduction Method.
Equivalency Laws-Deduction proof
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
30
Tautological propositiona tautology is a statement that can never be falseall of the lines of the truth table have the result "true"
Contradictory propositiona contradiction is a statement that can never be trueall of the lines of the truth table have the result "false"
Logical equivalence of two propositionstwo statements are logically equivalent if they will be true in exactly the
same cases and false in exactly the same casesall of the lines of one column of the truth table have all of the same
truth values as the corresponding lines from another column of the truth table
it's indicated using or ↔
Special results in the truth table
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
31
These rules state that certain pairs of wffs are equivalent, hence one can be substituted for the other with no change to truth values.
The set of equivalence rules are summarized here:
Equivalence Rules
Expression Equivalent to Abbreviation for ruleR V SR Λ S
S V RS Λ R
Commutative (comm)
(R V S) V Q (R Λ S) Λ Q
R Λ (S Λ Q)R V (S V Q)
Associative (ass)
(R V S) (R Λ S)
R Λ SR V S
De-Morgan’s Laws(De-Morgan)
R S R V S implication (imp)R (R) Double Negation (dn)
PQ (P Q) Λ (Q P) Equivalence (equ)Q P P Q Contraposition- cont
P P Λ P Self-reference - selfP V P P Self-reference - self
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
32
Example for using Equivalence rule in a proof sequence:Simplify (A V B) V C to an argument.
The result must be an argument in the form ofP1 ^ P2^………..Pn Q
Equivalence Rules
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
33
Example for using Equivalence rule in a proof sequence:Simplify (A V B) V C to an argument.
The result must be an argument in the form ofP1 ^ P2^………..Pn Q
Equivalence Rules
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
34
Inference rules allow us to add a wff to the last part of the proof sequence, if one or more wffs that match the first part already exist in the proof sequence. ( Works in one direction , unlike equivalence rules)
Inference Rules
From Can Derive Abbreviation for ruleR, R S S Modus Ponens- mpR S, S R Modus Tollens- mt
R, S R Λ S Conjunction-conR Λ S R, S Simplification- simR R V S Addition- add
P Q, Q R P R Hypothetical syllogism- hs
P V Q, P Q Disjunctive syllogism- ds
(P Λ Q) R P (Q R) Exportation - expP, P Q Inconsistency - inc
P Λ (Q V R) (P Λ Q) V (P Λ R) Distributive - distP V (Q Λ R) (P V Q) Λ (P V R) Distributive - dist
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
35
To prove an argument of the form
P1 Λ P2 Λ ... Λ Pn R Q
Deduction method allows for the use of R as an additional hypothesis and thus prove
P1 Λ P2 Λ ... Λ Pn Λ R Q
Deduction Method
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
36
Example : Prove (A B) Λ (B C) (A C)
Deduction Method
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
37
Prove that (P Q) (Q P) is a valid argument (called Contraposition – con).
Proofs of inference rules
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
38
Prove the argumentA Λ (B C) Λ [(A Λ B) (D V C)] Λ B D
Proofs using Propositional Logic
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
39
Prove the argumentA Λ (B C) Λ [(A Λ B) (D V C)] Λ B D
First, write down all the hypotheses.1. A2. B C3. (A Λ B) (D V C)4. B
Proofs using Propositional Logic
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
40
Prove the argumentA Λ (B C) Λ [(A Λ B) (D V C)] Λ B DFirst, write down all the hypotheses.1. A2. B C3. (A Λ B) (D V C)4. BUse the inference and equivalence rules to get at the conclusion D.5. C 2,4, mp6. A Λ B 1,4, con7. D V C 3,6, mp8. C V D 7, comm9. C D 8, imp
and finally10. D 5,9 impThe idea is to keep focused on the result and sometimes it is very easy to go down
a longer path than necessary.
Proofs using Propositional Logic
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
41
Russia was a superior power, and either France was not strong or Napoleon made an error. Napoleon did not make an error, but if the army did not fail, then France was strong. Hence the army failed and Russia was a superior power.
Q: Prove the upper argument ? From previous slides we translate this argument to the following
argument formula
(A Λ (B V C)) Λ C Λ (D B) (D Λ A)
Now we have to proof this propositional formula using proof sequence.
Proving Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
42
Prove (A Λ (B V C)) Λ C Λ (D B) (D Λ A)
Proof sequence1. A Λ (B V C) hyp2. C hyp3. D B hyp4. A 1, sim5. B V C 1, sim6. C V B 5, comm7. B 2, 6, ds8. B (D) 3, cont9. (D) 7, 8, mp10. D 9, dn11. D Λ A 4, 10 , con
Verbal Argument Proof
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
43
Example: Real Madrid is a superior power team, and either FC Barcelona is not strong
or Juardiola make an error. Juardiola does not make an error, but if FC Barcelona wins the game, then FC Barcelona is strong. Hence FC Barcelona loses the game and Real Madrid is a superior power team.
Q: Prove the upper argument ? From previous slides we translate this argument to the following
argument formula
(W Λ (X V Y)) Λ Y Λ (Z X) (Z Λ W)
Now we have to proof this propositional formula using proof sequence.
Proving Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
44
Prove the propositional form using the prove sequence rules (equivalence, inference and deduction)
Proving Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
45
Example: If the program is efficient, it executes quickly. Either the program is
efficient, or it has a bug. However, the program does not execute quickly. Therefore it has a bug.
Q: Prove the upper argument ? From previous slides we translate this argument to the following
argument formula
(E Q) (E B) Q’ ˄ ˅ ˄ B
Now we have to proof this propositional formula using proof sequence.
Proving Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
46
(E Q) (E B) Q’ ˄ ˅ ˄ BProve the propositional form using the prove sequence rules (equivalence, inference and deduction)
Proving Verbal Arguments
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
47
For Proving Verbal Arguments, you need to pass three stepsStep 1: Converting atomic prepositions to propositional
symbols
Step 2: Convert verbal argument to propositional logic (hypothesis, conclusion and form)
Step 3: Prove the propositional form using the prove sequence rules (equivalence, inference and deduction)
Recap
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
48
Prepared by: Sharif Omar Salem – ssalemg@gmail.com
End of Lecture
Prep
ared
by:
Sha
rif
Om
ar S
alem
– s
sale
mg@
gmai
l.com
49
Prepared by: Sharif Omar Salem – ssalemg@gmail.com
Next Lecture:Predicate Logic
top related