Propositional Logic.

Slides:



Advertisements
Similar presentations
TRUTH TABLES The general truth tables for each of the connectives tell you the value of any possible statement for each of the connectives. Negation.
Advertisements

Logic & Critical Reasoning
Logic Concepts Lecture Module 11.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Discussion #18 1/13 Discussion #18 Resolution with Propositional Calculus; Prenex Normal Form.
CS128 – Discrete Mathematics for Computer Science
Discussion #16 1/12 Discussion #16 Validity & Equivalences.
Logic Chapter 2. Proposition "Proposition" can be defined as a declarative statement having a specific truth-value, true or false. Examples: 2 is a odd.
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
Today’s Topics n Review Logical Implication & Truth Table Tests for Validity n Truth Value Analysis n Short Form Validity Tests n Consistency and validity.
1 Section 1.2 Propositional Equivalences. 2 Equivalent Propositions Have the same truth table Can be used interchangeably For example, exclusive or and.
Discussion #10 1/16 Discussion #10 Logical Equivalences.
Discussion #9 1/9 Discussion #9 Tautologies and Contradictions.
Logic Truth Tables, Propositions, Implications. Statements Logic is the tool for reasoning about the truth or falsity of statements. –Propositional logic.
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
Intro to Discrete Structures
Logical Equivalence & Predicate Logic
The Foundations: Logic and Proofs
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
1 Logic Logic is a discipline that studies the principles and methods used in correct reasoning It includes: A formal language for expressing statements.
Discussion #141/20 Discussion #14 Predicate Calculus.
BY: MISS FARAH ADIBAH ADNAN IMK. CHAPTER OUTLINE: PART III 1.3 ELEMENTARY LOGIC INTRODUCTION PROPOSITION COMPOUND STATEMENTS LOGICAL.
1 Propositional Logic Proposition 2 Propositions can be divided into simple propositions and compound propositions. A simple (or basic) proposition is.
Review I Rosen , 3.1 Know your definitions!
Chap. 2 Fundamentals of Logic. Proposition Proposition (or statement): an declarative sentence that is either true or false, but not both. e.g. –Margret.
Chapter 5 – Logic CSNB 143 Discrete Mathematical Structures.
2.3Logical Implication: Rules of Inference From the notion of a valid argument, we begin a formal study of what we shall mean by an argument and when such.
CSNB143 – Discrete Structure LOGIC. Learning Outcomes Student should be able to know what is it means by statement. Students should be able to identify.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, November 2015Introduction & Propositional Logic 1.
Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems or solving problems, creativity and insight.
Chapter 3: Introduction to Logic. Logic Main goal: use logic to analyze arguments (claims) to see if they are valid or invalid. This is useful for math.
Chapter 8 – Symbolic Logic Professor D’Ascoli. Symbolic Logic Because the appraisal of arguments is made difficult by the peculiarities of natural language,
Propositional Logic. Propositions Any statement that is either True (T) or False (F) is a proposition Propositional variables: a variable that can assume.
1 Introduction to Abstract Mathematics Expressions (Propositional formulas or forms) Instructor: Hayk Melikya
Propositional Logic ITCS 2175 (Rosen Section 1.1, 1.2)
Extra slides for Chapter 3: Propositional Calculus & Normal Forms Based on Prof. Lila Kari’s slides For CS2209A, 2009 By Dr. Charles Ling;
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
The Foundations: Logic and Proof, Sets, and Foundations PROPOSITIONS A proposition is a declarative sentence that is either True or False, but not the.
CSNB143 – Discrete Structure Topic 4 – Logic. Learning Outcomes Students should be able to define statement. Students should be able to identify connectives.
CSci 2011 Recap ^Propositional operation summary not andorconditionalBi-conditional pq ppqqpqpqpqpqpqpqpqpq TTFFTTTT TFFTFTFF FTTFFTTF FFTTFFTT.
Predicate Logic One step stronger than propositional logic Copyright © Curt Hill.
Chapter 2 Fundamentals of Logic 1. What is a valid argument or proof?
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
1 Section 6.2 Propositional Calculus Propositional calculus is the language of propositions (statements that are true or false). We represent propositions.
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
TRUTH TABLES Edited from the original by: Mimi Opkins CECS 100 Fall 2011 Thanks for the ppt.
Spring 2003CMSC Discrete Structures1 Let’s get started with... Logic !
3/6/20161 Let’s get started with... Logic !. 3/6/20162 Logic Crucial for mathematical reasoningCrucial for mathematical reasoning Used for designing electronic.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU1 Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems.
Chapter 1. Chapter Summary  Propositional Logic  The Language of Propositions (1.1)  Logical Equivalences (1.3)  Predicate Logic  The Language of.
Chapter 1 Logic and proofs
2. The Logic of Compound Statements Summary
CSNB 143 Discrete Mathematical Structures
(CSC 102) Discrete Structures Lecture 2.
Predicate Calculus Discussion #14 Chapter 2, Section 1 1/20.
Discussion #14 Predicate Calculus
Discussion #10 Logical Equivalences
CSCI 3310 Mathematical Foundation of Computer Science
CS201: Data Structures and Discrete Mathematics I
Information Technology Department
Predicate Calculus Discussion #14 Chapter 2, Section 1.
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
CS201: Data Structures and Discrete Mathematics I
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Predicate Calculus. Predicate Calculus Topics Predicates Variables and instantiation Quantifiers Logical expressions Bound and free variables.
Presentation transcript:

