Propositional Calculus: Boolean Functions and Expressions

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
CSE 311: Foundations of Computing Fall 2013 Lecture 3: Logic and Boolean algebra.
Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson.
Logic Use mathematical deduction to derive new knowledge.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
From Chapter 4 Formal Specification using Z David Lightfoot
1 Inference Rules and Proofs Z: Inference Rules and Proofs.
Discrete Mathematics Math 6A Instructor: M. Welling.
Let remember from the previous lesson what is Knowledge representation
Propositional Calculus Math Foundations of Computer Science.
Propositional Equivalence Goal: Show how propositional equivalences are established & introduce the most important such equivalences.
Propositional Calculus Math Foundations of Computer Science.
Propositional Calculus CS 680: Formal Methods in Verification Computer Systems Jeremy Johnson.
Adapted from Discrete Math
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Predicates and Quantifiers
Predicates & Quantifiers Goal: Introduce predicate logic, including existential & universal quantification Introduce translation between English sentences.
Discrete Mathematics Goals of a Discrete Mathematics Learn how to think mathematically 1. Mathematical Reasoning Foundation for discussions of methods.
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 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
CS1502 Formal Methods in Computer Science
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.
Logic Design CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
LOGIC Lesson 2.1. What is an on-the-spot Quiz  This quiz is defined by me.  While I’m having my lectures, you have to be alert.  Because there are.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson.
Copyright © Peter Cappello 2011 Predicates & Quantifiers.
1 Section 6.2 Propositional Calculus Propositional calculus is the language of propositions (statements that are true or false). We represent propositions.
Boolean Expression Evaluation CS 270: Math Foundations of CS Jeremy Johnson.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Logics for Data and Knowledge Representation ClassL (part 1): syntax and semantics.
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.
Discrete Structures for Computer Science Presented By: Andrew F. Conn Slides adapted from: Adam J. Lee Lecture #1: Introduction, Propositional Logic August.
1 Recursive Data Structures CS 270 Math Foundations of CS Jeremy Johnson.
Propositional Logic (a.k.a. Sentential Logic)
Chapter 7. Propositional and Predicate Logic
CS 270: Mathematical Foundations of Computer Science
Computer Science 210 Computer Organization
Propositional Equivalence
Propositional Calculus: Boolean Functions and Expressions
Lecture 1 – Formal Logic.
Predicates & Quantifiers
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Disjunctive Normal Form
Jeremy R. Johnson Wed. Sept. 29, 1999
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
Chapter 1 The Foundations: Logic and Proof, Sets, and Functions
NP-Completeness Proofs
CSE 311 Foundations of Computing I
CSE 311: Foundations of Computing
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
CS 270 Math Foundations of CS
CS 220: Discrete Structures and their Applications
Applied Discrete Mathematics Week 1: Logic
Disjunctive Normal Form
Back to “Serious” Topics…
Computer Security: Art and Science, 2nd Edition
Chapter 7. Propositional and Predicate Logic
Predicates and Quantifiers
This Lecture Substitution model
Presentation transcript:

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

Propositional Calculus September 4, 1997 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 2

Propositional Calculus Topics Motivation: Logical Reasoning Boolean Functions Syntax and Semantics of Boolean Expressions Equivalence of Boolean Functions and Boolean Expressons Evaluating Boolean Expressions Truth tables and Disjunctive Normal Form (DNF)

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

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

September 4, 1997 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 22n Boolean function of n variables. s x0 x1 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 f x0 x1 s Multiplexor function 6 6

Boolean Expressions BExpr := Constant: T|F Variable Negation:  BExpr September 4, 1997 Boolean Expressions BExpr := Constant: T|F Variable Negation:  BExpr And: BExpr  BExpr Or: BExpr  BExpr 7 7

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

Example Derivation       p  p  p    T BExpr T T   BExpr Variable p  T  p  (T   q) q

Parse Tree A valid derivation can be represented by a tree whose nodes are labeled by the subexpression that is generated and whose children correspond to the rhs of the rule p  (T   q) p (T   q) T  q q

Predicate for Boolean Expressions September 4, 1997 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 else return false 12 12

Semantics of Boolean Expressions September 4, 1997 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 13 13

Evaluating Expression Trees Assume p = T and q = F  p=T  T  q=F  p=T  T  p=T 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 not booleanEval(firstOperand(expr)) return false else return booleanEval(secondOperand(expr))

Disjunctive Normal Form September 4, 1997 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 x0 x1 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 (s  x0  x1 )  (s  x0  x1 )  (s  x0  x1 )  (s  x0  x1 ) 17 17

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 x y x  y 0 0 1 0 1 0 1 0 0 1 1 1 x y x  y 0 0 1 0 1 1 1 0 0 1 1 1 x y x  y 0 0 0 0 1 1 1 0 1 1 1 0 implication Equivalence (iff) xor 18