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

Similar documents
Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus. Math Foundations of Computer Science

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus. Math Foundations of Computer Science

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

Computer Organization and Levels of Abstraction

Computer Organization and Levels of Abstraction

CS February 17

Logic Design: Part 2

COMP combinational logic 1 Jan. 18, 2016

SAT Solver. CS 680 Formal Methods Jeremy Johnson

Introduction to Boolean logic and Logical Gates

LECTURE 4. Logic Design

TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009

CSC Discrete Math I, Spring Sets

Circuit analysis summary

Review. EECS Components and Design Techniques for Digital Systems. Lec 05 Boolean Logic 9/4-04. Seq. Circuit Behavior. Outline.

Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012

Summary of Course Coverage

Experiment 4 Boolean Functions Implementation

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

IT 201 Digital System Design Module II Notes

Combinational Logic & Circuits

Lecture (04) Boolean Algebra and Logic Gates

Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee

7/25/2016. Example: Addition of Unsigned Bit Patterns. ECE 120: Introduction to Computing. Adding Two Non-Negative Patterns Can Overflow

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

Combinational Circuits Digital Logic (Materials taken primarily from:

Chapter 2. Boolean Expressions:

01 Introduction to Digital Logic. ENGR 3410 Computer Architecture Mark L. Chang Fall 2006

Menu. Algebraic Simplification - Boolean Algebra EEL3701 EEL3701. MSOP, MPOS, Simplification

01 Introduction to Digital Logic. ENGR 3410 Computer Architecture Mark L. Chang Fall 2008

Boolean Logic CS.352.F12

Introduction to Boolean Algebra

Assignment (3-6) Boolean Algebra and Logic Simplification - General Questions

BOOLEAN ALGEBRA AND CIRCUITS

Programming Languages Third Edition

Introduction to Computer Architecture

Introduction to Boolean Algebra

Lecture 5. Logic I. Statement Logic

LECTURE 2 An Introduction to Boolean Algebra

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

Systems Architecture I

Propositional Calculus

Lecture #21 March 31, 2004 Introduction to Gates and Circuits

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

2.1 Sets 2.2 Set Operations

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

VLSI System Design Part II : Logic Synthesis (1) Oct Feb.2007

Logic and Computation

Boolean Algebra and Logic Gates

Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

Variable, Complement, and Literal are terms used in Boolean Algebra.

Simplification of Boolean Functions

Standard Boolean Forms

BOOLEAN ALGEBRA. Logic circuit: 1. From logic circuit to Boolean expression. Derive the Boolean expression for the following circuits.

Objectives: 1- Bolean Algebra. Eng. Ayman Metwali

SYNERGY INSTITUTE OF ENGINEERING & TECHNOLOGY,DHENKANAL LECTURE NOTES ON DIGITAL ELECTRONICS CIRCUIT(SUBJECT CODE:PCEC4202)

At this point in our study of digital circuits, we have two methods for representing combinational logic: schematics and truth tables.

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

Boolean Algebra A B A AND B = A*B A B A OR B = A+B

Boolean algebra. June 17, Howard Huang 1

4. Write a sum-of-products representation of the following circuit. Y = (A + B + C) (A + B + C)

Lecture 3: Binary Subtraction, Switching Algebra, Gates, and Algebraic Expressions

2.1 Binary Logic and Gates

Unit-IV Boolean Algebra

QUESTION BANK FOR TEST

DKT 122/3 DIGITAL SYSTEM 1

ENGIN 112 Intro to Electrical and Computer Engineering

Math 55 - Spring 04 - Lecture notes # 1 - Jan 20 (Tuesday)

EE292: Fundamentals of ECE

Information Science 1

ENGIN 112. Intro to Electrical and Computer Engineering

Computer Engineering Chapter 3 Boolean Algebra

Combinational Devices and Boolean Algebra

Combinational Logic Circuits

3. According to universal addressing, what is the address of vertex d? 4. According to universal addressing, what is the address of vertex f?

A Survey of Mathematics with Applications 8 th Edition, 2009

Standard Forms of Expression. Minterms and Maxterms

Section 001. Read this before starting!

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Introductory logic and sets for Computer scientists

Logic Gates and Boolean Algebra ENT263

24 Nov Boolean Operations. Boolean Algebra. Boolean Functions and Expressions. Boolean Functions and Expressions

UNIT 2 BOOLEAN ALGEBRA

CS40-S13: Functional Completeness

CS470: Computer Architecture. AMD Quad Core

CS8803: Advanced Digital Design for Embedded Hardware

LOGIC AND DISCRETE MATHEMATICS

Boolean Algebra. P1. The OR operation is closed for all x, y B x + y B

1. Fill in the entries in the truth table below to specify the logic function described by the expression, AB AC A B C Z

GC03 Boolean Algebra

Logic and its Applications

1. Mark the correct statement(s)

Combinational Circuits

Proving Properties of Recursive Functions and Data Structures. CS 270 Math Foundations of CS Jeremy Johnson

Transcription:

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

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. 2

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

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) ((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 5

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. 6

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. 7

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. x 0 x 1 f s x 0 x 1 f 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 A Boolean function can be described using a truth table. There are 2 2n Boolean function of n variables. s Multiplexor function 1 1 0 0 1 1 1 1 8

Boolean Expressions BExpr := Constant: T F Variable Negation: BExpr And: BExpr BExpr Or: BExpr BExpr 9

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 BExpr p p p BExpr BExpr Constant BExpr T BExpr

Example Derivation p p p T BExpr T BExpr T Constant p T p (T q) q

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 13

Semantics of Boolean Expressions An expression built up from variables, and, or, and not. x y x y 0 0 0 0 1 0 1 0 0 1 1 1 x y x y 0 0 0 0 1 1 1 0 1 1 1 1 x x 0 1 1 0 and or not 14

Evaluating Expression Trees Assume p = T and q = F T p=t p=t p=t T T T T q=f

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))

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 ) ( s x 0 x 1 ) (s x 0 x 1 ) (s x 0 x 1 ) s x 0 x 1 f 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 18

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.

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 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 20

Properties of Boolean Algebra Boolean expressions can be simplified using rules of Boolean algebra Identity law: A + 0 = A and A 1 = A. Zero and One laws: A + 1 = 1 and A 0 = 0 Inverse laws: Idempotent laws: A + A = A = A A Commutative laws: A + B = B + A and A B = B A. Associative laws: A + (B + C) = (A + B) + C and A (B C) = (A B) C. Distributive laws: A (B + C) = (A B) + (A C) and A + (B C) = (A + B) (A + C) Double Negation: AA = AA DeMorgan s laws:

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. 22

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

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 0 0 1 0 1 1 1 0 0 1 1 1 implication x y x y 0 0 1 0 1 0 1 0 0 1 1 1 equivalence x y x y 0 0 0 0 1 1 1 0 1 1 1 0 xor 24

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 0 0 1 1 0 1 1 1 1 0 0 0 1 1 1 1 25

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. 26

Derive the tautology x y x y Solution x y x y 0 0 1 0 1 1 1 0 0 1 1 1 xx yy ( xx yy) xx yy xx yy ( xx yy) ( xx yy) xx yy xx yy xx ( yy yy) xx xx yy ( xx TT) (TT yy) xx yy 27

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. 28