Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.

Slides:



Advertisements
Similar presentations
CSE 311: Foundations of Computing Fall 2013 Lecture 3: Logic and Boolean algebra.
Advertisements

Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson.
Logic Gate Level Part 2. Constructing Boolean expression from truth table First method: write nonparenthesized OR of ANDs Each AND is a 1 in the result.
Lecture 2 Dr Richard Reilly Dept. of Electronic & Electrical Engineering Room 153, Engineering Building To insert your company logo on this slide From.
Chapter 2 – Combinational Logic Circuits Part 1 – Gate Circuits and Boolean Equations Logic and Computer Design Fundamentals.
1 Section 10.1 Boolean Functions. 2 Computers & Boolean Algebra Circuits in computers have inputs whose values are either 0 or 1 Mathematician George.
From Chapter 4 Formal Specification using Z David Lightfoot
Logic Gate Level Combinational Circuits, Part 1. Circuits Circuit: collection of devices physically connected by wires to form a network Net can be: –
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
Lecture 3. Boolean Algebra, Logic Gates
Propositional Calculus Math Foundations of Computer Science.
Propositional Equivalence Goal: Show how propositional equivalences are established & introduce the most important such equivalences.
Copyright © Cengage Learning. All rights reserved.
Propositional Calculus Math Foundations of Computer Science.
Propositional Calculus CS 680: Formal Methods in Verification Computer Systems Jeremy Johnson.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Intro to Discrete Structures
Discrete Mathematics and Its Applications
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
1 Fundamentals of Computer Science Propositional Logic (Boolean Algebra)
Boolean Algebra – the ‘Lingua Franca’ of the Digital World The goal of developing an automata is based on the following (loosely described) ‘ideal’: if.
Lecture 7 Topics –Boolean Algebra 1. Logic and Bits Operation Computers represent information by bit A bit has two possible values, namely zero and one.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Apr. 3, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 3: Review of Digital Circuits and Logic Design Jeremy R. Johnson Mon. Apr.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
Lecture 22: 11/19/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Logic Design CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
Section 1.2: Propositional Equivalences In the process of reasoning, we often replace a known statement with an equivalent statement that more closely.
Extra slides for Chapter 3: Propositional Calculus & Normal Forms Based on Prof. Lila Kari’s slides For CS2209A, 2009 By Dr. Charles Ling;
Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson.
Section 3.4 Boolean Algebra. A link between:  Section 1.3: Logic Systems  Section 3.3: Set Systems Application:  Section 3.5: Logic Circuits in Computer.
Logic UNIT 1.
Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements.
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 9 Boolean Algebras and Combinatorial Circuits.
Boolean Algebra Computer Architecture. Digital Representation Digital is an abstraction of analog voltage –Voltage is a continuous, physical unit Typically.
Apr. 3, 2000Systems Architecture I1 Introduction to VHDL (CS 570) Jeremy R. Johnson Wed. Nov. 8, 2000.
May 9, 2001Systems Architecture I1 Systems Architecture I (CS ) Lab 5: Introduction to VHDL Jeremy R. Johnson May 9, 2001.
1 Section 6.2 Propositional Calculus Propositional calculus is the language of propositions (statements that are true or false). We represent propositions.
BOOLEAN ALGEBRA LOGIC GATES. Introduction British mathematician George Boole( ) was successful in finding the link between logic and mathematics.
Boolean Expression Evaluation CS 270: Math Foundations of CS Jeremy Johnson.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
CHAPTER 2 Boolean algebra and Logic gates
1 Proving Properties of Recursive Functions and Data Structures CS 270 Math Foundations of CS Jeremy Johnson.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Logic.
Boolean Algebra & Logic Gates
Digital Logic.
CS 270: Mathematical Foundations of Computer Science
Chapter 11 (Part 1): Boolean Algebra
Propositional Equivalence
Unit 2 Boolean Algebra.
Propositional Calculus: Boolean Functions and Expressions
Lecture 1 – Formal Logic.
CHAPTER 2 Boolean Algebra
Boolean Algebra A Boolean algebra is a set B of values together with:
Disjunctive Normal Form
Jeremy R. Johnson Wed. Sept. 29, 1999
Propositional Calculus: Boolean Functions and Expressions
Proving Properties of Recursive Functions and Data Structures
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Propositional Calculus: Boolean Algebra and Simplification
Elementary Metamathematics
Simplification of Boolean Expressions
Foundations of Discrete Mathematics
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Laws & Rules of Boolean Algebra
Presentation transcript:

Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

