Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module #1: Foundations of Logic

Similar presentations


Presentation on theme: "Module #1: Foundations of Logic"— Presentation transcript:

1 Module #1: Foundations of Logic
Discrete Mathematics and its Applications 2018/11/19 Module #1: Foundations of Logic Rosen 5th ed., §§ ~74 slides, ~4-6 lectures In Spring 2003 I spent 7 fifty-minute lecture periods on this material, but two half-lectures were taken up by team selection and a quiz, so it really only took 6 lectures. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

2 Module #1: Foundations of Logic (§§1.1-1.3, ~3 lectures)
Discrete Mathematics and its Applications 2018/11/19 Module #1: Foundations of Logic (§§ , ~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. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

3 Foundations of Logic: Overview
Propositional(命題) logic (§ ): Basic definitions. (§1.1) Equivalence rules & derivations. (§1.2) Predicate(述語) logic( (§ ) Predicates. Quantified(量化) predicate expressions. Equivalences & derivations. 2018/11/19 (c) , Michael P. Frank

4 Propositional Logic (§1.1)
Discrete Mathematics and its Applications 2018/11/19 Propositional Logic (§1.1) Propositional Logic (Propositional Calculus) is the logic of <compound statements> built from simpler statements using so-called Boolean connectives. Some applications in computer science: Design of digital electronic circuits. Expressing conditions in programs. Queries to databases & search engines. We normally attribute propositional logic to George Boole, who first formalized it. Actually the particular formal notation we will present is not precisely Boole’s; he originally spoke of logic in terms of sets, not propositions, and he also used Boolean algebra notation such as AB, A+B, rather than the A /\ B, A \/ B notation we will use. But, he was the first to mathematically formalize these kinds of concepts in preserved writings. Boole’s formalization of logic was developed further by the philosopher Frege. However, even though logic was not formalized as such until the 1800’s, the basic ideas of it go all the way back to the ancient Greeks. Aristotle (ca B.C.) developed a detailed system of logic (though one that was not quite as convenient and powerful as the modern one), and Chrysippus of Soli (ca B.C.) introduced a logic centered around logic AND, inclusive and exclusive OR, NOT, and implication, similarly to Boole’s. Chrysippus’ logic apparently included all of the key rules that Boole’s logic had. However, his original works were unfortunately lost; we only have fragments quoted by other authors. George Boole ( ) 2018/11/19 (c) , Michael P. Frank (c) , 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!] 2018/11/19 (c) , 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) 2018/11/19 (c) , Michael P. Frank

7 Operators / Connectives
Discrete Mathematics and its Applications 2018/11/19 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. Later in the course, we will see that operators can themselves be defined in terms of functions. This slide doesn’t define them that way because we haven’t defined functions yet. But for your reference, when you come back to study this section after learning about functions, in general, an n-ary operator O on any set S (the domain of the operator) is a function O:S^n->S mapping n-tuples of members of S (the operands) to members of S. “S^n” here denotes S with n as a superscript, that is, the nth Cartesian power of S. All this will be defined later when we talk about set theory. For Boolean operators, the set we are dealing with is B={True,False}. A unary Boolean operator U is a function U:B->B, while a binary Boolean operator T is a function T:(B,B)->B. Binary operators are conventionally written in between their operands, while unary operators are usually written in front of their operands. (One exception is the post-increment and post-decrement operators in C/C++/Java, which are written after their operands.) 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

8 Some Popular Boolean Operators
Formal Name Nickname Arity Symbol Negation operator NOT Unary Conjunction operator AND Binary Disjunction operator OR Exclusive-OR operator XOR Implication operator IMPLIES Biconditional operator IFF 2018/11/19 (c) , 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.” 2018/11/19 (c) , Michael P. Frank

10 The Negation Truth Table
Truth table for NOT: T :≡ True; F :≡ False “:≡” means “is defined as” 2018/11/19 (c) , 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 on rainy Friday. 2018/11/19 (c) , Michael P. Frank

