960 likes | 1.34k Views
Discrete Math. Part #1: The Fundamentals of Logic. Part #1: Foundations of Logic Section 2.1. Mathematical Logic is a tool for working with compound statements. Foundations of Logic: Overview. Propositional logic: It deals with propositions. Predicate logic: it deals with predicates.
E N D
Part #1: Foundations of LogicSection 2.1 Mathematical Logic is a tool for working with compound statements.
Foundations of Logic: Overview • Propositional logic:It deals with propositions. • Predicate logic: it deals with predicates.
Topic #1 – Propositional Logic Definition of a Proposition Definition: A proposition (denoted p, q, r, …) is simply: a statement (i.e., a declarative sentence) • with some definite meaning, (not fuzzy or ambiguous) • having a truth value that’s either true (T) or false (F) • it is never both, neither, or somewhere “in between!”
Topic #1 – Propositional Logic Examples of Propositions • “It is raining.” (In a given situation.) • “Beijing is the capital of China.” • “1 + 2 = 3” But, the following are NOT propositions: • “Who’s there?” (question) • “La la la la la.” (meaningless) • “Just do it!” (command) • “1 + 2” (expression with a non-true/false value) • “1 + 2 = x” (expression with unknown value: x)
Topic #1.0 – Propositional Logic: Operators Operators / Connectives An operator or 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 their truth values) instead of on numbers.
Topic #1.0 – Propositional Logic: Operators Some Popular Boolean Operators
Topic #1.0 – Propositional Logic: Operators The Negation Operator The unary negation operator “¬” (NOT) transforms a prop. into its logical negation. E.g. If p = “I have brown hair.” then ¬p = “I do not have brown hair.” The truth table for NOT: T :≡ True; F :≡ False “:≡” means “is defined as” Operandcolumn Resultcolumn
Topic #1.0 – Propositional Logic: Operators The Conjunction Operator The binary conjunction operator “” (AND) combines two propositions to form their logical conjunction. E.g. If p=“I will have salad for lunch.” and q=“I will have steak for dinner.”, then pq=“I will have salad for lunch andI will have steak for dinner.” ND Remember: “” points up like an “A”, and it means “ND”
Topic #1.0 – Propositional Logic: Operators Conjunction Truth Table Operand columns • Note that aconjunctionp1p2 … pnof n propositionswill have 2n rowsin its truth table. • Also: ¬ and operations together are suffi-cient to express any Boolean truth table!
Topic #1.0 – Propositional Logic: Operators The Disjunction Operator The binary disjunction operator “” (OR) combines two propositions to form their logical disjunction. p=“My car has a bad engine.” q=“My car has a bad carburetor.” pq=“Either my car has a bad engine, ormy car has a bad carburetor.” Meaning is like “and/or” in English.
Topic #1.0 – Propositional Logic: Operators Disjunction Truth Table • Note that pq meansthat 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 are also universal. Notedifferencefrom AND
Topic #1.0 – Propositional Logic: Operators Nested Propositional Expressions • Use parentheses to group sub-expressions:“I just saw my old friend, and either he’s grown or I’ve shrunk.” = f (g s) • (f g) s would mean something different • f g s would be ambiguous • By convention, “¬” takes precedence over both “” and “”.(¬, , , , ) • ¬s f means (¬s) f , not ¬ (s f)
Topic #1.0 – Propositional Logic: Operators A Simple Exercise Let p=“It rained last night”, q=“The sprinklers came on last night,” r=“The grass was wet this morning.” Translate each of the following into English: ¬p = r ¬p = ¬ r p q = “It didn’t rain last night.” “The grass was wet this morning, andit didn’t rain last night.” “Either the grass wasn’t wet this morning, or it rained last night, or the sprinklers came on last night.”
Topic #1.0 – Propositional Logic: Operators The Exclusive Or Operator The binary exclusive-or operator “” (XOR) combines two propositions to form their logical “exclusive or” (exjunction?). p = “I will earn an A in this course,” q =“I will drop this course,” p q = “I will either earn an A in this course, or I will drop it (but not both!)”
Topic #1.0 – Propositional Logic: Operators Exclusive-Or Truth Table • Note that pq meansthat p is true, or q istrue, but not both! • This operation iscalled exclusive or,because it excludes thepossibility that both p and q are true. Notedifferencefrom OR.
Topic #1.0 – Propositional Logic: Operators 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.
Topic #1.0 – Propositional Logic: Operators The Implication Operator hypothesis conclusion 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)
Topic #1.0 – Propositional Logic: Operators 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! The onlyFalsecase!
Topic #1.0 – Propositional Logic: Operators Examples of Implications • “If this lecture ever 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?
P Q has many forms in English Language: • "P implies Q" • " If P, Q" • "If P, then Q" • "P only if Q“ • "P is sufficient for Q" • "Q if P" • "Q is necessary for P" • "Q unless P"
Topic #1.0 – Propositional Logic: Operators 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
Topic #1.0 – Propositional Logic: Operators How do we know for sure? Proving the equivalence of p q and its contrapositive using truth tables:
Topic #1.0 – Propositional Logic: Operators Biconditional Truth Table • p q means that p and qhave the same truth value. • Note this truth table is theexact opposite of ’s! Thus, p q means ¬(p q) • p q does not implythat p and q are true, or that either of them causes the other, or that they have a common cause.
P Q has many forms in English Language: • "P if and only if Q" • "If P, then Q, and conversely" • "P is sufficient and necessary for Q"
Topic #1.0 – Propositional Logic: Operators Boolean Operations Summary
Topic #1.0 – Propositional Logic: Operators Some Alternative Notations
Translation English Sentences into Logical Expressions (1) • Ifyou are a computer science majororyou are not a freshman, P Q then you can access the internet from campus. R is translated to: ( Q P) R • If you watch televisionyour mind will decay, and conversely. P Q is translated to: P Q • You got an A in this class, but you did not do every exercise in the book. P Q is translated to: P Q4.
Translation English Sentences into Logical Expressions (2) • ifit is hot outsidebuy an ice cream, and if P Q you buy an ice creamit is hot outside. Q P is translated to: P Q Q P P Q • You can't drive a carifyou are a studentunless P Q you are older than 18 years old. R is translated to:( QR)P
Topic #2 – Bits 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”.
Topic #2 – Bits 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 0100 Bit-wise AND10 1010 1011 Bit-wise XOR 10 0100 1001 Bit-wise NOT(01 1011 0110)
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: Section2.2 Propositional equivalences. How to prove them. End of Section2.1
Topic #1.1 – Propositional Logic: Equivalences Propositional Equivalence (Section2.2) Two syntactically (i.e., textually) different compound propositions may be the semantically identical (i.e., have the same meaning). We call them equivalent. Learn: • Various equivalence rules or laws. • How to prove equivalences using symbolic derivations.
Topic #1.1 – Propositional Logic: Equivalences 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.
Topic #1.1 – Propositional Logic: Equivalences Logical Equivalence Compound proposition p is logically equivalent to compound proposition q, written pq, IFFthe compound proposition pq 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.
Topic #1.1 – Propositional Logic: Equivalences Proving Equivalencevia Truth Tables Ex. Prove that pq (p q). TAUTOLOGY
Topic #1.1 – Propositional Logic: Equivalences 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.
Topic #1.1 – Propositional Logic: Equivalences Equivalence Laws - Examples • Identity: pT p pF p • Domination: pT T pF F • Idempotent: pp p pp p • Double negation: p p • Commutative: pq qp pq qp • Associative: (pq)r p(qr) (pq)r p(qr)
Topic #1.1 – Propositional Logic: Equivalences More Equivalence Laws • Distributive: p(qr) (pq)(pr)p(qr) (pq)(pr) • De Morgan’s:(pq) p q (pq) p q • Trivial tautology/contradiction:p p Tp p F AugustusDe Morgan(1806-1871)
Topic #1.1 – Propositional Logic: Equivalences Defining Operators via Equivalences Using equivalences, we can define operators in terms of other operators. • Exclusive or: pq (pq)(pq)pq (pq)(qp) • Implies: pq p q • Biconditional: pq (pq) (qp)pq (pq)
Example 1: show that (P Q) (P Q) is a tautology 1. (P Q) (P Q) Implication rule 2. (P Q) (P Q) De Morgan Law 3. (P P) (Q Q) Associative and commutative 4. T T Negation law 5. T
Example2: show that (P (P Q) and (P Q) are logically equivalent. • (P (P Q) P (P Q) De morgan • P ((P) Q) De morgan • P ( P Q ) Double negation • ( P P) ( P Q) Distributive • F ( P Q) Negation • ( P Q) Identity
Topic #1.1 – Propositional Logic: Equivalences An Advanced Example Problem • Check using a symbolic derivation whether (p q) (p r) p q r. (p q) (p r) [Expand definition of ] (p q) (pr) [Expand defn. of ] (p q) ((p r) (p r)) [DeMorgan’s Law] (p q) ((p r) (p r)) cont.
Topic #1.1 – Propositional Logic: Equivalences 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.
Topic #1.1 – Propositional Logic: Equivalences 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.)
Topic #1 – Propositional Logic Review: Propositional Logic(2.1-2.2) • Atomic propositions: p, q, r, … • Boolean operators: • Compound propositions: s : (p q) r • Equivalences:pq (p q) • Proving equivalences using: • Truth tables. • Symbolic derivations. p q r …
Topic #3 – Predicate Logic Predicate Logic (Section2.3) • Predicate logic is an extension of propositional logic that permits concisely reasoning about whole classes of entities. • Propositional logic (recall) treats simple propositions (sentences) as atomic entities. • In contrast, predicate logic distinguishes the subject of a sentence from its predicate. • Remember these English grammar terms?
Topic #3 – Predicate Logic Subjects and Predicates • In the sentence “The dog is sleeping”: • The phrase “the dog” denotes the subject - the object or entity that the sentence is about. • The phrase “is sleeping” denotes the predicate- a property that is true of the subject. • In predicate logic, a predicate is modeled as a functionP(·) from objects to propositions. • P(x) = “x is sleeping” (where x is any object).
Topic #3 – Predicate Logic More About Predicates • Convention: Lowercase variables x, y, z... denote objects/entities; uppercase variables P, Q, R… denote propositional functions (predicates). • Keep in mind that the result ofapplying a predicate P to an object x is the proposition P(x). But the predicate Pitself (e.g. P=“is sleeping”) is not a proposition (not a complete sentence). • E.g. if P(x) = “x is a prime number”,P(3) is the proposition “3 is a prime number.”