
3/29/2017 Logic Propositions and logical operations Main concepts: • propositions • truth values • propositional variables • logical operations 1 3/29/2017 Propositions and logical operations • A proposition is the most basic element of logic • It is a declarative sentence that is either true or false Propositions and logical operations Examples of propositions: • Grass is green. • The Moon is made of green cheese. • Sacramento is the capital of California. • 1 + 0 = 1 • 0 + 0 = 2 2 3/29/2017 Propositions and logical operations Examples that are not propositions • Sit down! • What time is it? • x + 1 = 2 • x + y > z Propositions and logical operations • Every proposition has a truth value (T or F) • The value may be: • known/widely accepted as true • known/widely accepted as false • unknown • a matter of opinion (true for some people) • or even a false belief 3 3/29/2017 Propositions and logical operations • All these are propositions: Proposition Truth value 1 + 1 = 2 True 1 + 1 = 1 False It will rain tomorrow Unknown Logic is boring Opinion The sun orbits around the earth False belief Constructing Propositions • To avoid writing long propositions we use propositional variables • A propositional variable is typically a single letter (p, q, r, …) • It can denote arbitrary propositions • Examples: p: it is raining p represents the proposition “it is raining” q: the streets are wet q represents the proposition “the streets are wet” 4 3/29/2017 Compound Propositions • A logical operation combines propositions using certain rules • Example: • The operation denoted by “∧” means “and” • “p ∧ q” means “it is raining and the streets are wet” • If both p and q are true then p ∧ q is true • If either p or q (or both) are false then p ∧ q is false • “∧” is called the conjunction Constructing Propositions • Operations to construct compound propositions: • Conjunction ∧ AND • Disjunction ∨OR • Negation NOT • Implication → IF‐THEN • Biconditional ↔IFF 5 3/29/2017 Truth Tables • Any proposition can be represented by a truth table • It shows truth values for all combinations of its constituent variables • Example: proposition r involving 2 variables p and q all possible combinations truth values of of truth values of p and q compound proposition r pq r true true true false false true false false Conjunction • The conjunction of propositions p and q is denoted by p ∧ q • Its truth table is: pqp ∧ q Example: TT T • p: I am at home TF F • q: It is raining FT F • p ∧ q: I am at home and it is raining FF F 6 3/29/2017 Disjunction • The disjunction of propositions p and q is denoted by p ∨ q • Its truth table is: pq p ∨ q Example: TT T • p: I am at home TF T • q: It is raining FT T • p ∨ q: I am at home or it is raining FF F Ambiguity of “or” in English • In natural languages “or” has two distinct meanings • Inclusive Or: • p ∨ q is true if either p or q or both are true • Example: • “Math 10a or Math 12 may be taken as a prerequisite for CS 6” • Meaning: take either one but may also take both 7 3/29/2017 Ambiguity of “or” in English • Exclusive Or (Xor) • Denoted as “⊕” • p ⊕ q is true if either p or q but not both are true p q p ⊕ q Example: TT F • “Soup or salad comes with this entrée” TF T • Meaning: do not expect to get both FT T FF F Negation • The negation of a proposition p is denoted by ¬p • Its truth table is: Example: p ¬p TF • p: The earth is round FT • p: It is not true that the earth is round or more simply: The earth is not round 8 3/29/2017 Constructing truth tables • A proposition can involve any number of variables • Each row corresponds to a possible combination of variables • With n variables the truth table has: • n+1 columns (1 for each of the n variables and 1 for the compound expression) • 2n rows (plus a header) Constructing truth tables • To construct the truth table for a given proposition: 1. Create a table with 2n rows and n+1 columns 2. Fill in the first n columns with all possible combinations 3. Determine and enter the truth value for each combination 9 3/29/2017 Constructing truth tables • Example: pqr¬p ∨ (q ∧ r ) p ∨ q ∧ r Constructing truth tables • Using intermediate pqr ¬p ∨ (q ∧ r ) columns TTT TTF TFT TFF FTT FTF FFT FFF 10 3/29/2017 Conditional statements • If p and q are propositions then p → q is a conditional statement or implication • It means: if p then q • p is the hypothesis (premise) and q is the conclusion (consequence) • Example: p q p → q • p: It is raining TT T • q: The streets are wet TF F • p → q: If it is raining then streets are wet FT T FF T • From a false premise anything can be implied! Understanding Implication • View logical conditional as an obligation or contract: • Example: “If you get 100% on the final then you will earn an A” p → q q: earn A ¬q: don’t get A p: get 100% p → q = T p → q = F ¬p: don’t get 100% p → q = T p → q = T • F → T does not violate the contract • The only time the contract is broken is when T → F 11 3/29/2017 Understanding Implication • In p → q there may not be any connection between p and q • Examples of valid but counterintuitive implications: • If the moon is made of green cheese then you get a PhD in physics • True! • If Juan has a smartphone then 2 + 3 = 6: • False if Juan does have a smartphone • True if he does NOT Different Ways of Expressing if p then q If it’s raining then streets are wet if p, q If it’s raining, streets are wet p implies q Rain implies that streets are wet p only if q q if p q when p Streets are wet when it’s raining q whenever p Streets are wet whenever it’s raining q follows from p Streets being wet follows from there being a rain p is sufficient for q q is necessary for p 12 3/29/2017 Different Ways of Expressing p → q: It is raining → streets are wet Which statements are equivalent? q if p Streets are wet if it’s raining = T q only if p Streets are wet only if it’s raining = F p if q It’s raining if streets are wet = F p only if q It’s raining only if streets are wet = T Last statement is awkward but consider a different example: (n is even → n1 is odd) ≡ (n is even only if n1 is odd) Remember: (q if p) ≡ (p only if q) ≢ (p if q) ≡ (q only if p) Sufficient versus Necessary p is sufficient for q Rain is sufficient for streets being wet q is necessary for p Wet streets are necessary for there being rain • “Necessary condition” is counter‐intuitive in English • It suggest that wet streets are a requirement for rain • Better: implicitly read “necessary result of” or “necessary consequence of” 13 3/29/2017 Converse, Inverse, Contrapositive • From p → q we can form new conditional statements: q → p is the converse of p → q p → q is the inverse of p → q q → p is the contrapositive of p → q • How are these statements related to the original? • How are they related to each other? • Are any of them equivalent? Converse, Inverse, Contrapositive • Example 1. implication: it’s raining → streets are wet True 2. converse: streets are wet → it’s raining False 3. inverse: it’s not raining → streets are not wet False 4. contrapositive: streets are not wet → it’s not raining True Only 1 = 4 and 2 = 3 14 3/29/2017 Biconditional • The biconditional proposition p ↔ q means: p if and only if q • Other ways to say this: • p iff q pqp ↔ q • if p then q, and conversely TT T • p is necessary and sufficient for q TF F FT F FF T Biconditional • Example p: You buy an airline ticket q: You can take a flight p ↔ q: You can take a flight iff you buy an airline ticket • True only if you do both or neither • Doing only one or the other makes the proposition false 15 3/29/2017 Compound Propositions • All logical operations can be applied to build up arbitrarily complex compound propositions • Any proposition can become a term inside another proposition • Examples: • p, q, r, t are simple propositions • p ∨ q and r → t combine simple propositions • p ∨ q → t and p ∨ q ∧ t ∨ r combine simple and compound propositions into more complex compound propositions • Parenthesis indicate the order of evaluation Precedence of Logical Operations • To reduce number of parentheses use precedence rules Operation Precedence Examples: 1 • p ∨ q ∧ r means: p ∨ q ∧ r ∧ 2 • p ∨ q ∧ r requires the parentheses ∨ 3 → 4 • p ∨ q → r means: p ∨ q → r ↔ 5 • p ∨ q → r requires parentheses 16 3/29/2017 Logical Equivalence • A tautology is a proposition that is always true Example: p∨ p p¬pp ∨ ¬p TF T FT T • A contradiction is a proposition that is always false Example: p∧ p p¬pp ∧ ¬p TF F FT F Equivalent Propositions • Two propositions are logically equivalent if they always have the same truth value • We write this as p ≡ q • Formally: p and q are logically equivalent iff p ↔ q is a tautology 17 3/29/2017 Showing Equivalence • One way to determine equivalence is to use truth tables • Example: show that p ∨ q is equivalent to p → q pqp p ∨ q p → q TTF TFF FTT FFT Showing Non‐Equivalence • Find at least one row where values differ • Example: Show that neither the converse nor the inverse of an implication are equivalent to the implication p q ¬p ¬q p → q ¬p → ¬q q → p TTFF T TFFT F FTTF T FFTT T 18 3/29/2017 Showing Equivalence • Truth tables with many variable become cumbersome • Use laws of logic to transform propositions into equivalent forms • To prove that p ≡ q, produce a series of equivalences leading from p to q: p ≡ p1 p1 ≡ p2 .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages53 Page
-
File Size-