12 Conjunction Truth Table
Discrete Mathematics and its Applications 2018/11/19 Conjunction Truth Table Note that a conjunction p1  p2  …  pn of n propositions will have 2n rows in its truth table. The combination of ¬ and  is <universal operator> (can express any Boolean operation) Note that AND is commutative and associative, which means that we can write a long conjunction (like in the first bullet on the left) without parenthesizing it. It also doesn’t matter what order the n propositions are in. The fact that an n-operand operator has 2^n rows in its truth table is an easy consequence of the product rule of combinatorics. Here is a proof. Note that for the table to be complete, we must have 1 row for every possible assignment of truth values to the n operands. Thus, there is 1 row for every function f:V->B, where V is the set of operand columns {p,q,…} and B={T,F}. Here, |V|=n and |B|=2. The number of functions from a set of size n to a set of size m is m^n. This is because of the product rule, as we will see in a moment. In this case, m=2 so we get 2^n such functions. In terms of the product rule: There are 2 possible values for p. For each of these, there are 2 possible values for q, since the choice of q is independent of the choice of p. And so on. So there are 2x2x…(n repetitions)…x2 possible rows, thus 2^n. Of course, we haven’t defined the product rule, set cardinality, or functions yet, so don’t worry if the above argument doesn’t quite make sense to you yet. In the second bullet, we would say, {NOT,AND} is a universal set of Boolean operators, but we haven’t even defined sets yet. If you already know what a set is, a universal set of operators over a given domain is a set of operators such that nested expressions involving those operators are sufficient to express any possible operator over that domain. In this case, the domain is B={T,F}. The proof that {NOT,AND} is universal is as follows: OR can be defined by p OR q = NOT(NOT(p) AND NOT(q)) (easily verified; this is one of DeMorgan’s Laws, which we will get to later). Now, armed with OR, AND, and NOT, we can show how to express any Boolean truth table, with any number of columns, as follows. Look for the cases where the last (result) column is T. For each such row in the truth table, include a corresponding term in a disjunctive expression for the whole truth table. The term should be a conjunction of terms, one for each input operand in that row. Each of these terms should be p if the entry in that position is “T”, and NOT(p) if the entry in that position is “F”. So, the entire expression basically says, “the value of the operator is T if and only if the pattern of truth values of the input operands exactly matches one of the rows in the truth table that ends in a ‘T’ result.” Thus, the expression directly encodes the content of the truth table. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

13 The Disjunction Operator
Discrete Mathematics and its Applications 2018/11/19 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”. OR is also commutative and associative. The animated picture on the right is just a memory device to help you remember that the disjunction operator is symbolized with a downward-pointing wedge, like the blade of an axe, because it “splits” a proposition into two parts, such that you can take either part (or both), if you are trying to decide how to make the whole proposition true. Note that the meaning of disjunction is like the phrase “and/or” which is sometimes used in informal English. “The car has a bad engine and/or a bad carburetor.” 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

14 Disjunction Truth Table
Note that pq is true when p is true, or q is true, or both are true! So, this operation is also called inclusive or, because it includes the possibility that both p and q are true. “¬” and “” together can form universal operator too. 2018/11/19 (c) , 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. 2018/11/19 (c) , Michael P. Frank

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

17 The Implication Operator
Discrete Mathematics and its Applications 2018/11/19 The Implication Operator antecedent consequent The implication p  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) Note that the definition of “p implies q” says: “If p is true, then q is true, and if p is not true, then q is either true or false.” Well, saying that q is either true or false is not saying anything, since any proposition is, by the very definition of a proposition, either true or false. So, the last part of that sentence (covering the case where p is not true) is not really saying anything. So we may as well say the definition is, “If p is true, then q is true.” 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

18 Implication Truth Table
Discrete Mathematics and its Applications 2018/11/19 Implication Truth Table p  q is false only when p is true but q is not true. p  q does not say that p causes q! p  q does not require that p or q are ever true! E.g. “(1=0)  pigs can fly” is TRUE! Let’s consider the rows of the truth table, one at a time. In the first row, p is false and q is false. Now, let’s consider the definition of p->q. It says “If p is true, then q is true, but if p is false, then q is either true or false.” Well, in this case, p is false, and q is either true or false (namely false), so the second part of the statement is true. But, of course that part is true, since it is just a tautology that q is either true or false. In other words, and if is always true when its antecedent is false. Similarly, the second row is True. The third row is false, since p is true but q is false, so it is not the case that if p is true then q is true. Finally, in the fourth row, since p is true and q is true, it is the case that if q is true then q is true. Many students have trouble with the implication operator. When we say, “A implies B”, it is just a shorthand for “either not A, or B”. In other words, it is just the statement that it is NOT the case that A is true and B is false. This often seems wrong to students, because when we say “A implies B” in everyday English, we mean that if somehow A were to become true in some way, somehow, the statement B would automatically be thereby made true, as a result. This does not seem to be the case in general when A and B are just two random false statements (such as the example in the last bullet). (However in this case, we might make a convoluted argument that the antecedent really DOES effectively imply the consequent: Note that if 1=0, then if a given pig flies 0 times in his life, then he also flies 1 time, thus he can fly.) In any case, perhaps a more accurate and satisfying English rendering of the true meaning of the logical claim “A implies B”, might be just, “the possibility that A implies B is not contradicted directly by the truth values of A and B”. In other words, “it is not the case that A is true and B is false.” (Since that combination of truth values would directly contradict the hypothesis that A implies B.) 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