Propositional Logic

Propositions Any statement that is either True (T) or False (F) is a proposition Propositional variables: a variable that can assume a value of T or F Propositional constants: T or F Atomic proposition: A proposition consisting of only a single propositional variable or constant Logical connectives: logical operators

Truth Table Gives the values of a proposition under all possible assignments of its variables Used to define connectives P P T F

Connectives F T P  Q F T P  Q T F P  Q T F P  Q P Q T T T F F T F Conjunction “and” F T P  Q Disjunction “or” T F P  Q Conditional “implies” T F P  Q Biconditional “equivalent” P Q T T T F F T F F P implies Q if P then Q Q if P (e.g., Q :- P) P only if Q P is sufficient for Q Q is necessary for P P is equivalent to Q P if and only if Q P is necessary and sufficient for Q P iff Q

Compound Propositions Also called logical expressions, formulas, and well- formed formulas (wffs) Well-formed formulas are defined inductively: Basis: T and F are wffs (these are the constants) P, Q, … are wffs (these are the variables) Induction: if A and B are wffs, then so are: (A) (A  B), (A  B), (A  B), (A  B)

Parentheses Well-formed formulas are fully parenthesized: ((((P  Q))  ((P)  Q))  R) We can remove some parentheses: Outside parentheses can be removed Use precedence:      Use associativity  always left associative

Evaluating Logical Expressions P  Q F T ((P)  Q) Q P T F F T