2 Propositional Calculus  Objective: To provide students with the concepts and techniques from propositional calculus so that they can use it to codify logical statements and to reason about these statements. To illustrate how a computer can be used to carry out formal proofs and to provide a framework for logical deduction.

Propositional Calculus  Topics  Motivation  Boolean functions and expressions  Rules of Boolean Algebra  Tautologies and automatic verification of tautologies

Word Problem  Tom likes Jane if and only if Jane likes Tom. Jane likes Bill. Therefore, Tom does not like Jane.  Let p denote “Tom likes Jane”  Let q denote “Jane likes Tom”  Let r denote “Jane likes Bill”  ((p  q)  r)   p encodes the above claim  The claim is not valid as the assignment p = true, q = true, and r = true evaluates to false

5 Programming Example  Boolean expressions arise in conditional statements. It is possible to abstract the relations with boolean variables (propositions that are either true or false). Using this abstraction one can reason and simplify conditional statements.  if ((a = b) && (c == d)) then { … } else { … }  Let p denote the relation (a<b) and q denote the relation (c == d). The above expression is then equal to p || !p && q

6 Programming Example (cont)  The previous expression is equivalent (two expressions are equivalent if they are true for the same values of the variables occurring in the expressions) to a simpler expression  (p || !p && q)  p || q  We can see this since if p is true both expressions are true, and if p is false, then !p is true and (!p && q) is true exactly when q is true.

7 Limitations of Propositional Calculus  Propositions hide the information in the predicates they abstract.  Sometimes properties of the hidden information is required to make further deductions.  E.G. for integers a,b, and c, (a < b) && (b < c) implies that a < c; however, this can not be deduced without using the order properties of the integers.  The predicate calculus allows the use of predicates to encode this additional information.  E.G. we can introduce a parameterized predicate lt(a,b) to encode the predicate a < b. Properties such as lt(a,b) && lt(b,c)  lt(a,c) can be asserted. This type of notation and deduction is called predicate calculus and will be discussed later.

8 Boolean Functions  A Boolean variable has two possible values (true/false) (1/0).  A Boolean function has a number of Boolean input variables and has a Boolean valued output.  A Boolean function can be described using a truth table.  There are 2 2 n Boolean function of n variables. s x 0 x 1 f f x0x0 x1x1 s Multiplexor function

9 Boolean Expressions  BExpr :=  Constant: T|F  Variable  Negation:  BExpr  And: BExpr  BExpr  Or: BExpr  BExpr

Expression Trees Boolean expressions can be represented by a binary tree Internal nodes are operators Leaf nodes are operands Consider p  (T   q):  p  T  q

Example Derivation  BExpr BExpr  BExpr   Variable BExpr   p   p    p  ConstantBExpr   p  T

Example Derivation   p  TBExpr   p  T  p  T  q    p  T  Constant  p  (T   q)

13 Predicate for Boolean Expressions define isBooleanExpr(expr) return true if the input expr is a Boolean expression if constant return true if variable return true if isNegation(expr) and isBooleanExpr(operand(expr)) return true if isDisjunction(expr) and isBooleanExpr(firstOperand(expr)) and isBooleanExpr(secondOperand(expr)) then return true if isConjunction(expr) and isBooleanExpr(firstOperand(expr)) and isBooleanExpr(secondOperand(expr)) then return true else return false