19 Examples of Implications
Discrete Mathematics and its Applications 2018/11/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? The first one is true because T->T is True. It doesn’t matter that my lecture ending is not the cause of the sun rising tomorrow. The second one is false for me, because although Tuesday is a day of the week, I am most certainly NOT a penguin. (But, if a penguin were to say this statement, then it would be true for him.) The third one is true, because 1+1 is not equal to 6. F->T is True. The last one is true, because the moon is not made of green cheese. F->F is True. In other words, anything that’s false implies anything at all. p->q if p is false. Why? If p is false, then if p is true, then p is both false and true at the same time, and so truth and falsity are the same thing. So if q is false then q is true. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

20 Meaning of p  q “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. 2018/11/19 (c) , Michael P. Frank

21 Converse, Inverse, Contrapositive
Discrete Mathematics and its Applications 2018/11/19 Converse, Inverse, Contrapositive Some terminology, for an implication p  q: Its converse is: 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? Also, note that the converse and inverse of p->q also have the same meaning as each other. Contrapositive 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

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

23 The biconditional operator
Discrete Mathematics and its Applications 2018/11/19 The biconditional operator The biconditional p  q is true when p and q have the same truth values and is false otherwise. The biconditional p  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. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

24 Biconditional Truth Table
Discrete Mathematics and its Applications 2018/11/19 Biconditional Truth Table p  q is true when p and q have the same truth value. Note this truth table is the exact opposite of ’s : p  q means ¬(p  q) p  q does not imply p and q are true, or cause each other. Also, p IFF q is equivalent to (p -> q) /\ (q -> p). (“/\” being the AND wedge) 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

25 Boolean Operations Summary
Discrete Mathematics and its Applications 2018/11/19 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. For fun, try writing down the truth tables for each of the 4 possible unary operators, and each of the 16 possible binary operators. For each one, try to come up with an English description of the operator that conveys its meaning. Also, figure out a way to define it in terms of other operators we already introduced. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

26 Some Alternative Notations
2018/11/19 (c) , 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 2018/11/19 (c) , 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 2018/11/19 (c) , 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. 2018/11/19 (c) , 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 2018/11/19 (c) , Michael P. Frank

31 Bits and Bit Operations
Discrete Mathematics and its Applications 2018/11/19 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 ( ) Bits can also be defined in terms of sets, if you like, by the convention that the empty set {} represents 0, and the set containing the empty set {{}} represents 1. Or more generally, any two distinct objects can represent the two bit-values or truth-values. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

32 Discrete Mathematics and its Applications
2018/11/19 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 “ ” is 1. When a bit string represents a base-2 number, by convention the first bit is the most significant bit. Ex =8+4+1=13. We will talk about strings more generally later in the module on sequences. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

33 Discrete Mathematics and its Applications
2018/11/19 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. , , , … …, , , This is just a fun exercise to practice with the binary number system. We’ll have more to say about binary (and base-n numbers in general) later in the course. If you demonstrate this technique, you should probably apologize to your audience when you get to 4. The sequence in the last bullet is (in decimal): 0, 1, 2, … (skip a bunch) …, 1021, 1022, The next number, 1024 (or 1K) is 2^10. You would need 11 fingers to show it! 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

34 Discrete Mathematics and its Applications
2018/11/19 Bitwise Operations Boolean operations can be extended to operate on bit strings as well as single bits. E.g.: Bit-wise OR Bit-wise AND Bit-wise XOR The answers are present, but hidden, as white text on a white background. The slide can be done in class as an exercise, with the instructor typing in the students’ answers in the space provided. Then the correct answers can be revealed by selecting the bottom 3 rows and changing their font color unconditionally to black. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