Evaluating Logical Expressions (P  Q)  P  Q  R T F 3 F T 1 T F 5 T F 2 F T 4 T F 6 F T  R  Q P )  PQ ( R Q P

Evaluating with Truth Tables In general… To evaluate expressions using truth tables with k variables and n operations is O(2kn). If we have one operator (n = 1) and if we can substitute in T or F and evaluate in 1 sec, then k time 30 20 minutes 40 14 days 50 40 years 60 40,000 years! Not practical to use truth tables for “large” k!

Logical Expressions Tautology – a logical expression that is true for all variable assignments The symbol |= (read “entails”) denotes that what follows holds or is true, so long as what precedes it is true Since tautologies are always true, we sometimes write “|= B” to denote that B is a tautology independent of what precedes it Contradiction – a logical expression that is false for all variable assignments Contingent – a logical expression that is neither a tautology nor a contradiction

Sample Tautologies F T (P  P) P  P P P T F T F F T (P  Q)  Q

Sound Reasoning A logical argument has the form: A1  A2  …  An  B and is sound if when Ai = T for all i, B = T (i.e., if the premises are all true, then the conclusion is also true) This happens when A1  A2  …  An  B is a tautology

Practice Exercises PE1 Consider the statement: "If Christophe is the best teacher on campus, then you are taking CS 236." Is the statement true? Why or why not? ------------------ PE2 Consider the statement: "If you have graduated from BYU, then Christophe is the best teacher on campus." Is the statement true? Why or why not? PE3 There was a farmer had a goat. That goat liked corn. The farmer had a pile of corn in a barn, but because he reserved it for cattle, he would keep the door shut when the goat was around. Furthermore, the neighborhood was a bit dodgy with a wolf lurking about that would gladly sink his teeth into a nice fat goat (although he did not care much about corn). Our farmer wished to protect his goat from the wolf and his corn from the goat. Assuming that each object (corn, goat, wolf) has only two states (e.g., open/closed, around/not around), write a logic statement, or proposition, for danger situations, such as the goat being around and the barn's door being open. You may wish to start with a truth table.

Logical Arguments Consider the following statements if you study then you succeed you study you succeed These three statements create a logical argument Lines 1 and 2 are the premises Line 3 is the conclusion This logical argument is sound… 1. If P then Q 2. P ------------------ 3. Q ( ( P  Q )  P )  Q

Modus Ponens Hence, modus ponens is sound! A B A  B T ? A  B A B F T

Important! We are dealing with the validity of an argument, NOT with the validity of the result! In logic, it doesn’t matter if a logical statement makes sense or not What does matter is that: IF the premises are correct THEN so is the conclusion 1. If P then Q 2. P ------------------ 3. Q

Valid Logical Arguments P: I study hard Q: I do well on my exam P: cows give milk Q: doors open P: I obey Q: I am happy P: I sail past the end of the world Q: I will fall off Makes sense Doesn’t make sense Makes sense Doesn’t make sense

Disjunctive Syllogism A  B A B Disjunctive Syllogism A F T (A  B)  A  B (A  B)  A A  B B A F T T F F T T Hence, disjunctive syllogism is sound!

Logical Implication If A and B are two logical expressions and if A  B is a tautology, we say that A logically implies B, and we write A > B > is a meta-symbol to say a logical argument is sound (P  Q)  P > Q (P  Q)  P > Q If A  B is a tautology, then A > B Modus ponens Disjunctive syllogism

Logical Equivalence A  B if and only if A  B is a tautology If A and B are two logical expressions and if A and B always have the same truth value, then A and B are said to be logically equivalent, and we write A  B  is a meta-symbol to say that A  B is a tautology. F T  A A  A A Thus, A  A  A F T T Which means, you can replace A  A with A. A  B if and only if A  B is a tautology

Practice Exercises PE1 Is the following argument valid? Explain. If you eat healthy all your life, then you will live longer. You lived longer. Therefore, you ate healthy all your life. ------------------ PE2 If you completed Project 2, then you completed Project 1. You did not complete Project 1. Therefore, you did not complete Project 2.

Laws of , , and  Name Law Excluded middle law Contradiction law P  P  T P  P  F Identity laws P  F  P P  T  P Domination laws P  T  T P  F  F Idempotent laws P  P  P P  P  P Double-negation law (P)  P Note the similarity with sets:  / ∨,  / ∧, / F, E / T

Law Name Commutative laws P  Q  Q  P P  Q  Q  P Associative laws (P  Q)  R  P  (Q  R) (P  Q)  R  P  (Q  R) Distributive laws (P  Q)  (P  R)  P  (Q  R) (P  Q)  (P  R)  P  (Q  R) De Morgan’s laws (P  Q)  P  Q (P  Q)  P  Q Absorption laws P  (P  Q)  P P  (P  Q)  P

Can prove all laws by truth tables… F T Q  P  (P  Q)  Q P T F F T T T F T F T F De Morgan’s law holds!

Two Other Useful Laws Law of implication Law of contrapositive P  Q  P  Q Law of contrapositive P  Q  Q   P Note that the converse of P  Q is Q  P, and the two are NOT equivalent

Duals To create the dual of a logical expression 1) swap propositional constants T and F 2) swap connective operators  and  P  P  T Excluded Middle     P  P  F Contradiction The dual of a law is always a law! Thus, most laws come in pairs  pairs of duals

Normal Forms Normal forms are standard forms, sometimes called canonical or accepted forms A logical expression is said to be in disjunctive normal form (DNF) if it is written as a disjunction, in which all terms are conjunctions of literals Similarly, a logical expression is said to be in conjunctive normal form (CNF) if it is written as a conjunction of disjunctions of literals

DNF and CNF Disjunctive Normal Form (DNF) ( ..  ..  .. )  ( ..  ..  .. )  …  ( ..  .. ) Term Literal, i.e. P or P Examples: (P  Q)  (P  Q) P  (Q  R) Conjunctive Normal Form (CNF) ( ..  ..  .. )  ( ..  ..  .. )  …  ( ..  .. ) Examples: (P  Q)  (P  Q) P  (Q  R)

Converting Expressions to DNF or CNF The following procedure converts an expression to DNF or CNF: Remove all  and  Move  inside (use De Morgan’s law) Use distributive laws to get proper form Simplify as you go (e.g., double-neg., idemp., comm., assoc.)

