Week 3 recap Need to know for this course Recursion Be very comfortable with recursive definitions Recursive datatypes and functions Know how to do structural induction Induction and structural induction 1 2 Summary of topics Well-formed formulas (SYNTAX) COMP2111 Week 4 Boolean Algebras Term 1, 2020 Valuations (SEMANTICS) Propositional Logic CNF/DNF Proof Natural deduction 3 4
Summary of topics Well-formed formulas Let Prop = { p , q , r , . . . } be a set of propositional letters. Consider the alphabet Well-formed formulas Σ = Prop ∪ {⊤ , ⊥ , ¬ , ∧ , ∨ , → , ↔ , ( , ) } . Boolean Algebras Valuations The well-formed formulas (wffs) over Prop is the smallest set of CNF/DNF words over Σ such that: Proof ⊤ , ⊥ and all elements of Prop are wffs Natural deduction If ϕ is a wff then ¬ ϕ is a wff If ϕ and ψ are wffs then ( ϕ ∧ ψ ), ( ϕ ∨ ψ ), ( ϕ → ψ ), and ( ϕ ↔ ψ ) are wffs. 5 6 Examples Conventions To aid readability some conventions and binding rules can and will be used. The following are well-formed formulas: Parentheses omitted if there is no ambiguity (e.g. p ∧ q ) ( p ∧ ¬⊤ ) ¬ binds more tightly than ∧ and ∨ , which bind more tightly ¬ ( p ∧ ¬⊤ ) than → and ↔ (e.g. p ∧ q → r instead of (( p ∧ q ) → r ) ¬¬ ( p ∧ ¬⊤ ) Other conventions (rarely used/assumed in this course): The following are not well-formed formulas: ′ or · for ¬ p ∧ ∧ + for ∨ p ∧ ¬⊤ · or juxtaposition for ∧ ( p ∧ q ∧ r ) ∧ binds more tightly than ∨ ¬ ( ¬ p ) ∧ and ∨ associate to the left: p ∨ q ∨ r instead of (( p ∨ q ) ∨ r ) → and ↔ associate to the right: p → q → r instead of ( p → ( q → r )) 7 8
Conventions Parse trees To aid readability some conventions and binding rules can and will The structure of well-formed formulas (and other grammar-defined be used. syntaxes) can be shown with a parse tree . Parentheses omitted if there is no ambiguity (e.g. p ∧ q ) Example ¬ binds more tightly than ∧ and ∨ , which bind more tightly (( P ∧ ¬ Q ) ∨ ¬ ( Q → P )) than → and ↔ (e.g. p ∧ q → r instead of (( p ∧ q ) → r ) Other conventions (rarely used/assumed in this course): ∨ ′ or · for ¬ + for ∨ · or juxtaposition for ∧ ∧ binds more tightly than ∨ ∧ and ∨ associate to the left: p ∨ q ∨ r instead of (( p ∨ q ) ∨ r ) → and ↔ associate to the right: p → q → r instead of ( p → ( q → r )) 9 10 Parse trees Parse trees The structure of well-formed formulas (and other grammar-defined The structure of well-formed formulas (and other grammar-defined syntaxes) can be shown with a parse tree . syntaxes) can be shown with a parse tree . Example Example (( P ∧ ¬ Q ) ∨ ¬ ( Q → P )) (( P ∧ ¬ Q ) ∨ ¬ ( Q → P )) ∨ ∨ ¬ ∧ ∧ 11 12
Parse trees Parse trees The structure of well-formed formulas (and other grammar-defined The structure of well-formed formulas (and other grammar-defined syntaxes) can be shown with a parse tree . syntaxes) can be shown with a parse tree . Example Example (( P ∧ ¬ Q ) ∨ ¬ ( Q → P )) (( P ∧ ¬ Q ) ∨ ¬ ( Q → P )) ∨ ∨ ∧ ¬ ∧ ¬ → → ¬ ¬ P P Q Q P 13 14 Parse trees formally Summary of topics Formally, we can define a parse tree as follows: A parse tree is either: Well-formed formulas (B) A node containing ⊤ ; Boolean Algebras (B) A node containing ⊥ ; Valuations (B) A node containing a propositional variable; CNF/DNF (R) A node containing ¬ with a single parse tree child; Proof (R) A node containing ∧ with two parse tree children; Natural deduction (R) A node containing ∨ with two parse tree children; (R) A node containing → with two parse tree children; or (R) A node containing ↔ with two parse tree children. 15 16
Definition: Boolean Algebra Examples of Boolean Algebras A Boolean algebra is a structure ( T , ∨ , ∧ , ′ , 0 , 1) where 0 , 1 ∈ T ∨ : T × T → T (called join ) The set of subsets of a set X : ∧ : T × T → T (called meet ) T : Pow( X ) ′ : T → T (called complementation ) ∧ : ∩ and the following laws hold for all x , y , z ∈ T : ∨ : ∪ commutative: x ∨ y = y ∨ x ′ : c x ∧ y = y ∧ x 0 : ∅ associative: ( x ∨ y ) ∨ z = x ∨ ( y ∨ z ) 1 : X ( x ∧ y ) ∧ z = x ∧ ( y ∧ z ) Laws of Boolean algebra follow from Laws of Set Operations. distributive: x ∨ ( y ∧ z ) = ( x ∨ y ) ∧ ( x ∨ z ) x ∧ ( y ∨ z ) = ( x ∧ y ) ∨ ( x ∧ z ) identity: x ∨ 0 = x , x ∧ 1 = x complementation: x ∨ x ′ = 1 , x ∧ x ′ = 0 17 18 Examples of Boolean Algebras Examples of Boolean Algebras Example Example The two element Boolean Algebra : Cartesian products of B , that is n -tuples of 0’s and 1’s with Boolean operations, e.g. B 4 : B = ( { true , false } , && , � , ! , false , true ) where ! , && , � are defined as: (1 , 0 , 0 , 1) ∨ (1 , 1 , 0 , 0) = (1 , 1 , 0 , 1) join: ! true = false ; ! false = true , meet: (1 , 0 , 0 , 1) ∧ (1 , 1 , 0 , 0) = (1 , 0 , 0 , 0) true && true = true ; ... (1 , 0 , 0 , 1) ′ = (0 , 1 , 1 , 0) complement: true � true = true ; ... 0: (0 , 0 , 0 , 0) NB 1: (1 , 1 , 1 , 1) . We will often use B for the two element set { true , false } . For simplicity this may also be abbreviated as { T , F } or { 1 , 0 } . 19 20
Examples of Boolean Algebras Examples of Boolean Algebras Example Example If ( T , ∨ , ∧ , ′ , 0 , 1) is a Boolean algebra, then the dual algebra Functions from any set S to B ; their set is denoted Map( S , B ) ( T , ∧ , ∨ , ′ , 1 , 0) is also a Boolean Algebra. For example: If f , g : S − → B then T : Pow( X ) ( f ∨ g ) : S − → B is defined by s �→ f ( s ) � g ( s ) ∧ : ∪ ( f ∧ g ) : S − → B is defined by s �→ f ( s ) && g ( s ) ∨ : ∩ f ′ : S − → B is defined by s �→ ! f ( s ) ′ : c 0 : S − → B is the function f ( s ) = false 0 : X 1 : S − → B is the function f ( s ) = true 1 : ∅ 21 22 Derived laws Every finite Boolean algebra satisfies: | T | = 2 k for some k . All algebras with the same number of elements are isomorphic , i.e. “structurally similar”, written ≃ . Therefore, studying one such algebra describes properties of all. The following are all derivable from the Boolean Algebra laws. The algebras mentioned above are all of this form Idempotence x ∧ x = x n -tuples ≃ B n x ∨ x = x ( x ′ ) ′ = x Pow( S ) ≃ B | S | Double complementation Annihilation x ∧ 0 = 0 Map( S , B ) ≃ B | S | x ∨ 1 = 1 ( x ∧ y ) ′ = x ′ ∨ y ′ de Morgan’s Laws NB ( x ∨ y ) ′ = x ′ ∧ y ′ Boolean algebra as the calculus of two values is fundamental to computer circuits and computer programming. Example: Encoding subsets as bit vectors. 23 24
Duality Duality formally If E is an expression made up with ∧ , ∨ , ′ , 0 , 1 and variables; then A Boolean Algebra expression is defined as follows: dual( E ) is the expression obtained by replacing ∧ with ∨ and 0, 1 are expressions vice-versa; and 0 with 1 and vice-versa. A variable, x , y , . . . , is an expression. Theorem (Principle of Duality) If E is an expression then E ′ is an expression. If you can show E 1 = E 2 holds in all Boolean Algebras a , then If E 1 and E 2 are expressions, then ( E 1 ∧ E 2 ) and ( E 1 ∨ E 2 ) are dual ( E 1 ) = dual ( E 2 ) holds in all Boolean Algebras. expressions. a by using the Boolean Algebra Laws 25 26 Duality formally Duality example If Exp is the set of expressions, we define dual : Exp → Exp as follows: dual(0) = 1, dual(1) = 0 dual(( x ∨ ( x ∧ y ))) = (dual( x ) ∧ dual(( x ∧ y ))) dual( x ) = x for all variables x = ( x ∧ dual(( x ∧ y ))) dual( E ′ ) = dual( E ) ′ for all expressions E = ( x ∧ (dual( x ) ∨ dual( y ))) = ( x ∧ ( x ∨ y )) dual(( E 1 ∧ E 2 )) = (dual( E 1 ) ∨ dual( E 2 )) for all expressions E 1 and E 2 dual(( E 1 ∨ E 2 )) = (dual( E 1 ) ∧ dual( E 2 )) for all expressions E 1 and E 2 27 28
Duality example Duality example dual(( x ∨ ( x ∧ y ))) = (dual( x ) ∧ dual(( x ∧ y ))) dual(( x ∨ ( x ∧ y ))) = (dual( x ) ∧ dual(( x ∧ y ))) = ( x ∧ dual(( x ∧ y ))) = ( x ∧ dual(( x ∧ y ))) = ( x ∧ (dual( x ) ∨ dual( y ))) = ( x ∧ (dual( x ) ∨ dual( y ))) = ( x ∧ ( x ∨ y )) = ( x ∧ ( x ∨ y )) 29 30 Duality example Summary of topics Well-formed formulas Boolean Algebras dual(( x ∨ ( x ∧ y ))) = (dual( x ) ∧ dual(( x ∧ y ))) = ( x ∧ dual(( x ∧ y ))) Valuations = ( x ∧ (dual( x ) ∨ dual( y ))) CNF/DNF = ( x ∧ ( x ∨ y )) Proof Natural deduction 31 32
Recommend
More recommend