35 End of §1.1 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. 2018/11/19 (c) , 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 ≡. 2018/11/19 (c) , Michael P. Frank

37 Tautologies and Contradictions
A tautology is a compound proposition that is true no 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. 2018/11/19 (c) , Michael P. Frank

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

39 Proving Equivalence via 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 2018/11/19 (c) , 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. 2018/11/19 (c) , 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) 2018/11/19 (c) , 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 ≡ T p  p ≡ F Augustus De Morgan ( ) 2018/11/19 (c) , 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) 2018/11/19 (c) , 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. 2018/11/19 (c) , 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. 2018/11/19 (c) , 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.) 2018/11/19 (c) , 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 … 2018/11/19 (c) , 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)? 2018/11/19 (c) , 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. 2018/11/19 (c) , 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 any number x, P(x) is true” instead of (0+1>0)  (1+1>1)  (2+1>2)  ... Two types: universal quantification and existential quantification. 2018/11/19 (c) , Michael P. Frank

51 Quantifier Quantifiers provide a notation to quantify (count) how many objects satisfy a given predicate. “” is the FORLL or universal quantifier. x P(x) means for all x in the u.d., P holds. “” is the XISTS or existential quantifier. x P(x) means there exists an x in the u.d. (that is, 1 or more) such that P(x) is true. 2018/11/19 (c) , Michael P. Frank

52 The Universal Quantifier 
Discrete Mathematics and its Applications 2018/11/19 The Universal Quantifier  Example: Let the u.d. of x be parking spaces at TCU. Let P(x) be the predicate “x is full.” Then the universal quantification of P(x), x P(x), is the proposition: “All parking spaces at TCU are full.” i.e., “Every parking space at TCU is full.” i.e., “For each parking space at TCU, that space is full.” Instructors: You can substitute your favorite overly-crowded destination in place of the University of Florida in this example. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

53 The Existential Quantifier 
Example: Let the u.d. of x be parking spaces at TCU. Let P(x) be the predicate “x is full.” Then the existential quantification of P(x), x P(x), is the proposition: “Some parking space at TCU is full.” “There is a parking space at TCU that is full.” “At least one parking space at TCU is full.” 2018/11/19 (c) , Michael P. Frank

54 Free and Bound Variables
An expression like P(x) is said to have a free variable x (meaning, x is undefined). A quantifier (either  or ) operates on an expression having one or more free variables, and binds one or more of those variables, to produce an expression having one or more bound variables. 2018/11/19 (c) , Michael P. Frank

55 Example of Binding y x P(x,y) has 2 free variables, x and y.
x P(x,y) has 1 free variable, and one bound variable. [Which is which?] “P(x), where x=3” is another way to bind x. An expression with zero free variables is a bona-fide (actual) proposition. An expression with one or more free variables is still only a predicate: x P(x,y) y x 2018/11/19 (c) , Michael P. Frank

56 Negations Let x P(x) be the statement of
“Every student in the class has taken a course in calculus”, where P(x) is “x has taken a course in calculus” What is its negation? x P(x)  x P(x) ≡  x P(x)   x Q(x) ≡  x Q(x) 2018/11/19 (c) , Michael P. Frank

57 Translating from English into Logical Expressions
Express “Every student in this class has studied calculus” using predicates and quantifiers. Solution1: Let C(x) be the predicate of “x has studied calculus”. Assume universe of disclosure of x consists of the students in the class. It’s x C(x) 2018/11/19 (c) , Michael P. Frank

58 Translating from English into Logical Expressions(continued)
Solution2: If the u.d. is all people. Let S(x) be the predicate of “x is in this class”. The solution is x S(x)  C(x). [Why not x S(x)  C(x) ? ] Solution3: We concern about other subjects. Let Q(x,y) be the predicate of “student x has studied subject y”. The solution is x ( S(x)  Q(x, Calculus)). 2018/11/19 (c) , Michael P. Frank

59 Review: Predicate Logic (§1.3)
Objects x, y, z, … Predicates P, Q, R, … are functions mapping objects x to propositions P(x). Multi-argument predicates P(x, y). Quantifiers: [x P(x)] :≡ “For all x’s, P(x).” [x P(x)] :≡ “There is an x such that P(x).” Universes of discourse, bound & free vars. 2018/11/19 (c) , Michael P. Frank