CNF Conversion Example ( ..  ..  .. )  ( ..  ..  .. )  …  ( ..  .. ) ((P  Q)  R  (P  Q))  ((P  Q)  R  (P  Q)) impl.  (P  Q)  R  (P  Q) deM.  (P  Q)  R  (P  Q) deM.  (P  Q)  R  (P  Q) double neg.  (P  Q)  (P  Q)  R comm.  (P  Q)  R idemp.  (P  R)  (Q  R) distr. (DNF) (CNF)

DNF Expression Generation The only definition of  is the truth table F T  R Q P F T (P  Q  R) minterms (P  Q  R) (P  Q  R)  (P  Q  R)  (P  Q  R)  (P  Q  R)

CNF Expression Generation } Find . Find the DNF of . Then, use De Morgan’s law to get the CNF of  (i.e. ()  ) Form a conjunction of max terms  F T  Q P max terms T F (P  Q) (P  Q) (P  Q) (P  Q)   (P  Q)  (P  Q) DNF of    f  ((P  Q)  (P  Q))  (P  Q)  (P  Q) DeM.  (P  Q)  (P  Q) DeM., double neg.

Predicate Calculus

Calculus What does calculus mean? Lots of calculus studies … Comes from the word “stone” Implies a process of calculating Lots of calculus studies … Differential calculus Integral calculus Relational calculus Propositional calculus Predicate calculus Predicate calculus is a generalization of propositional calculus Kidney stone

Predicate Calculus Also called Predicate or First-Order Logic Contains all of the components of propositional calculus… Together with: Predicates A universe of discourse (UofD) Terms Quantifiers

Predicates A predicate is a statement that is either true or false and has zero or more arguments A predicate has a name followed by a list of arguments enclosed in parentheses and is called an atomic formula Examples: Jane is the mother of Mary isMother(Jane, Mary) M(j, m) Atomic formulas can be combined by logical connectives Example: isMother(Jane,Mary)  isMother(Mary,Jane) If all arguments of a predicate are individual constants, the resulting atomic formula must either be true or false Examples: Jane is the mother of Mary = T isMother(Jane, Mary) = T isMother(Mary, Jane) = F The number and order of predicate arguments is significant The number of elements in the predicate list is called the arity of the predicate

Predicates  Sets Every set is a predicate Given a set S, define P(s), such that P(s) is true iff sS, and false otherwise Every predicate is a set Given a predicate P(s), define S, such that sS if and only if P(s) is true

UofD, Terms, Quantifiers The Universe of Discorse (UofD) is a set of values The UofD represents all values being considered The UofD is sometimes called the domain of interest, or simply the domain Arguments in predicates can be constants (values in the UofD), variables (whose value assignments come from the UofD), or terms (expressions that evaluate to values in the UofD) Quantifiers give us a way to evaluate predicate calculus formulas with variables that range over the entire UofD

Predicate Evaluation (I) Sometimes we know the “meaning” but we don’t know which assignments hold until we are told For example: T F Sara Zed Sally Jim siblingOf UoD = {Jim, Sally, Sara, Zed} siblingOf(x,y)

Predicate Evaluation (II) Sometimes we don’t know the “meaning” but we are “given” the assignments For example: F T c b a P UoD = {a, b, c} P(x, y) Facts: P(b, c) P(c, a) P(a, c) Under a “closed world assumption,” we only need to list the facts (substitutions that evaluate to True). All others are False.

Instantiation Instantiation is the substitution of a constant for a variable (or in general, the substitution of a term, which is an expression that yields a constant) Sxt A means substitute term t for all variables x in A Sxt A is called an instantiation of A and t is said to be an instance of x Examples: Sx3 P(x, y) = P(3, y) Sx3+1 P(x, y, z, x) = P(3+1, y, z, 3+1) = P(4, y, z, 4)

Universal Quantification (I) Let A be an expression, and let x be a variable. If we want to say that P(x) is true for all substitutions of values for x in the UofD, we write xP(x). The symbol  is pronounced “for all” and is called the universal quantifier. Examples: All cats have tails, x(cat(x)  hasTail(x)). For every integer x, x+1 > x, x(>(x+1, x)).

Universal Quantification (II) x P(x) is shorthand for: x P(x) = P(a)  P(b)  P(c) with UoD = {a, b, c}. x P(x) = P(0)  P(1)  … with UoD = non-negative integers. x P(x) = T when P(x) = T for all substitutions from the UoD. (Only need one false predicate instantiation to make the formula false.) Examples: x red(x) = T for UoD = red apples x red(x) = F for UoD = apples

