Presentation is loading. Please wait.

Presentation is loading. Please wait.

Propositional Logic.

Similar presentations


Presentation on theme: "Propositional Logic."— Presentation transcript:

1 Propositional Logic

2 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

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

4 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

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

6 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

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

8 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

9 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!

10 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

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

12 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

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

14 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

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

16 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

17 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

18 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!

19 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

20 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

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

22 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

23 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

24 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!

25 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

26 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

27 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

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

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

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

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

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

33 Predicate Calculus

34 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

35 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

36 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

37 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

38 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

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

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

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

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

43 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

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

45 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

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

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

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

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

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

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

52 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

53 Validity & Equivalences

54 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!

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

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


Download ppt "Propositional Logic."

Similar presentations


Ads by Google