14 Semantics of Boolean Expressions  An expression built up from variables, and, or, and not. x y x  y x y x  y x  x and or not

Evaluating Expression Trees Assume p = T and q = F  p=T  T  q=F  p=T  TT  T T

Evaluation define booleanEval(expr, env) Input: expr is a Boolean Expression, env is an environment of variable assignments to T or F. Assume all variables in expr are defined in env Output: true if expr evaluates to true and false if expr evaluates to false if isConstant(expr) return expr if isVariable(expr) return lookup(expr,env) if isNegation(expr) return not booleanEval(operand(expr)) if isDisjunction(expr) return booleanEval(firstOperand(expr)) or booleanEval(secondOperand(expr)) if isConjunction(expr) return booleanEval(firstOperand(expr)) and booleanEval(secondOperand(expr))

Short Circuit Evaluation define booleanEval(expr, env) Input: expr is a Boolean Expression, env is an environment of variable assignments to T or F. Assume all variables in expr are defined in env Output: true if expr evaluates to true and false if expr evaluates to false if isConstant(expr) return expr if isVariable(expr) return lookup(expr,env) if isNegation(expr) return not booleanEval(operand(expr)) if isDisjunction(expr) if booleanEval(firstOperand(expr)) return true else return booleanEval(secondOperand(expr)) if isDisjunction(expr) if not booleanEval(firstOperand(expr)) return false else return booleanEval(secondOperand(expr))

18 Disjunctive Normal Form  A Boolean expression is a Boolean function  Any Boolean function can be written as a Boolean expression  Write a Boolean expression that evaluates to true for each row in the truth table that is true and false for other rows.  The Boolean expression for a given row is the conjunction of the variables that are true and the negation of variables that are false.  Take the disjunction of all such rows.  E.G. (multiplexor function) s x 0 x 1 f (  s  x 0   x 1 )  (  s  x 0  x 1 )  (s   x 0  x 1 )  (s  x 0  x 1 )

Boolean Algebra  The Boolean operators  and  are analogous to addition and multiplication with true and false playing the roles of 1 and 0. Complement is used for negation.  This provides a compact notation and suggests appropriate algebraic simplification  Similar properties hold such as the associative, commutative, and distributive identities.

20 Sums of Products  Disjunctive normal form, using the notation of Boolean Algebra, corresponds to a sum of products  E.G. (multiplexor function) s x 0 x 1 f

Properties of Boolean Algebra

22 Simplification of Boolean Expressions  Simplifying multiplexor expression using Boolean algebra  Equational reasoning: replace subexpressions by equivalent expressions  Verify that the boolean function corresponding to this expression as the same truth table as the original function.

Nand is functionally complete  All boolean functions can be implemented using nand gates (and, or and not can be implemented using nand)  not:  and:  or: x y x | y

24 Additional Notation  Several additional Boolean functions of two variables have special meaning and are given special notation. By our previous results we know that all boolean functions can be expressed with not, and, and or; so the additional notation is simply a convenience. x y x  y implication x y x  y equivalence x y x  y xor

25 Tautologies  A tautology is a boolean expression that is always true, independent of the values of the variables occurring in the expression. The properties of Boolean Algebra are examples of tautologies.  Tautologies can be verified using truth tables. The truth table below shows that x  y   x  y x y x  y  x  y

26 Exercise  Derive the tautology x  y   x  y from the sum of products expression obtained from the truth table for x  y. You will need to use properties of Boolean algebra to simplify the sum of products expression to obtain the desired equivalence.

27 Solution x y x  y

28 Tautology Checker  A program can be written to check to see if a Boolean expression is a tautology.  Simply generate all possible truth assignments for the variables occurring in the expression and evaluate the expression with its variables set to each of these assignments. If the evaluated expressions are always true, then the given Boolean expression is a tautology.  A similar program can be written to check if any two Boolean expressions E1 and E2 are equivalent, i.e. if E1  E2. Such a program has been provided.