Existential Quantification (I) Let A be an expression, and let x be a variable. If we want to say that P(x) is true for at least one value of x, we write xP(x). The symbol  is pronounced “there exists” and is called the existential quantifier. Examples: Some people like apples, x(likesApples(x)). There is an integer larger than 10, x(>(x, 10)).

Existential Quantification (II) x is shorthand for: x P(x) = P(a)  P(b)  P(c) with UoD = {a, b, c}. x P(x) = P(1)  P(2) … with UoD = non-negative integers. x P(x) = T when P(x) = T for one or more substitutions from UoD. (Only need one true predicate instantiation to make the formula true.) Examples: x red(x) = T for UoD = all apples x red(x) = F for UoD = golden delicious apples

Expressions with Quantifiers Quantifiers associate right to left. Example with UoD = {Ann, Sue, Tim} xy loves(x, y) = (x(y(loves(x, y)))) = x(loves(x, Ann)  loves(x, Sue)  loves(x, Tim)) = (loves(Ann, Ann)  loves(Ann, Sue)  loves(Ann, Tim))  (loves(Sue, Ann)  loves(Sue, Sue)  loves(Sue, Tim))  (loves(Tim, Ann)  loves(Tim, Sue)  loves(Tim, Tim)) We say, for every x, there exists a y such that x loves y. (Everybody loves somebody.)

Examples Order matters. What about yx loves(x, y)? There exists a y such that for every x, x loves y. Somebody is loved by everybody. Not the same as everybody loves somebody. What about xy loves(x, y)? There exists an x such that for every y, x loves y. Somebody loves everybody. What about yx loves(x, y)? For every y there exists an x such that x loves y. Everybody is loved by somebody. Order matters.

Practice Exercises PE1 Translate the following statement into predicate logic (don't omit the quantifiers): "If a person is female and is a parent, then that person is someone's mother". (choose appropriate names or letters for your predicates). ------------------ PE2 Translate the following statement into predicate logic (don't omit the quantifiers): "There is a professor who has taught a student from every department on campus". (choose appropriate names or letters for your predicates). PE3 Assume that the universe of discourse is {a,b,c} and that the following are true about a predicate P: P(a,a), P(b,c), P(a,c), P(b,a). State whether "exists(x) forall(y) P(x,y)" is true or not. Show your work.

Precedence Quantifiers have the highest precedence:    (unary operators)     yx P(x, y)  Q(x)  x R(x, y, z) y (x P(x, y))  Q(x)  (x R(x, y, z)) (y (x P(x, y)))  Q(x)  ((x R(x, y, z))) (y (x P(x, y)))  (Q(x)  ((x R(x, y, z)))) ((y (x P(x, y)))  (Q(x)  ((x R(x, y, z)))))

Scope, Bound, and Free Scope defines extent. Parentheses define scope, and precedence dictates how to insert parentheses. Bound variables define “sameness”. A variable is bound if it “is introduced by” a quantifier. A variable remains bound throughout the scope of the quantifier unless rebound by another quantifier in a nested sub formula. Any variable that is not bound is said to be free. We can consider bound variables to be local to the scope of the quantifier, just as parameters and locally declared variables in procedures are local to the procedure in which they are declared. If several quantifiers use the same bound variable for quantification, then all those variables are local to their scope and are distinct.

Example y x (P(x, y)  (Q(x)  x R(x, y, z))) Which variables are bound and which are free? y x (P(x, y)  (Q(x)  x R(x, y, z)))

Example y x (P(x, y)  (Q(x)  x R(x, y, z))) Which variables are bound and which are free? y x (P(x, y)  (Q(x)  x R(x, y, z))) y is bound x is bound x is bound z is free different x’s

Validity & Equivalences

Validity An expression that is true for all interpretations is said to be valid. (A valid expression is also call a tautology.) An expression that is true for no interpretation is said to be contradictory. (A contradictory expression is also called a contradiction.) If A is valid, A is contradictory. (a tautology) (a contradiction) Examples: P(x, y)  P(x, y)   P(x, y)  P(x, y) is valid P(x, y)   P(x, y) is contradictory Laws are valid!

DeMorgan’s Laws with Quantifiers deMorgan’s laws: xA  xA xA  xA Proof: xP(x)  (P(x1)  P(x2)  …)  P(x1)  P(x2)  …  xP(x)

Rectification Standardizing variables apart, also called rectification  we can rename variables to make distinct variables have distinct names. (xP(x, y)  xQ(y, x))  yR(y, x) free same free (xP(x, y)  zQ(y, z))  wR(w, v)