Date post: | 08-Apr-2018 |
Category: |
Documents |
Upload: | kanakkshetri |
View: | 221 times |
Download: | 0 times |
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 1/31
DiscreteMathComputer 06 - Propositional Logic
Kanak Kshetri
1 Chapter Outline
• Difficulties with informal logic
• Propositional logic (one type of formal logic)
• Three mathematical systems for reasoning about propositions:
– Truth Tables: easy to understand but unwieldy for large expressions; “semantic
technique”
– Natural Deduction: “syntactic technique”, uses inference rules
– Boolean Algebra: axiomatic approach
2 Need for Formalism
• Natural language has ambiguities and subtleties
– e.g. “and” can sometimes suggest an implication as in “The sun is shining and Iam happy”
• Proposition: variable whose value must be either True or False
• Logical Operators: and, or, not, implies . Operate on propositions
• Statements that can’t be represented by propositional logic (due to lack of context):
– e.g. “That cloud looks like a motor bike”
– context required: which cloud? who thinks that it looks like a motor bike?
3 Basic Logical Operators
3.1 Logical And (∧)• aka Conjunction
1
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 2/31
3.1.1 Truth Table
A B A ∧ B
False False FalseFalse True TrueTrue False False
True True True
3.2 Inclusive Or (∨)
• aka Disjunction
3.2.1 Truth Table
A B A ∨ B
False False FalseFalse True TrueTrue False True
True True True
3.3 Exclusive Or (⊕)
• Either one or the other, but not both
3.3.1 Truth Table
A B A ⊕ B
False False FalseFalse True TrueTrue False True
True True False
3.4 Logical Not (¬)
3.4.1 Truth Table
A ¬A
True FalseFalse True
3.5 Logical Implication (⇒)
• Use to represent conditional phrases
• e.g. “If it is sunny today, then there will be a picnic.”
• Implication does not say anything about cause-and-effect
2
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 3/31
3.5.1 Truth Table
A B A ⇒ B
False False TrueFalse True TrueTrue False False
True True True
3.5.2 Understanding the truth table
• Why is an implication true even if A is False?
• One way to think about is that an implication is a statement that if something happensthen something else must also happen
– So, if the first event happens, but the second doesn’t, the implication must havebeen faulty
– But the first event doesn’t happen at all, then we’re indifferent about the implica-
tion
• Rephrasing the above point, “If A then B” is like saying that “A” is sufficient for B tooccur
– So, if we see an A but not a B, clearly A isn’t sufficient for B
– But if we see a B on its own, maybe something other than A caused it.
– e.g. Matchsticks are sufficient for fire. But just because you use a lighter to makea fire doesn’t mean matchsticks can’t cause fire. However, if you have a matchstickand still can’t produce fire, it clearly isn’t sufficient.
• Book is a little handwavy and just says “this is the way it is”
3.6 Logical Equivalence (⇔)
• Use to make a claim that two propositions always have the same value, or are equivalent
• aka “If and only if”, “necessary and sufficient”
3.6.1 Truth Table
A B A ⇔ B
False False TrueFalse True False
True False FalseTrue True True
3.6.2 "If and only If"
• A ⇔ B can be written as (A ⇒ B) ∧ (B ⇒ A)
3
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 4/31
4 The Language of Propositional Logic
4.1 Well-Formedness
• Have a grammar for propositional logic
•
If a formula doesn’t follow this grammar, it isn’t well formed• e.g. Well-Formed Formula: A ⇒ (B ∧ (¬A))
• e.g. not Well-Formed Formula: ∧AB¬C
• Well-formedness is only about the syntax and says nothing about the semantics
of the formula
– e.g. “if it compiles”, then it is well-formed. Just because something compiles doesn’tmean it’ll pass all the tests
4.2 Syntax of Well-Formed Formulas
• Constants False and True are WFF.
• Any propositional variable is WFF.
• Negation: If a is WFF, then ¬a is WFF
• Conjunction: If a and b are WFF, then a ∧ b is WFF
• Disjunction: If a and b are WFF, then a ∨ b is WFF
• Implication: If a and b are WFF, then a ⇒ b is WFF
• Equivalence: If a and b are WFF, then a ⇔ b is WFF
4.2.1 Example: P ⇒ (Q ∧ R) is a WFF
• P,Q,R are WFF because they’re propositional variables
• So, Q ∧ R is a WFF (conjunction rule)
• So, P ⇒ (Q ∧ R) is a WFF (implication rule)
4.3 Order of Precedence
• Negation (¬) is the most tightly binding operator
• Conjunction (∧)
• Disjunction (∨)
• Implication (⇒)
• Equivalence (⇔) is the least tightly binding operator
4
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 5/31
4.4 Object Language and Meta Language
• WFFs of propositional language will be called object language
– They refer to sentences in propositional logic
• Language of equations, substitutions, and justifications will be called the meta lan-
guage
– The surround the object language
– They’re used to talk about propositions
4.5 Computing with Boolean Expressions
• ¬x is writtenn o t x
• a ∧ b is writtena & & b
• a ∨ b is writtena | | b
• a ⇒ b is writtena = = > b
• a ⇔ b is written a < = > b
4.6 (Exercise 1) : Lying Bus Driver
4.6.1 Scenario
• Want to go to the airport, are at the bus stop
• Either this bus or the next is going to the airport, but not both
• Can only ask one “yes-or-no” question
• Some drivers will answer “yes” when the correct answer is “no”
– You don’t know if this bus driver is one of those people
• Ask one “yes or no” question that can help you decide whether to take this bus or thenext
4.6.2 Solution 1
• I first gave names to the situations:
– A: this bus goes to the airport– So, ¬A means the next one goes to the airport
– L: this driver is a liar
– So, ¬L means this driver answers truthfully
• I want to formulate my question so that if the answer is “True”, then A.
5
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 6/31
• I then made a table of the possible situations:
L A Desired Answer
True True TrueTrue False FalseFalse True TrueFalse False False
• So, clearly just asking A gives me the desired answer regardless of what L is
4.7 (Exercise 2) : Evaluating propositional formulas
• False ∧ True
– False
• True ∨ (¬True)
– True
• ¬(False ∨ True)
– ¬True
– False
• (¬(False ∧ True)) ∨ False
– (¬False) ∨ False
– True ∨ False
– True
• (¬True) ⇒ True
– False ⇒ True
– True
• True ∨ False ⇒ True
– True ⇒ True
– True
• True ⇒ (True ∧ False)
– True ⇒ False
– False
• False ⇒ False
– True
6
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 7/31
• ¬False ⇔ True
– True ⇔ True
– True
• True ⇔ (False ⇒ False)
– True ⇔ True
– True
• False ⇔ (True ∧ (False ⇒ True))
– False ⇔ (True ∧ True)
– False ⇔ True
– False
• ¬(True ∨ False) ⇔ False ∧ True
– ¬True ⇔ False
– False ⇔ False
– True
4.7.1 Verification using the Book’s Stdm Library
∗Stdm> False /\ True
False
∗Stdm> True \ / ( not True)True
∗
Stdm> not ( False \ / True )False
∗Stdm> ( not ( False / \ True ) ) \ / False
True
∗Stdm> ( not True) ==> True
True
∗Stdm> True \ / False ==> True
True
∗Stdm> True ==> ( True / \ False )False
∗Stdm> False ==> False
True
∗Stdm> ( not False ) <=> True
True
∗Stdm> True <=> ( False ==> False )True
∗Stdm> False <=> ( True / \ ( False ==> True ) )False
7
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 8/31
∗Stdm> ( not ( True \ / False ) ) <=> False / \ True
True
∗Stdm>
5 Truth Tables: Semantic Reasoning
• Table
• Column headers are all the variables (and expressions)
• Add a row for each possible setting of values for variables
– 3 variables means 23 = 8 rows
– because 2 possible settings for each of the 3 variables
5.1 Example: Calculating using a Truth Table
• Suppose we want to know when the proposition ((A ⇒ B) ∧ ¬B) ⇒ ¬A is true
• Make a Truth TableA B A ⇒ B ¬B (A ⇒ B) ∧ ¬B ¬A ((A ⇒ B) ∧ ¬B) ⇒ ¬A
F F T T T T TF T T F F T TT F F T F F TT T T F F F T
5.2 Definition: Tautology
• Proposition that is always True, regardless of its variables
5.3 Definition: Contradiction
• Proposition that is always False, regardless of its variables
5.4 Definition: Entailment ()
• P 1, P 2, · · · , P n Q means that if all the propositions P 1, P 2, · · · , P n are True, then Q isalso True
5.4.1 Discussion
• makes a statement about actual meanings of propositions
• Model of a logic system: Set of truth values along with the method for calculatingmeaning of any well-formed formula
• Different values of n
– n = 1 gives P Q, which has the same semantics as ⇒
– n = 0 gives Q, which means that Q is always True, or is a tautology
8
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 9/31
5.5 Limitations of Truth Tables
• Size is exponential in number of variables
• Other techniques (natural deduction, Boolean algebra) give much better insight intowhy a proposition is true
5.6 Exercise 3: Determine which formulas are tautologies using truth ta-bles
5.6.1 (True ∧ P ) ∨ Q
P Q True ∧ P (True ∧ P ) ∨ Q
T T T TT F T TF T F TF F F F
• not a tautology
• without truth tables: (True ∧ P ) ∨ Q becomes P ∨ Q, which is False when both P and Q
are False
5.6.2 (P ∨ Q) ⇒ (P ∧ Q)
P Q P ∨ Q P ∧ Q (P ∨ Q) ⇒ (P ∧ Q)
T T T T TT F T F FF T T F FF F F F T
• not a tautology
5.6.3 (P ∧ Q) ⇒ (P ∨ Q)
P Q P ∧ Q P ∨ Q (P ∨ Q) ⇒ (P ∧ Q)
T T T T TT F F T TF T F T TF F F F T
• Tautology
5.6.4 (P ∨ Q) ⇒ (Q ∨ P )
P Q P ∨ Q Q ∨ P (P ∨ Q) ⇒ (P ∧ Q)
T T T T TT F T T TF T T T TF F F F T
9
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 10/31
• Tautology
• Without Truth Table: by commutativity of ∨
5.6.5 ((P ∨ Q) ∧ (P ∨ R)) ⇔ (P ∧ (Q ∨ R))
P Q R P ∨ Q P ∨ R LHS Q ∨ R RHS LHS ⇔ RHSF F F F F F F F TF F T F T F T F TF T F T F F T F TF T T T T T T F F
T F F T T T F F FT F T T T T T T TT T F T T T T T TT T T T T T T T T
• Not a tautology
5.7 Exercise 4: Determine Well-formedness, and build a truth table
5.7.1 (True ∧ P ) ∨ Q
• Truth table from Ex 3.1
• See that it is satisfiable, but not a tautology
5.7.2 ((P ∨ Q) ∧ (P ∨ R)) ⇔ (P ∧ (Q ∨ R))
• Truth table from Ex 3.5
•
Satisfiable, but not a tautology
5.7.3 ((P ∧ ¬Q) ∨ (Q ∧ ¬P )) ⇒ ¬(P ⇔ Q)
P Q A=P ∧ ¬Q B=Q ∧ ¬P A ∨ B C=(P ⇔ Q) ¬C (A ∨ B) ⇒ C
T T F F F T F TT F T F T F T TF T F T T F T TF F F F F T F T
• Tautology
5.7.4 (P ⇒ Q) ∧ (P ⇒ ¬Q)
P Q LHS=P ⇒ Q RHS=P ⇒ ¬Q LHS ∧ RHS
T T T F FT F F T FF T T T TF F T T T
10
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 11/31
• Satisfiable, but not a tautology
5.7.5 (P ⇒ Q) ∧ (¬P ⇒ Q)
P Q LHS=P ⇒ Q RHS=¬P ⇒ Q LHS ∧ RHS
T T T T T
T F F T FF T T T TF F T F F
• Satisfiable, but not a tautology
5.7.6 (P ⇒ Q) ⇔ (¬Q ⇒ ¬P )
P Q LHS=P ⇒ Q RHS=¬Q ⇒ ¬P LHS ⇔ RHS
T T T T TT F F F T
F T T T TF F T T T
• Tautology
• (This is just the contrapositive)
6 Natural Deduction: Inference Reasoning
6.1 Introduction
• Natural deduction allows us to reason about logical propositions without substituting
values for variables
• Logical Inference: reasoning formally about a set of statements. Requires:
– Object Language: to talk about the statements we’re reasoning about. e.g. Propo-sitional expressions
– Inference Rules: Rules to infer new facts from information given
– Meta Language: Defines the “form of argument” so that we can determinewhether arguments are actually valid
6.1.1 Definition: Sequent ()
• P 1, P 2, · · · , P n Q is called a sequent
• Means: if all propositions P 1, · · · , P n are known, then proposition Q can be inferredformally using the rules of natural deduction
• e.g. Difference between P Q ⇒ P and P Q ⇒ P
11
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 12/31
– The version doesn’t say how we know that Q ⇒ P when we assume P . It justsays that it is True.
– The version says that there is a proof that shows Q ⇒ P when we assume P
6.1.2 Meta Variables
• Meta variables can stand for any WFF proposition
• e.g. we can have a be P ∧ Q
• Convention: meta variables will be written in lower case, propositional variables inupper case
6.1.3 Writing an Inference Rule
• Assumptions are written above a horizontal line
• Conclusion written below the line.
• (For latex simplicity, I’ll just use the sequent notation to talk about inference rules)
• Inference rule only works in one direction
6.2 Definitions of True, Not and Equivalence
6.2.1 Primitives
• Only primitive objects are constant False, and ∨, ∧, ⇒
• All other objects are built using these
• Below we give definitions for some primitives
– can be verified using truth tables
– But we’ll only manipulate them using rules of logical deduction
6.2.2 Definition: True
• True = False ⇒ False
• (Verify using truth table, but this particular definition is “trivial” because that’s howwe defined implication)
6.2.3 Definition: Negation
• ¬a = a ⇒ False
• Proof (via truth tables):
– Suppose a is True, then right side becomes True → False, which is False
12
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 13/31
– Suppose a is False, then right side becomes False → False, which we defined tobe True
– So in both cases the definition is consistent
• Consistency (via logical inference only):
– If a is True, then ¬True is True ⇒ False which is (False ⇒ False) ⇒ False
– We have a rule called Reduction Ad Absurdum which allows us to infer False from(False ⇒ False) ⇒ False
– If a is False, then ¬False is $False ⇒ False$< which we defined to be True
6.2.4 Definition: Equivalence
• a ⇔ b = (a ⇒ b) ∧ (b ⇒ a)
• (Note that’s the definition of if and only if)
•
Proof by Truth Table:
a b a ⇒ b b ⇒ a LHS RHS
T T T T T TT F F T F FF T T F F FF F T T T T
• Hence, this formula is also correct
6.3 IMPORTANT: Note on Proofs of the Inference Rules
• I’ve “proven” each of the inference rules by making references to the Truth Table
• But it looks like that might be circular atleast based on the discussion in the sectionon “Inferring the Operator Truth Tables”
• Assume that you have a system with FALSE, and three operators OR, AND, IMPLIES
• Pretend that it is just a coincidence that they match the names of Boolean operators
6.4 And Introduction
6.4.1 Definition: a, b a ∧ b
• Proof:
– We know that a and b are True
– By definition of ∧, a ∧ b is True
13
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 14/31
6.4.2 Usage Example 1
• Statement: (R ⇒ S ), ¬P (R ⇒ S ) ∧ ¬P
• Proof:
– Use and introduction
6.4.3 Usage Example 2
• Statement: P,Q,R (P ∧ Q) ∧ R
• Proof:
– If P and Q are True, P ∧ Q is True by and introduction
– Since, R is True, another usage of and introduction means (P ∧ Q) ∧ R is True aswell
• Note: This can be written in a tree diagram type form (Page 130)
6.4.4 Exercise 10:
• Statement: Prove P,Q,R P ∧ (Q ∧ R)
• Proof:
– If Q and R are True, Q ∧ R is true by and introduction
– If, P is true, another application of and introduction means P ∧ (Q ∧ R) is True aswell
• Note, we could have proven this simply by noting the associativity of ∧
6.4.5 Exercise 11
• Shape of x = A ∧ (B ∧ (C ∧ D))
– Right-heavy tree
– If there are 2n variables in x, then the height of the proof tree will also be 2n
– (At each level, we can reason about one of the variables in x)
• Shape of y = (A ∧ B) ∧ (C ∧ D))
– Balanced tree: height is logarithmic in number of variables
– (At each level, we can reason about half of the variables in y)
14
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 15/31
6.5 And Elimination
6.5.1 Definition: (a ∧ b) a, (a ∧ b) b
• Proof:
– We know that a ∧ b is True
– But a ∧ b is True exactly when both a and b are True
– So, if the conjunction is True, they must individually be True as well
6.5.2 Usage Example
• Statement: P, Q ∧ R P ∧ Q
• Proof:
– P is True by assumption
– Q ∧ R means Q is True by and elimination
– Since both P and Q are true, P ∧ Q is True (by and introduction)
6.5.3 Usage Example
• Statement: (P ∧ Q) ∧ R R ∧ Q
• Proof:
– By and elimination, both P ∧ Q and R are True
– Another and elimination on P ∧ Q yields True for P and Q
– So, both Q and R are True, by and introduction, Q ∧ R is True
6.5.4 Usage Example
• Statement: P ∧ Q Q ∧ P
• Proof:
– By and elimination, both P and Q are True
– By and introduction, Q ∧ P is True
• This proves the commutativity of And (which we could have also done using TruthTables)
15
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 16/31
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 17/31
6.6.3 Usage Example
• Statement: a, a ⇒ b, b ⇒ c c
• Proof:
– By Modus Ponens on a, a ⇒ b, we see that b is True
– By Modus Ponens on b, b ⇒ c, we see that c is True
6.6.4 Exercise 13
• Statement: P, P ⇒ Q, (P ∧ Q) ⇒ (R ∧ S ) S
• Proof:
– By Modus Ponens on P, P ⇒ Q, we see that Q is True
– By And Introduction, P ∧ Q is True
– By Modus Ponens on P ∧ Q, P ∧ Q ⇒ R ∧ S , we see that R ∧ S is True
– By And Elimination on R ∧ S , we see that both R and S are True
6.6.5 Exercise 14
• Statement: P ⇒ Q, R ⇒ S, P ∧ R S ∧ R
• Proof:
– By And Elimination on P ∧ R, we see that P and R are True
– By Modes Ponens on R, R ⇒ S , we see that S is True
– By And Introduction on R and S , we see that S ∧ R is True
6.7 Imply Introduction
6.7.1 Definition: (a b) (a ⇒ b)
• “In order to imply the logical implication a ⇒ b, you must have a proof of b using a asan assumption”
6.7.2 Example Usage
• Statement: (P ∧ Q) ⇒ Q
• Since the doesn’t have anything to the left, it is saying that this is a tautology
• What proof do we have for this?
– Consider the sequent P ∧ Q Q, which is just and elimination
– So, we have a proof for P ∧ Q Q, which means we can write P ∧ Q ⇒ Q byImplies introduction
17
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 18/31
• Assumptions Made
– And Elimination assumed P ∧ Q is True.
– We can’t infer Q without this assumption.
– So, this appears in the sequent to the left of the in P ∧ Q Q– But the entire sequent P ∧ Q Q doesn’t have any further assumptions
∗ Whenever P ∧ Q is true, Q is true.
– So, this sequent can be put in as an assumption without adding any other assump-tions
– This is why when we do implies introduction, we get (P ∧ Q) ⇒ Q
6.7.3 Discharged assumptions
• Assumptions that are made temporarily to establish a sequent, and which is thenthrown away
• E.g. to establish the sequent P ∧ Q Q, we made an assumption P ∧ Q
• Once we got P ∧ Q Q, we don’t need to assumption for any other purpose
• Indicate discharged assumptions by boxes
6.7.4 Implication Chain Rule
• Statement: a ⇒ b, b ⇒ c a ⇒ c
• Proof:
– Since we are trying to prove a ⇒ c, we must use Imply Introduction somewhere– This means that we need to show a c
– Assume a is True, then by Modus Ponens on a ⇒ b, b is True
– Since b is True, by Modus Ponens on b ⇒ c, c is True
– So, we have a sequent a c, and we can discharge the assumption that a is True
– By Imply Introduction on a c, we get ac
6.7.5 Modus Tollens
• Statement: a ⇒ b, ¬b ¬a
• Proof:
– ¬a is an abbreviation for a ⇒ False
– This means that we need to use Imply Introduction
– Expand ¬a and ¬b to get: a ⇒ b, b ⇒ False a ⇒ False
– This is just implication chain rule
18
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 19/31
6.7.6 Exercise 15
• Statement: P Q ⇒ P ∧ Q
• Proof:
– We are trying to prove an implication Q ⇒ P ∧Q, means we have to Imply Introduction
– To introduce imply, we need to prove the sequent Q P ∧ Q
– We know that P is true from what is given
– Assume that Q is true.
– By and introduction, we have P, Q P ∧ Q
– This sequent does not have any further assumptions, so we can discharge the as-sumption that B is True
– So, we have the sequent Q P ∧ Q, which means we have Q ⇒ P ∧ Q byintroduce imply
•
(Maybe incorrect)
6.7.7 Exercise 16
• Statement: P ∧ Q ⇒ Q ∧ P
• Proof:
– We need to use introduce imply on the sequent P ∧ Q Q ∧ P
– But that’s just commutativity of ∧, which we proved earlier, the sequent holdswithout any further assumptions
– So, we can introduce imply on the sequent to get the desired answer
6.8 Or Introduction
6.8.1 Definition: a a ∨ b and b a ∨ b
• Proof
– By the definition of , if one of its arguments is true, then the whole expressionbecomes true
6.8.2 Example Usage
• Statement: P ∧ Q P ∨ Q
• Proof
– By and elimination on P ∧ Q, we have P is True, Q is True
– By or introduction, we have P ∨ Q is True
19
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 20/31
6.8.3 Exercise 17
• Statement: P ⇒ False ∨ P
• Proof
– To prove this implication, we need to prove the sequent P False ∨ P
– But that sequent is True by or introduction
– So, by introduce implication, we have P ⇒ False ∨ P
6.8.4 Exercise 18
• Statement: P, Q (P ∧ Q) ∨ (Q ∨ R)
• Proof:
– By and introduction, we have P ∧ Q is True
– By or introduction, we have Q ∨ R is True
– By or introduction, (P ∧ Q) ∨ (Q ∨ R) is True
– (Actually, knowing that P ∧ Q is True is sufficient because we can or introduce thatto get True)
6.9 Or Elimination
6.9.1 Definition (((a ∨ b), (a c), (b c)) c)
• This is Proof by Case Analysis
• Proof:
– Assumption is that a ∨ b is True
– By the definition of ∨ (from Truth Table), atleast one of a and b must be True
– Suppose a is True
∗ We have a c, i.e. a proof that c is True when a holds
– Otherwise, b is True
∗ We have b c, i.e. a proof that c is True when a holds
– So, c is True whenever the assumptions hold
• (Did i just prove Proof by Case Analysis by DOING proof of case analysis? Somethingis weird here. . . )
20
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 21/31
6.9.2 Example Usage
• Statement: (P ∧ Q) ∨ (P ∧ R) P
• Proof:
– Suppose P ∧ Q is True, then by and elimination, P is True
– Suppose instead that P ∧ R is True, then by and elimination, P is True
– So, we have ((P ∧ Q) ∨ (P ∧ R)), (P ∧ Q) P, (P ∧ R) P
– Use or elimination to get that P is True
6.9.3 Example Usage
• Statement: (a ∧ b) ∨ (a ∧ c) (b ∨ c)
• Proof:
– Assume a ∧ b by and elimination, we get a ∧ b b
– Discharge the assumption a ∧ b because we have a sequent
– By or introduction, we have b b ∨ c
– Assume a ∧ c by and elimination, we get a ∧ c c
– Discharge the assumption a ∧ c
– By or introduction, we have c b ∨ c
– We can no do or elimination on (a ∧ b) ∨ (a ∧ c) (b ∨ c), ((a ∧ b) b) b ∨ c, ((a ∧ c)
c) b ∨ c
– This gives us b ∨ c
6.10 Identity
6.10.1 Definition a a
• It is necessary because we can’t prove P P without it.
6.10.2 Theorem: True
• By definition, True = False ⇒ False
• So, we need to introduce imply to prove this
• To introduce imply, we need to prove the sequent False False
• This is true by identity
• So, we have False ⇒ False or equivalently, True
21
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 22/31
6.11 Contradiction
6.11.1 Definition: False a
• Anything can be inferred if the assumption is False
• (Remember the Truth table for P ⇒ Q gave True when P was False?)
• Expresses the fact that False is untrue purely using logical inference
– Can’t just say False is not True, because we defined True that way
– Also doesn’t rely on us making “intuitionistic” statements like “False is Wrong”
6.11.2 Example Usage
• Statement: P, ¬P Q
• Proof:
– ¬P is shorthand for P ⇒ False– So, from P, P ⇒ False by modus ponens, we have False
– False Q follows from contradiction
6.11.3 Example Usage
• Statement; a ∨ b, ¬a b
• Proof:
– ¬a is shorthand for a ⇒ False
– Performing or elimination on a ∨ b,
∗ Assume a is True, then we have a, a ⇒ False, which by Modus Ponens givesus False
∗ So, by contradiction, b is True
∗ (Discharge the assumption that a is True)
∗ Assume b is True, the by identity, b is True
∗ (Discharge the assumption that b is True)
∗ Combining, we have (a ∨ b, ¬a), (((a ∨ b) a), a ⇒ False) b, (((a ∨ b) b) b),we can now perform or elimination
6.12 Reduction Ad Absurdum
6.12.1 Definition: (¬a False) a
• If you can infer False from an assumption ¬a, then you must conclude that a is true
• This is the Proof by Contradiction strategy
22
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 23/31
6.12.2 Example Usage
• Statement: ¬¬a a
• Proof:
– Strategy: Assume ¬a and show that it leads us to infer False (proof by contradic-tion)
– Assuming ¬a, we have ¬a, ¬¬a
– Expand out the abbreviations to get: a ⇒ False, (a ⇒ False) ⇒ False
– Since we have a ⇒ False and (a ⇒ False) ⇒ False, by Modus Ponens, we haveFalse
– So, by reductio ad absurdum, a Must be True if ¬¬a is True
6.13 Inferring the Operator Truth Tables
• Two fundamental questions:
– Are inference rules powerful enough?
– Will they ever allow us to make mistakes?
• profound and difficult questions, modern research has shown some astonishing results
• Easy version of first question: Are inference rules powerful enough to infer the truthtables of logical operators?
6.13.1 Example: Deriving the Truth Table value of True ∧ False
• Want to show that it is logically equivalent to False, and not logically equivalent to True
• To show equivalence with False, we need to show: False ⇒ (True ∧ False), True ∧
False ⇒ False
– False (True ∧ False) follows from contradiction
– By introduce implication, we have False ⇒ (True ∧ False)
– True ∧ False False
∗ Expand out True the expression is now False ∧ (False ⇒ False)
∗ By and elimination, we get False ∧ (False ⇒ False) False, which by identitygives us False False
∗ By introduce implication, we have True ∧ False ⇒ False
23
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 24/31
6.13.2 Exercise: Calculating value of True ∧ True
• Proof that True ∧ True ⇒ True
– By and elimination, we have True ∧ True True
– By identity, we have True True
– By introduce implication, we have True ∧ True ⇒ True
• Proof that True ⇒ (True ∧ True)
– Need to prove the sequent True True ∧ True
– By and introduction, we have True True ∧ True
– By introduce implication, we have True ⇒ True ∧ True
6.13.3 Exercise: Calculating the value of True ∨ False
• Proof that True ∨ False ⇒ True
– We have True True from identity
– We have False True from contradiction
– So, we have (True ∨ False), (True True), (False True)
– By or elimination, we have (True ∨ False) True
– By introduce implication, we have True ∨ False ⇒ True
• Proof that True ⇒ (True ∨ False)
– From or introduction, we have True (True ∨ False)
– By introduce implication, we have True ⇒ (True ∨ False)
6.13.4 Extra Credit: What happens when we try to say True ∨ False is False?
• Need to show equivalence
• Proof that False ⇒ (True ∨ False)
– False (True ∨ False) by contradiction
– By introduce implication, we have False ⇒ (True ∨ False)
• Proof that (True ∨ False) ⇒ False
– Need to do an or elimination
– False False comes from identity
– True False needs to be shown
– Expand out True: False ⇒ False False needs to be shown
– Since False is not True, we can’t use Modus Ponens
– We have no applicable inference rule to use
24
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 25/31
6.13.5 Exercise
• When we computed value of True ∧ False, we used and elimination to say that (False ⇒
False) ∧ False False
• But we could have said (False ⇒ False) False (False ⇒ False) which is True
• What would have happened then?
– We would have had to show that True False
– That is, False ⇒ False False
– Same situation as in extra credit: Have no valid inference law to use; so can’tdeduce.
7 Proof Checking by Computer
7.1 Proof Checkers and Theorem Provers
• Proof Checker: reads in a theorem and a proof. Determines if the proof is valid
• Theorem Prover: reads in a theorem and attempts to generate a proof
7.2 Example of Proof Checking
• See 06-proofs.hs
8 Boolean Algebra: Equational Reasoning
8.1 Introduction
8.1.1 Approaches to Propositional Logic
• Truth Tables: semantic approach
• Natural Deduction: syntactic approach
• Boolean Algebra: axiomatic approach
8.1.2 Equational Reasoning
• Show that two values are the same by building chains of equalities
– e.g. show that a = b and b = c, so a = c
• can substitute equals for equals
– if x = y, can substitute in x wherever y is used
25
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 26/31
8.2 Laws of Boolean Algebra
8.2.1 Operations with Constants
• a ∧ False = False
• a ∧ True = True
• Identity for or: a ∨ True = True
• Identity for and: a ∨ False = a
• Exercise 25: Simplification
– (P ∧ False) ∨ (Q ∧ True)
– False ∨ (Q ∧ True)
– Q ∧ True
– Q
• Exercise 26
– Prove that: (P ∧ False) ∧ True) = False
– Direct Proof:
∗ (P ∧ False) ∧ True)
∗ False ∧ True
∗ False
8.2.2 Basic Properties of ∧ and ∨
• Disjunctive Implication: a ⇒ a ∨ b (Or Introduction)
• Conjunctive Implication: a ∧ b ⇒ a (And Elimination)
• Idempotence: a ∧ a = a
• Idempotence: a ∧ a = a
• Commutative: a ∧ b = b ∧ a
• Commutative: a ∨ b = b ∨ a
• Associativity: (a ∧ b) ∧ c = a ∧ (b ∧ c)
• Associativity: (a ∨ b) ∨ c = a ∧ (b ∨ c)
• Exercise 27
26
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 27/31
– Prove: (P ∧ ((Q ∨ R) ∨ Q)) ∧ S = S ∧ ((R ∨ Q) ∧ P )
– Direct Proof starting from LHS
– (P ∧ ((Q ∨ R) ∨ Q)) ∧ S
– (P ∧ ((R ∨ Q) ∨ Q)) ∧ S (by commutativity of or)
– (P ∧ (R ∨ (Q ∨ Q)) ∧ S (by associativity of or)– (P ∧ (R ∨ Q)) ∧ S (by idempotence of or)
– ((R ∨ Q) ∧ P ) ∧ S (by commutivatiy of and)
– S ∧ ((R ∨ Q) ∧ P ) (by commutivatiy of and)
• Exercise 28
– Prove: P ∧ (Q ∧ (R ∧ S )) = ((P ∧ Q) ∧ R) ∧ S
– Direct proof starting from LHS
– P ∧ (Q ∧ (R ∧ S ))
– ((P ∧ Q) ∧ (R ∧ S )) (by associativity of and)
– ((P ∧ Q) ∧ R) ∧ S (by associativity of and)
8.2.3 Distributive and De Morgan’s Laws
• And distributes over Or: a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c)
• Or distributes over And: a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c)
• De Morgan: ¬(a ∧ b) = ¬a ∨ ¬b
• De Morgan: ¬(a ∨ b) = ¬a ∧ ¬b
• Exercise 29
– Give an intuitive explanation of second De Morgan’s laws
– If none of (a, b) are true, it means that a is not true and b is not true
8.2.4 Laws on Negation
• ¬True = False
• ¬False = True
• a ∧ ¬a = False
• a ∨ ¬a = True
• ¬(¬a) = a
27
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 28/31
8.2.5 Laws on Implication
• Modus Ponens: a ∧ (a ⇒ b) ⇒ b
• Modus Tollens: ¬b ∧ (a ⇒ b) ⇒ ¬a
• Disjunctive Syllogism: (a ∨ b) ∧ ¬ ⇒ b
• Implication Chain: (a ⇒ b) ∧ (b ⇒ c) ⇒ (a ⇒ c)
• Implication Combination: (a ⇒ b) ∧ (c ⇒ d) ⇒ ((a ∧ c) ⇒ (b ∧ d))
• Currying: (a ∧ b) ⇒ c = a ⇒ b ⇒ c
• Implication: a ⇒ b = ¬a ∧ b
• Contrapositive: a ⇒ b = ¬b ⇒ ¬a
• Absurdity: (a ⇒ b) ∧ (a ⇒ ¬b) = ¬a
•
Understanding the currying law
– Says there are two equivalent ways of establishing that a and b both hold
– One of them is to say a ∧ b
– The other is to have an implication on a and an implication on b
– If either of a or b is false,
∗ a ∧ b is false, so (a ∧ b) ⇒ c is vacuous
∗ Either a ∧ b or b ∧ c is vacuous (if a is False, then the first one is vacuous, if b
is false, the second one)
•
Understanding the Implication Law
– allows us to prove a ⇒ b
– Note that we don’t have an “Introduce Implication” rule like in natural deduction
– So we use this rule
8.2.6 Logical Equivalence
• a ⇔ b is the same as (a ⇒ b) ∧ (b ⇒ a)
• Subtle difference between ⇔ and =
– = is an operator in the meta language that says that two sides of an equation havethe same value
– ⇔ is in the object language itself and it gives a new proposition
• Exercise 30
28
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 29/31
– Prove: (A ∨ B) ∧ BB
– Strategy: We’ll reduce the left side of the equivalence to be the right side
– (A ∨ B) ∧ B
– (A ∨ B) ∧ (B ∨ False) (by Identity of OR)
– (B ∨ A) ∧ (B ∨ False) (commutativity of AND)– B ∨ (A ∧ False) (distributivity of OR)
– B ∨ False
– B
• Exercise 31
– Prove: ((¬A ∧ B) ∨ (A ∧ ¬B)) ⇔ (A ∨ B) ∧ (¬(A ∧ B))
– Direct proof starting from “left side”
– (¬A ∧ B) ∨ (A ∧ ¬B)
– (¬A ∨ (A ∧ ¬B)) ∧ (B ∨ (A ∧ ¬B)) (by distributing the OR over the AND)
– ((¬A ∨ A) ∧ (¬A ∨ ¬B)) ∧ ((B ∨ A) ∧ (B ∨ ¬B)) (by distributing the OR over the AND)
– (True ∧ (¬A ∨ ¬B)) ∧ ((B ∨ A) ∧ True)
– (¬A ∨ ¬B) ∧ (B ∨ A)
– ¬(A ∧ B) ∧ (B ∨ A) (by Demorgan’s laws)
• Exercise 32
– Prove: ¬(A ∧ B) ≡ ¬A ∨ ¬B
– Direct proof starting from “right side”– ¬A ∨ ¬B
– ¬(¬(¬A ∨ ¬B)) (Double negation is just identity)
– ¬(A ∧ B) (by De Morgan’s other law)
• Exercise 33
– Prove: (A ∨ B) ∧ (¬A ∨ C ) ∧ (B ∨ C ) ⇔ (A ∨ B) ∧ (¬A ∨ C )
– Proof is by cases on A
– Case: A is True∗ LHS: (True ∨ B) ∧ ((¬True) ∨ C ) ∧ (B ∨ C )
∗ i.e. True ∧ C ∧ (B ∨ C )
∗ i.e. C ∧ (B ∨ C )
∗ i.e. C (proven in Review Exercise 45)
∗ RHS: (True ∨ B) ∧ ((¬True) ∧ C )
29
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 30/31
∗ i.e. True ∧ C
∗ i.e. C
∗ So the equality holds in this case
– Case: A is False
∗ LHS: (False ∨ B) ∧ ((¬False) ∨ C ) ∧ (B ∨ C )
∗ i.e. B ∧ True ∧ (B ∨ C )
∗ i.e. B ∧ (B ∨ C )
∗ i.e. B
∗ RHS: (False ∨ B) ∧ ((¬False) ∨ C )
∗ i.e. B ∧ True
∗ i.e. B
∗ So, the equality holds in this case
– Since the equality holds in both cases, the statement is proven.
9 Logic in Computer Science
• Talks about applications of theorem provers
10 Meta Logic
• Making statements about the logical system itself
• Fundamental Meta-Logic operators:
– P 1, P 2, · · · , P n Q means there is a proof that shows Q from the assumptionsP 1, · · · , P n
– P 1, P 2, · · · , P n Q means Q must be tree if all assumptions are true, but saysnothing about the proof
10.1 Definition: Consistency of a Logical System
• A formal system is consistent if, for all well-formed formulas a and b, if a b then a b
• That is, each proposition that is provable is actually True
10.2 Definition: Completeness of a Logical System
• A formal system is complete if, for all well-formed formulas a and b, if a b then a b
• That is, every proposition that is true can be proved using the system
10.3 Theorem: Propositional Logic is consistent and complete
• No proof given
30
8/7/2019 Discrete Mathematics Using a Computer - 06 - Propositional Logic Notes
http://slidepdf.com/reader/full/discrete-mathematics-using-a-computer-06-propositional-logic-notes 31/31
10.4 Godel’s Theorem: A logical system powerful enough to express ordi-nary arithmetic must be either inconsistent or incomplete
• It is impossible to capture all of mathematics in a safe logical system
11 Further Reading• Forever Undecided: A Puzzle Guide to Godel by Raymond Smullyan
– “Don’t miss it”
• Godel, Escher, Bach: An Eternal Braid by Douglas Hofstadter
– “Another unmissable classic”
• How to Prove it: A Structured approach by Daniel Velleman
– Good source for hints on carrying out proofs with lots of example
• Computer-Aided Reasoning: An approach: by Matt Kaufmann, Panagiotis Mano-lios, and J Strother Moore
– Describes the ACL2 theorem prover
• Introduction to HOL: by M Gordon and T Melham
– Describes the HOL theorem prover
• Logic for Mathematics and Computer Science by Burris
– “more advanced treatement of mathematical logic”
• A Mathematical Introduction to Logic by Enderton
– “standard presentation of logic from a mathematical perspective”
• Type Theorey and Functional Programming by Thompson
– “detailed development of relationship between inference rules and rules used todefine type systems”
• Logic and Declarative Language by Downward
• Proofs and Types by Girard, Lafont and Taylor
– relationship between inference proofs and type systems at a research level
31