Lecture 7 CS 1813 – Discrete Mathematics

Download Report

Transcript Lecture 7 CS 1813 – Discrete Mathematics

Lecture 7
CS 1813 – Discrete Mathematics
Equational Reasoning
Back to the Future: High-School Algebra
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
1
Some Laws of Algebra
a + 0 = a
{+ identity}
(-a) + a = 0
{+ complement}
a  1 = a
{ identity}
a  0 = 0
{ null}
a + b = b + a
{+ commutative}
a + (b+c) = (a+b) + c {+ associative}
a(b+c) = ab + ac
{distributive law}
Equations go both ways
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
2
Theorem
(-1)  (-1) = 1
(-1)  (-1)
= ((-1)  (-1)) + 0
= ((-1)  (-1)) + ((-1) + 1)
= (((-1)(-1)) + (-1)) + 1
= (((-1)(-1)) + (-1)1) + 1
= ((-1)((-1) + 1)) + 1
= ((-1)0) + 1
=0+1
=1+0
=1
{+ id}
{+ comp}
{+ assoc}
{ id}
{dist law}
{+ comp}
{ null}
{+ comm}
{+ id}
proof by equational reasoning
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
QED
3
Laws of Boolean Algebra
From Fig 2.1, Hall & O’Donnell, Discrete Math with a Computer,
Springer, 2000
page 1
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
4
Laws of Boolean Algebra
From Fig 2.1, Hall & O’Donnell, Discrete Math with a Computer,
Springer, 2000
page 2
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
5
Theorem (a  False)  (b  True) = b
equations
{rule}
(p  False)  (q  True)
= False  (q  True)
= (q  True)  False
= q  True
= q
substitution
[formula in eqn / variable in rule]
names changed to clarify substitutions
{ null} [p /a]
{ comm} [False /a] [qTrue /b]
{ id}
[q  True /a]
{ id}
[q /a]
QED
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
6
Using Equational Proof Checker
import Stdm
th7 = (P `And` FALSE) `Or`
( Q `And` TRUE)
`thmEq` Q
pr7 =
startProof ((P `And` FALSE) `Or`
(Q `And` TRUE))
<-> (FALSE `Or` (Q `And` TRUE),
andNull)
<-> ((Q `And` TRUE) `Or` FALSE,
orComm)
<-> (Q `And` TRUE,
orID)
<-> (Q,
andID)
Notepad window
Prelude> :cd DMf00
Prelude> :cd Lectures
Prelude> :load lecture07.hs
Reading file "lecture07.hs":
Reading file "Stdm.lhs":
Reading file "lecture07.hs":
Hugs session for:
C:\HUGS98\lib\Prelude.hs
Stdm.lhs
lecture07.hs
Main> check_equation th7 pr7
The proof is correct
Hugs Session
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
7
Equations the Proof Checker Knows
andNull
orNull
andID
orID
andIdempotent
orIdempotent
andComm
orComm
andAssoc
orAssoc
andDistOverOr
orDistOverAnd
deMorgansLawAnd
deMorgansLawOr
negTrue
negFalse
andCompl
orCompl
dblNeg
currying
implication
contrapositive
absurdity
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
8
Theorem
equations
(a  b)  b = b
 absorption
{rule}
(p  q)  q
= (p  q)  (q  True)
= (q  p)  (q  True)
= q  (p  True)
= q  True
=q
substitution
[formula in eqn / variable in rule]
names changed to clarify substitutions
{ id} [q /a]
{ comm} [p /a] [q /b]
{ dist over } [q /a] [True /b] [p /c]
{ null} [p /a]
{ id}
[q/a]
QED
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
9
Theorem
equations
(a  b)  b = b
 absorption
{rule}
(p  q)  q
… exercise …
=q
substitution
[formula in eqn / variable in rule]
names changed to clarify substitutions
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
10
Consistent, But Not Minimal
redundancy among laws of Boolean algebra
Deriving the contrapositive law
Theorem (contrapositive): a  b = b  a
A proof using laws other than the contrapositive law
equations
pq
= (p)  q
= (((p)  q))
= (((p))  (q))
= (p  (q))
= (p)  ((q))
= ((q))  (p)
= (q)  (p)
{rule}
substitution
[formula in eqn / variable in rule]
{imp} [p /a] [q /b]
{dbl neg} [(p)  q /a]
{DeMorgan } [p /a] [q /b]
{dbl neg} [p /a]
{DeMorgan } [p /a] [q /b]
{ comm} [p /a] [((q)) /b]
{imp} [q /a] [p /b]
QED
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
11
End of Lecture 7
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
12