1 / 76

Module #1: Foundations of Logic

Module #1: Foundations of Logic. Rosen 5 th ed., §§1.1-1.4 ~74 slides, ~4-6 lectures. Module #1: Foundations of Logic (§§1.1-1.3, ~3 lectures). Mathematical Logic is a tool for working with complicated < compound statements>. It includes: A language for expressing them.

ernestc
Download Presentation

Module #1: Foundations of Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Module #1:Foundations of Logic Rosen 5th ed., §§1.1-1.4 ~74 slides, ~4-6 lectures (c)2001-2003, Michael P. Frank

  2. Module #1: Foundations of Logic(§§1.1-1.3, ~3 lectures) Mathematical Logic is a tool for working with complicated <compound statements>. It includes: • A language for expressing them. • A concise notation for writing them. • A methodology for objectively reasoning about their truth or falsity. • It is the foundation for expressing formal proofs in all branches of mathematics. (c)2001-2003, Michael P. Frank

  3. Foundations of Logic: Overview • Propositional(命題) logic (§1.1-1.2): • Basic definitions. (§1.1) • Equivalence rules & derivations. (§1.2) • Predicate(述語) logic( (§1.3-1.4) • Predicates. • Quantified(量化) predicate expressions. • Equivalences & derivations. (c)2001-2003, Michael P. Frank

  4. Propositional Logic (§1.1) Propositional Logic (Propositional Calculus) is the logic of <compound statements> built from simpler statements using so-called Booleanconnectives. Some applications in computer science: • Design of digital electronic circuits. • Expressing conditions in programs. • Queries to databases & search engines. George Boole(1815-1864) (c)2001-2003, Michael P. Frank

  5. Definition of a Proposition A proposition (p, q, r, …) is simply a statement (i.e., a declarative sentence) with a definite meaning, having a truth value that’s either true (T) or false (F) (never both, neither, or somewhere in between). (However, you might not know the actual truth value, and it might be situation-dependent.) [Later we will study probability theory, in which we assign degrees of certainty to propositions. But for now: think True/False only!] (c)2001-2003, Michael P. Frank

  6. Examples of Propositions • “It is raining.” (In a given situation.) • “Beijing is capital of China.” • “1 + 2 = 3” But, following are NOT propositions: • “Who’s there?” (interrogative, question) • “La la la la la.” (meaningless interjection) • “Just do it!” (imperative, command) • “Yeah, I sorta dunno, whatever...” (vague) • “1 + 2” (expression with a non-true/false value) (c)2001-2003, Michael P. Frank

  7. Operators / Connectives An operator (or a connective) combines one or more operand expressions into a larger expression. (E.g., “+” in numeric exprs.) Unary operators take 1 operand (e.g., −3); binary operators take 2 operands (eg 3  4). Propositional (or Boolean) operators operate on propositions or truth values instead of on numbers. (c)2001-2003, Michael P. Frank

  8. Some Popular Boolean Operators (c)2001-2003, Michael P. Frank

  9. The Negation Operator The unary negation operator “¬” (NOT) transforms a prop. into its logical negation. ¬p can be stated as“It’s not the case that p” E.g. The negation of proposition “I have brown hair.” is “It’s not the case that I have brown hair”, or “I do not have brown hair.” (c)2001-2003, Michael P. Frank

  10. The Negation Truth Table Truth table for NOT: T :≡ True; F :≡ False “:≡” means “is defined as” (c)2001-2003, Michael P. Frank

  11. The Conjunction Operator Let p, q be propositions. The proposition “p and q”( denoted “p q” ) is true when both p and q are true and is false otherwise. p q is called the conjunction of p and q. E.g. If p=“Today is Friday.” and q=“It’s raining today.”, then pq is true onrainy Friday. (c)2001-2003, Michael P. Frank

  12. Conjunction Truth Table • Note that aconjunctionp1p2  … pnof n propositionswill have 2n rowsin its truth table. • The combination of ¬ and  is <universal operator> (can express any Boolean operation) (c)2001-2003, Michael P. Frank

  13. The Disjunction Operator Let p, q be propositions. The proposition “p or q”( denoted “p q” ) is false when both p and q are false and is true otherwise. ”p q”is called the disjunction of p and q. The disjunction of p, q of previous example is “Today is Friday or it is raining today”. (c)2001-2003, Michael P. Frank

  14. Disjunction Truth Table • Note that pq is true • when p is true, or q istrue, or both are true! • So, this operation isalso called inclusive or,because it includes thepossibility that both p and q are true. • “¬” and “” together can form universal operator too. (c)2001-2003, Michael P. Frank

  15. The Exclusive Or Operator Let p, q be propositions. The exclusive-or of p and q ( denoted “p q” ) is true when exactly one of p and q is true and is false otherwise. The truth table of exclusive-or. “¬” and “” together are not universal. (c)2001-2003, Michael P. Frank

  16. Natural Language is Ambiguous Note that English “or” can be ambiguous regarding the “both” case! “Pat is a singer orPat is a writer.” - “Pat is a man orPat is a woman.” - Need context to disambiguate the meaning! For this class, assume “or” means inclusive.   (c)2001-2003, Michael P. Frank

  17. The Implication Operator antecedent consequent The implicationp  q states that p implies q. I.e., If p is true, then q is true; but if p is not true, then q could be either true or false. E.g., let p = “You study hard.”q = “You will get a good grade.” p  q = “If you study hard, then you will get a good grade.” (else, it could go either way) (c)2001-2003, Michael P. Frank

  18. Implication Truth Table • p  q is falseonly whenp is true but q is not true. • p  q does not saythat pcausesq! • p  q does not requirethat p or qare ever true! • E.g. “(1=0)  pigs can fly” is TRUE! (c)2001-2003, Michael P. Frank

  19. Examples of Implications • “If this lecture ends, then the sun will rise tomorrow.” True or False? • “If Tuesday is a day of the week, then I am a penguin.” True or False? • “If 1+1=6, then Bush is president.” True or False? • “If the moon is made of green cheese, then I am richer than Bill Gates.” True or False? (c)2001-2003, Michael P. Frank

  20. “p implies q” “if p, then q” “if p, q” “when p, q” “whenever p, q” “q if p” “q when p” “q whenever p” “p only if q” “p is sufficient for q” “q is necessary for p” “q follows from p” “q is implied by p” We will see some equivalent logic expressions later. Meaning of p  q (c)2001-2003, Michael P. Frank

  21. Converse, Inverse, Contrapositive Some terminology, for an implication p  q: • Its converseis: q  p. • Its inverse is: ¬p  ¬q. • Its contrapositive: ¬q  ¬p. • One of these three has the same meaning (same truth table) as p q. Can you figure out which? Contrapositive (c)2001-2003, Michael P. Frank

  22. How do we know for sure? Proving the equivalence of p  q and its contrapositive using truth tables: (c)2001-2003, Michael P. Frank

  23. The biconditional operator The biconditionalp q is truewhen p and q have the same truth values and is false otherwise. The biconditionalp q has exactly same truth values of (p  q)  (q p). “p if and only if q” is used for p q . Let p be “You can take the flight”, q be “You buy a ticket”. What is the proposition of “You can take the flight if and only if you buy a ticket.” ? p q. (c)2001-2003, Michael P. Frank

  24. Biconditional Truth Table • p  q is true when p and qhave the same truth value. • Note this truth table is theexact opposite of ’s : p  q means ¬(p  q) • p  q does not implyp and q are true, or cause each other. (c)2001-2003, Michael P. Frank

  25. Boolean Operations Summary • We have seen 1 unary operator (out of the 4 possible) and 5 binary operators (out of the 16 possible). Their truth tables are below. (c)2001-2003, Michael P. Frank

  26. Some Alternative Notations (c)2001-2003, Michael P. Frank

  27. Precedence of Operators • Use parentheses so that the order of conjunction and disjunction is clear. • ¬p  q means (¬p )  q not ¬ (p  q) • p  q  r means (p  q) r (left to right for operators with same precedence) • The precedence of operators (c)2001-2003, Michael P. Frank

  28. Translating English Sentences • To remove the ambiguity • “ You can access the Internet from campus only if you are a computer science major or you are not a freshman” • Solution: Let • a=“You can access the Internet from campus” • c=“You are a computer science major” • f=“You are a freshman” • The sentence can be represented by a c  ¬ f Implies (c)2001-2003, Michael P. Frank

  29. System Specifications Determine whether following specifications are consistent: “ The diagnostic message is stored in the buffer or it is retransmitted” “The diagnostic message is not stored in the buffer” “If the diagnostic message is stored in the buffer, then it is retransmitted” Solution: Let p denote “The diagnostic message is stored in the buffer” q denote “The diagnostic message is retransmitted” p  q ¬ p p  q They are consistent when p is false and q is true. (c)2001-2003, Michael P. Frank

  30. Logic Puzzles Two kinds of inhabitants: Knights: always tell the truth; Knaves: always lie. You encounter 2 people A and B. A says:”B is a knight”, B says: “I and A are of opposite types”. What are A and B? Solution: Let p denote “A is a knight” ; q denote “B is a knight” ○ : consistent; X : inconsistent (c)2001-2003, Michael P. Frank

  31. Bits and Bit Operations • A bit is a binary (base 2) digit: 0 or 1. • Bits may be used to represent truth values. • By convention: 0 represents “false”; 1 represents “true”. • Boolean algebra is like ordinary algebra except that variables stand for bits, + means “or”, and multiplication means “and”. • See chapter 10 for more details. John Tukey(1915-2000) (c)2001-2003, Michael P. Frank

  32. Bit Strings • A Bit string of length n is an ordered series or sequence of n0 bits. • More on sequences in §3.2. • By convention, bit strings are written left to right: e.g. the first bit of “1001101010” is 1. • When a bit string represents a base-2 number, by convention the first bit is the most significant bit. Ex. 11012=8+4+1=13. (c)2001-2003, Michael P. Frank

  33. Counting in Binary • Did you know that you can count to 1,023 just using two hands? • How? Count in binary! • Each finger (up/down) represents 1 bit. • To increment: Flip the rightmost (low-order) bit. • If it changes 1→0, then also flip the next bit to the left, • If that bit changes 1→0, then flip the next one, etc. • 0000000000, 0000000001, 0000000010, ……, 1111111101, 1111111110, 1111111111 (c)2001-2003, Michael P. Frank

  34. Bitwise Operations • Boolean operations can be extended to operate on bit strings as well as single bits. • E.g.:01 1011 011011 0001 110111 1011 1111 Bit-wise OR01 0001 0100Bit-wise AND10 1010 1011Bit-wise XOR (c)2001-2003, Michael P. Frank

  35. You have learned about: Propositions: What they are. Propositional logic operators’ Symbolic notations. English equivalents. Logical meaning. Truth tables. Atomic vs. compound propositions. Alternative notations. Bits and bit-strings. Next section: §1.2 Propositional equivalences. How to prove them. End of §1.1 (c)2001-2003, Michael P. Frank

  36. Propositional Equivalence (§1.2) Compound propositions p and q that have same truth values in all possible cases are called logically equivalent, denoted as p≡q. The symbol ≡ is not a logical connective, it means that p≡q is not a compound prop. Sometimes, the symbol  is used instead of ≡. (c)2001-2003, Michael P. Frank

  37. Tautologies and Contradictions A tautology is a compound proposition that is trueno matter what the truth values of its atomic propositions are! Ex.p  p [What is its truth table?] A contradiction is a compound proposition that is false no matter what! Ex.p  p [Truth table?] Other compound props. are contingencies. (c)2001-2003, Michael P. Frank

  38. Logical Equivalence Compound proposition p is logically equivalent to compound proposition q, written p≡q, IFFthe compound proposition pq is a tautology. Compound propositions p and q are logically equivalent to each other IFFp and q contain the same truth values as each other in all rows of their truth tables. (c)2001-2003, Michael P. Frank

  39. Proving Equivalencevia Truth Tables Ex. Prove that pq≡ (p  q). F T T T F T T F F T T F T F T T F F F T (c)2001-2003, Michael P. Frank

  40. Equivalence Laws • These are similar to the arithmetic identities you may have learned in algebra, but for propositional equivalences instead. • They provide a pattern or template that can be used to match all or part of a much more complicated proposition and to find an equivalence for it. (c)2001-2003, Michael P. Frank

  41. Equivalence Laws - Examples • Identity: pT ≡p pF ≡p • Domination: pT ≡T pF ≡F • Idempotent: pp ≡p pp ≡p • Double negation: p ≡p • Commutative: pq ≡qp pq ≡qp • Associative: (pq)r≡p(qr) (pq)r≡p(qr) (c)2001-2003, Michael P. Frank

  42. More Equivalence Laws • Distributive: p(qr) ≡ (pq)(pr)p(qr) ≡ (pq)(pr) • De Morgan’s: (pq) ≡ p  q (pq) ≡ p  q • Trivial tautology/contradiction:p  p≡Tp  p≡F AugustusDe Morgan(1806-1871) (c)2001-2003, Michael P. Frank

  43. Defining Operators via Equivalences Using equivalences, we can define operators in terms of other operators. • Exclusive or: pq≡ (pq)(pq)pq≡ (pq)(qp) • Implies: pq ≡ p  q • Biconditional: pq ≡ (pq) (qp)pq ≡ (pq) (c)2001-2003, Michael P. Frank

  44. An Example Problem • Check using a symbolic derivation whether (p  q)  (p  r)≡ p  q  r. (p  q)  (p  r) [Expand definition of ] (p  q)  (pr) [Defn. of ]  (p  q)  ((p  r)  (p  r)) [DeMorgan’s Law]  (p  q)  ((p  r)  (p  r))  [associative law] cont. (c)2001-2003, Michael P. Frank

  45. Example Continued... (p  q)  ((p  r)  (p  r)) [ commutes]  (q  p)  ((p  r)  (p  r))[ associative]  q  (p  ((p  r)  (p  r))) [distrib.  over ]  q  (((p  (p  r))  (p  (p  r))) [assoc.]  q  (((p  p)  r)  (p  (p  r))) [trivail taut.]  q  ((T  r)  (p  (p  r))) [domination] q  (T  (p  (p  r))) [identity]  q  (p  (p  r)) cont. (c)2001-2003, Michael P. Frank

  46. End of Long Example q  (p  (p  r)) [DeMorgan’s]  q  (p  (p  r)) [Assoc.]  q  ((p  p)  r) [Idempotent]  q  (p  r) [Assoc.]  (q  p)  r [Commut.] p  q  r Q.E.D. (quod erat demonstrandum) (Which was to be shown.) (c)2001-2003, Michael P. Frank

  47. Review: Propositional Logic(§§1.1-1.2) • Atomic propositions: p, q, r, … • Boolean operators:      • Compound propositions: s : (p q)  r • Equivalences:pq  (p  q) • Proving equivalences using: • Truth tables. • Symbolic derivations. p q  r … (c)2001-2003, Michael P. Frank

  48. Predicates and Quantifiers(§1.3) • The statement “ X is greater than 3” has 2 parts: Subject (variable X) and Predicate (“is greater than 3”). • Let P(X) denote statement “X is greater than 3”, where P denote the predicate “is greater than 3”. P(X) is also said to be the value of propositional function P at X • For example, let P(X) denote “X>3”, what are the truth values of P(4) and P(2)? (c)2001-2003, Michael P. Frank

  49. Predicates • Let Q(x,y) denote the statement “x=y+3”, What are the truth values of the propositions Q(1,2) and Q(3,0)? • Let R(x,y,z) denote the statement “x+y=z”, What are the truth values of the propositions R(1,2,3) and R(0,0,1)? • A statement of the form P(x1,x2,…,xn) is the value of the propositional function P at the n-tuple (x1,x2,…,xn), and P is also called a predicate. (c)2001-2003, Michael P. Frank

  50. Quantification • The collection of values that a variable x can take is called x’s universe of discourse (Domain). • E.g., let P(x)=“x+1>x”. We can then say,“For anynumberx, P(x) is true” instead of(0+1>0)  (1+1>1) (2+1>2) ... • Two types: universal quantification and existential quantification. (c)2001-2003, Michael P. Frank

More Related