60 Nested Quantifiers (§1.4)
Example: Let the u.d. of x & y be people. Let L(x,y)=“x likes y” (a predicate with 2 free variables) Then y L(x,y) = “There is someone whom x likes.” (A predicate with 1 free variable, x) Then x (y L(x,y)) = “Everyone has someone whom they like.” (A __________ with ___ free variables.) Proposition 2018/11/19 (c) , Michael P. Frank

61 Quantifier Exercise If R(x,y)=“x relies upon y,” express the following in unambiguous English: x(y R(x,y))= y(x R(x,y))= x(y R(x,y))= y(x R(x,y))= x(y R(x,y))= Everyone has someone to rely on. There’s a poor overburdened soul whom everyone relies upon (including himself)! There’s some needy person who relies upon everybody (including himself). Everyone has someone who relies upon them. Everyone relies upon everybody, (including themselves)! 2018/11/19 (c) , Michael P. Frank

62 Natural language is ambiguous!
“Everybody likes somebody.” For everybody, there is somebody they like, x y Likes(x,y) or, there is somebody (a popular person) whom everyone likes? y x Likes(x,y) “Somebody likes everybody.” Same problem: Depends on context, emphasis. [Probably more likely.] 2018/11/19 (c) , Michael P. Frank

63 Still More Conventions
Sometimes the universe of discourse is restricted within the quantification, e.g., x>0 P(x) is shorthand for “For all x that are greater than zero, P(x).” =x (x>0  P(x)) x>0 P(x) is shorthand for “There is an x greater than zero such that P(x).” =x (x>0  P(x)) 2018/11/19 (c) , Michael P. Frank

64 More to Know About Binding
x x P(x) - x is not a free variable in x P(x), therefore the x binding isn’t used. (x P(x))  Q(x) - The variable x is outside of the scope of the x quantifier, and is therefore free. Not a proposition! (x P(x))  (x Q(x)) – This is legal, because there are 2 different x’s! 2018/11/19 (c) , Michael P. Frank

65 Quantifier Equivalence Laws
Discrete Mathematics and its Applications 2018/11/19 Quantifier Equivalence Laws Definitions of quantifiers: If u.d.=a,b,c,… x P(x)  P(a)  P(b)  P(c)  … x P(x)  P(a)  P(b)  P(c)  … From those, we can prove the laws: x P(x)  x P(x) x P(x)  x P(x) Which propositional equivalence laws can be used to prove this? (Chalkboard.) Another way to see why the order of quantifiers matters is to expand out the definitions of FORALL and EXISTS in terms of AND and OR. For example, suppose the universe of discourse just consists of two objects a and b. Now, consider some predicate P(x,y). Then, FORALL x EXISTS y P(x,y)  (EXISTS y P(a,y)) /\ (EXISTS y P(b,y))  (P(a,a) \/ P(a,b)) /\ P(b,a) \/ P(b,b)). In contrast, EXISTS y FORALL x P(x,y)  (FORALL x P(x,a)) \/ (FORALL x P(x,b))  (P(a,a) /\ P(b,a)) \/ (P(a,b) /\ P(b,b)). To see that these two are inequivalent, suppose only P(a,a) and P(b,b) are true. Then, the first proposition (with the FORALL first) is true, but, the second proposition (with the EXISTS first) is true. Students can come up with this counterexample in-class as an exercise. DeMorgan's 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

66 More Equivalence Laws x y P(x,y)  y x P(x,y) x y P(x,y)  y x P(x,y) x (P(x)  Q(x))  (x P(x))  (x Q(x)) x (P(x)  Q(x))  (x P(x))  (x Q(x)) Exercise: See if you can prove these yourself. What propositional equivalences did you use? 2018/11/19 (c) , Michael P. Frank

67 More Notational Conventions
Quantifiers bind as loosely as needed: parenthesize x P(x)  Q(x) Consecutive quantifiers of the same type can be combined: x y z P(x,y,z)  x,y,z P(x,y,z) or even xyz P(x,y,z) All quantified expressions can be reduced to the canonical alternating form x1x2x3x4… P(x1, x2, x3, x4, …) ( ) 2018/11/19 (c) , Michael P. Frank

68 Defining New Quantifiers
As per their name, quantifiers can be used to express that a predicate is true of any given quantity (number) of objects. Define !x P(x) to mean “P(x) is true of exactly one x in the universe of discourse.” !x P(x)  x (P(x)  y (P(y)  y x)) “There is an x such that P(x), where there is no y such that P(y) and y is other than x.” 2018/11/19 (c) , Michael P. Frank

