Lecture 4 CS 1813 – Discrete Mathematics Lecture 4 - CS 1813 Discrete Math, University of Oklahoma 9/20/2018 Lecture 4 CS 1813 – Discrete Mathematics Inference Rules, Dude CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Definitions of Variables in Haskell double-hyphen starts comment x = 3 -- defines x to be three xs = [4, 2, 9, 1] -- defines xs to be a sequence first letter in variable: lowercase andCommutes = Theorem [A `And` B] (B `And` A) -- defines andCommutes to be a Theorem proofAndCommutes = -- variable def’d to be Proof (Assume(A `And` B) {---------------------}`AndER` B, Assume(A `And` B) {---------------------}`AndEL` A) {--------------------------------------}`AndI` (B `And` A) infix alternative x `f` y means f x y indent to continue definition {- comment -} embedded comment CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Using Haskell from Windows Lecture 4 - CS 1813 Discrete Math, University of Oklahoma 9/20/2018 Using Haskell from Windows importing tools module Lecture04 where import Stdm cp = check_proof comm = Theorem [A `And` B] (B `And` A) proofComm = (Assume(A `And` B) {-------------------------}`AndER` B, Assume(A `And` B) {------------------------}`AndEL` A) {-------------------------------------}`AndI` (B `And` A) Notepad window def’n saves typing Green indicates cmd from user Prelude> :cd DMs05 Prelude> :cd Lectures Prelude> :load lecture04.hs Reading file "lecture04.hs": Reading file "Stdm.lhs": Hugs session for: C:\HUGS98\lib\Prelude.hs Stdm.lhs lecture04.hs Main> cp comm proofComm The proof is valid Hugs Session Demo of proof checker software. During a session using the Hugs interpreter, I prepare my Haskell code in a file with a .hs extension, and I keep this file open under Notepad. I start an interactive Hugs session using winhugs.exe. In the window for the interactive session, I change to the directory containing my Haskell code (:cd directory). Warning: the winhugs.exe program does not seem to support backing up in the directory structure. If you need to back up, close the session and start again. This directory containing the .hs file with the Haskell code must also contain the Stdm.lhs file that specifies a Haskell module implementing the tools supplied through the textbook’s website. I then load the .hs file containing my Haskell code. If there are syntax errors in the code, I correct them in the Notepad window, save the file, and reload (:reload). When I have successfully loaded a .hs file, I issue proof-checking commands using the theorems and proofs defined in the .hs file. CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Incorrect Proof of Theorem Theorem ( Commutes) a b |– b a Proof a b {EL} a a b {ER} b {I} b a Conclusion not in proper form (b and a in wrong positions to match I rule) a b {I} a b I rule CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Another Theorem and Proof a b, ac, bd |– c d Proof a ab {E} b E rule Modus Ponens a b {EL} a a b {ER} b ac bd What if this is on the right and this is on the left? {E} {E} c d {I} c d CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Theorem and Proof in Proof-Checker Notation Lecture 4 - CS 1813 Discrete Math, University of Oklahoma 9/20/2018 Theorem and Proof in Proof-Checker Notation proof = ((Assume(A `And` B) {------------------------- }`AndEL` A, Assume(A `Imp` C)) {-------------------------------------------}`ImpE` C, (Assume(A `And` B) {------------------------ }`AndER` B, Assume(B `Imp` D)) {-----------------------------------------}`ImpE` D) {-------------------------------------------------------------------------}`AndI` (C `And` D) theorem = Theorem [A `And` B, A `Imp` C, B `Imp` D] (C `And` D) premises (Proof, Proof) {-----------}`AndI` Prop conclusion At this point, again go to the Haskell session with lecture04.hs and again demonstrate use of proof checker. CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Inference Rules We’ve Used in Proofs a b {EL} a EL rule And Elimination Left a b {ER} b ER rule And Elimination Right Implication Elimination a ab {E} b E rule Modus Ponens Latin name: a b {I} a b I rule And Introduction How these rules work: If you have proofs of the propositions above the line (or if they are premises of the theorem you are trying to prove), you can infer the proposition below the line. CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Implication Introduction a different kind of animal a |– b {I} ab I rule If there is a proof of proposition b when you assume proposition a , then you can infer the proposition ab . What’s Different? The assumed proposition, a, need not be a premise of the theorem Nor does it have to be proved from the premises Temporary Admission The assumption a is temporarily “admitted” into the proof Later, when the {I} rule is invoked, the assumption a is discharged What! You can assume anything you want? Where’s the logic in that? The conclusion of the rule doesn’t require a to be true, or b either It only requires that if a were true, then b would also be true What happens to assumptions that aren’t discharged? They become premises of the theorem (“permanent inmates” so to speak) CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
How Implication Introduction Is Used Theorem (Implication Introduction Example) |– P Q Q Proof This proves the theorem P Q |– Q At this point the proof admits, temporarily, the extra assumption P Q Applying I discharges the P Q assumption P Q {ER} Q {I} P Q Q Implication Introduction a |– b {I} ab I rule Applying the I rule with a = P Q and b = Q We have proved P Q |– Q So, we can infer P Q Q CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
CS 1813 Discrete Mathematics, Univ Oklahoma Implication Chain Rule Settle in – it’s going to be proofs, proofs, and more proofs Theorem (Implication Chain Rule) ab, bc |– ac Suppose, somehow, we could find a proof for: a |– c Then the I rule would lead to the conclusion ac Strategy in a nutshell Assume a Prove: a |– c Conclude ac (by applying the I rule) proof remaining assumptions a ab {E} b assumption temporarily admitted discharged bc {E} c {I} ac conclusion by I CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Getting the Parens and Commas Right in Proof-Checker Notation {IL} a b (a b) False {E} False {I} a False a ( ) ( ( ) ( ) ( Assume A {---------------}`OrIL` ( ) A `Or` B , Assume((A `Or` B) `Imp` FALSE) ) {--------------------------------------------------------------}`ImpE` ( ) FALSE {--------------------------------------------------------------------}`ImpI` ( ) A `Imp` FALSE ) CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Maybe an Easier Way get syntax right, step by step {IL} a b (a b) False {E} False {I} a False a Step-by-step method aOrb = A `Or` B Main> check_proof thm prfThm The proof is valid Hugs Session hyp = aOrb `Imp` FALSE concl = A `Imp` FALSE thm = Theorem [hyp] concl prf1 = OrIL (Assume A) aOrb prf2 = ImpE (prf1, Assume hyp) FALSE prfThm = ImpI prf2 concl CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
CS 1813 Discrete Mathematics, Univ Oklahoma End of Lecture CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page