Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 4 CS 1813 – Discrete Mathematics

Similar presentations


Presentation on theme: "Lecture 4 CS 1813 – Discrete Mathematics"— Presentation transcript:

1 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

2 Definitions of Variables in Haskell
double-hyphen starts comment x = 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

3 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

4 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

5 Another Theorem and Proof
a  b, ac, bd |– c  d Proof a ab  {E} b E rule Modus Ponens a  b {EL} a a  b {ER} b ac bd What if this is on the right and this is on the left?  {E}  {E} c d  {I} c  d CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

6 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

7 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 ab  {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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

8 Implication Introduction a different kind of animal
a |– b  {I} ab I rule If there is a proof of proposition b when you assume proposition a , then you can infer the proposition ab . 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

9 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} ab 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

10 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) ab, bc |– ac Suppose, somehow, we could find a proof for: a |– c Then the I rule would lead to the conclusion ac Strategy in a nutshell Assume a Prove: a |– c Conclude ac (by applying the I rule) proof remaining assumptions a ab {E} b assumption temporarily admitted discharged bc {E} c {I} ac conclusion by I CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

11 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

12 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

13 CS 1813 Discrete Mathematics, Univ Oklahoma
End of Lecture CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page


Download ppt "Lecture 4 CS 1813 – Discrete Mathematics"

Similar presentations


Ads by Google