69 Some Number Theory Examples
Discrete Mathematics and its Applications 2018/11/19 Some Number Theory Examples Let u.d. = the natural numbers 0, 1, 2, … “A number x is even, E(x), if and only if it is equal to 2 times some other number.” x (E(x)  (y x=2y)) “A number is prime, P(x), iff it’s greater than 1 and it isn’t the product of two non-unity numbers.” x (P(x)  (x>1  yz x=yz  y1  z1)) Note we can even use quantifier expressions to define concepts like even-ness and prime-ness. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

70 Goldbach’s Conjecture (unproven)
Discrete Mathematics and its Applications 2018/11/19 Goldbach’s Conjecture (unproven) Using E(x) and P(x) from previous slide, E(x>2): P(p),P(q): p+q = x or, with more explicit notation: x [x>2  E(x)] → p q P(p)  P(q)  p+q = x. “Every even number greater than 2 is the sum of two primes.” The notation in the top part may look confusing at first but it is actually unambiguous. After FORALL we must have the name of a variable. The following term has 1 free variable x, so we assume that variable comes after the FORALL. Then, the expression E(x>2) becomes a predicate that restricts the universe of discourse. E() is only a predicate if it contains a free variable; the only free variable within it is x so we translate E(x>2) as E(x) /\ x>2. This then is the predicate that must be true of an item in the universe of discourse in order for the rest of the expression to apply to it. Similarly, P(p) and P(q) translate to both free variables p and q after the EXISTS and to conjoined propositions about p and q. Alternatively, the whole expression could also be written FORALL E(x)>2 EXISTS p+q=x, P(p), P(q). Or of course in many other equivalent forms. Due to Goedel’s theorem, as far as we know right now, it is entirely possible that Goldbach’s conjecture could be perfectly true for the universe of all natural numbers from 0 to infinity, yet, there might be absolutely NO finite-length proof of this conjecture from the basic axioms of number theory. On the other hand, it might have a proof that is finite but extremely long, or even possibly a relatively short one that we just haven’t been lucky enough to discover yet. 2018/11/19 (c) , Michael P. Frank (c) , Michael P. Frank

71 Calculus Example One way of precisely defining the calculus concept of a limit, using quantifiers: 2018/11/19 (c) , Michael P. Frank

72 Deduction Example Definitions: s :≡ Socrates (ancient Greek philosopher); H(x) :≡ “x is human”; M(x) :≡ “x is mortal”. Premises: H(s) Socrates is human. x H(x)M(x) All humans are mortal. 2018/11/19 (c) , Michael P. Frank

73 Deduction Example Continued
Some valid conclusions you can draw: H(s)M(s) [Instantiate universal.] If Socrates is human then he is mortal. H(s)  M(s) Socrates is inhuman or mortal. H(s)  (H(s)  M(s)) Socrates is human, and also either inhuman or mortal. (H(s)  H(s))  (H(s)  M(s)) [Apply distributive law.] F  (H(s)  M(s)) [Trivial contradiction.] H(s)  M(s) [Use identity law.] M(s) Socrates is mortal. 2018/11/19 (c) , Michael P. Frank

74 Another Example Definitions: H(x) :≡ “x is human”; M(x) :≡ “x is mortal”; G(x) :≡ “x is a god” Premises: x H(x)  M(x) (“Humans are mortal”) and x G(x)  M(x) (“Gods are immortal”). Show that x (H(x)  G(x)) (“No human is a god.”) 2018/11/19 (c) , Michael P. Frank

75 The Derivation x H(x)M(x) and x G(x)M(x).
x M(x)H(x) [Contrapositive.] x [G(x)M(x)]  [M(x)H(x)] x G(x)H(x) [Transitivity of .] x G(x)  H(x) [Definition of .] x (G(x)  H(x)) [DeMorgan’s law.] x G(x)  H(x) [An equivalence law.] 2018/11/19 (c) , Michael P. Frank

76 End of §1.3-1.4, Predicate Logic
From these sections you should have learned: Predicate logic notation & conventions Conversions: predicate logic  clear English Meaning of quantifiers, equivalences Simple reasoning with quantifiers Upcoming topics: Introduction to proof-writing. Then: Set theory – a language for talking about collections of objects. 2018/11/19 (c) , Michael P. Frank


Download ppt "Module #1: Foundations of Logic"

Similar presentations


Ads by Google