Presentation is loading. Please wait.

Presentation is loading. Please wait.

6/20/2018 Discrete Math A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different.

Similar presentations


Presentation on theme: "6/20/2018 Discrete Math A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different."— Presentation transcript:

1 6/20/2018 Discrete Math A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different paces, rather than dividing the material up into fixed-length lectures, we will divide it up into “modules” which correspond to major topic areas and will generally take 1-3 lectures to cover. Within modules, we have smaller “topics”. Within topics are individual slides. 6/20/2018

2 Part #1: The Fundamentals of Logic
6/20/2018 Part #1: The Fundamentals of Logic 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.

3 Part #1: Foundations of Logic
6/20/2018 Part #1: Foundations of Logic Mathematical Logic is a tool for working with compound statements.

4 Foundations of Logic: Overview Section 1.1: Logic
6/20/2018 Foundations of Logic: Overview Section 1.1: Logic Propositional logic: It deals with propositions. Predicate logic: it deals with predicates.

5 Definition of a Proposition
6/20/2018 Topic #1 – Propositional Logic Definition: A proposition (denoted p, q, r, …) is a statement (i.e., a declarative sentence) having a truth value that’s either true (T) or false (F) .But it is never both, neither, or somewhere “in between!” Note: (commands and questions are not propositions) definite

6 Examples of Propositions
6/20/2018 Topic #1 – Propositional Logic Examples of Propositions “It is raining.” (In a given situation.) “Amman is the capital of Jordan” “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)

7 Operators / Connectives
6/20/2018 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. 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.)

8 Some Popular Boolean Operators
6/20/2018 Topic #1.0 – Propositional Logic: Operators 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

9 6/20/2018 Topic #1.0 – Propositional Logic: Operators The Negation Operator Definition: Let p be a proposition then ¬p is the nagation of p (Not p , it is not the case that p) E.g. If p = “London is a city.” then ¬p = “London is not a city.” or “ it is not the case that London is a city.” The truth table for NOT: T :≡ True; F :≡ False “:≡” means “is defined as” Operand column Result column

10 The Conjunction Operator
6/20/2018 Topic #1.0 – Propositional Logic: Operators The Conjunction Operator Definition: Let p and q be propositions, the proposition “p AND q” denoted by (p q) is called the conjunction of p and q. E.g. If p=“I will have salad for lunch.” and q=“I will have steak for dinner.”, then pq=“I will have salad for lunch and I will have steak for dinner.” ND Remember: “” points up like an “A”, and it means “ND”

11 Conjunction Truth Table
6/20/2018 Topic #1.0 – Propositional Logic: Operators Conjunction Truth Table Operand columns Note that a conjunction p1  p2  …  pn of n propositions will have 2n rows in its truth table. “AND”,”but”,”in addition to”,”moreover” 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.

12 The Disjunction Operator
6/20/2018 Topic #1.0 – Propositional Logic: Operators The Disjunction Operator Definition: Let p and q be propositions, the proposition “p OR q” denoted by (p  q) is called the disjunction of p and q. p=“My car has a bad engine.” q=“My car has a bad carburetor.” pq=“Either my car has a bad engine, or my car has a bad carburetor.” 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.”

13 Disjunction Truth Table
6/20/2018 Topic #1.0 – Propositional Logic: Operators Disjunction Truth Table Note that pq means that 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. Note difference from AND

14 The Exclusive Or Operator
6/20/2018 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!)”

15 Exclusive-Or Truth Table
6/20/2018 Topic #1.0 – Propositional Logic: Operators Exclusive-Or Truth Table Note that pq means that p is true, or q is true, but not both! This operation is called exclusive or, because it excludes the possibility that both p and q are true. A good way to remember the symbol for XOR, a plus sign inside an O, is to think of XOR as adding the bit-values of its inputs (mod 2). E.g., 0+0=0, 1+0=0, 1+1=0 (mod 2). Thus XOR is basically an addition, and we put it inside an “O” to remind ourselves that it is a type of “Or”. XOR together with unary operators do not form a universal set of operators over the Booleans. However, it turns out that they are a universal set for quantum logic! However we do not have time to cover quantum computing in this class, interesting though it is. Note difference from OR.

16 Natural Language is Ambiguous
6/20/2018 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 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.

17 6/20/2018 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.” For slides that have interactive exercises, it may be a good idea to stop the class for a minute to allow the students to discuss the problem with their neighbors, then call on someone to answer. This will help keep the students engaged in the lecture activity. “The grass was wet this morning, and it 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.”

18 Nested Propositional Expressions
6/20/2018 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) As an exercise, drop the truth tables for f /\ (g \/ s) and (f /\ g) \/ s to see that they’re different, and thus the parentheses are necessary. Precedence conventions such as the one in the second bullet help to reduce the number of parentheses needed in expressions. Note that negation, with its tight binding (high precedence), and with its position to the left of its operand, behaves similarly to a negative sign in arithmetic. There is also a precedence convention that you see sometimes (for example, in the C programming language) that AND takes precedence over OR. However, this convention is not quite universally accepted, not all systems adopt it. Therefore, to be safe, you should always include parentheses whenever you are mixing ANDs and ORs in a single sequence of binary operators.

19 The Implication Operator
6/20/2018 Topic #1.0 – Propositional Logic: Operators The Implication Operator hypothesis conclusion 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 get 100% on the final.” q = “You will get an A” p  q = “If you get 100% on the final, then you will get an A.” 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.” Sometimes the antecedent is called the hypothesis and the consequent is called the conclusion.

20 Implication Truth Table
6/20/2018 Topic #1.0 – Propositional Logic: Operators 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! The only False case! 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.)

21 Examples of Implications
6/20/2018 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? 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.

22 P  Q has many forms in English Language:
"P implies Q" “Q whenever P” " If P, Q" “Q follows from P” "If P, then Q" "P only if Q“ "P is sufficient for Q" "Q if P" "Q is necessary for P" “Q when P"

23 Converse, Inverse, Contrapositive
6/20/2018 Topic #1.0 – Propositional Logic: Operators Converse, Inverse, Contrapositive Some terminology, for an implication p  q: Its converse is: q  p. Its inverse is: ¬p  ¬q. Its contrapositive: ¬q  ¬ p. Also, note that the converse and inverse of p->q also have the same meaning as each other.

24 Biconditional  Truth Table
6/20/2018 Topic #1.0 – Propositional Logic: Operators Biconditional  Truth Table In English: "P if and only if Q" "If P, then Q, and conversely" "P is sufficient and necessary for Q“ Written p  q Also, p IFF q is equivalent to (p -> q) /\ (q -> p). (“/\” being the AND wedge)

25 Translation English Sentences into Logical Expressions
If you are a computer science major or you are not a freshman, P  Q then you can access the internet from campus R is translated to: (P   Q)  R

26 Precedence of Logical operators
1 2 3 4 5

27 (Section1.2)Propositional Equivalence Tautologies and Contradictions
6/20/2018 Topic #1.1 – Propositional Logic: Equivalences (Section1.2)Propositional Equivalence Tautologies and Contradictions A tautology is a compound proposition that is always true. Ex. p  p A contradiction is a compound proposition that is false Ex. p  p Other compound props. are contingencies. Ex. P q

28 Equivalence Laws  Identity: pT  p pF  p
6/20/2018 Topic #1.1 – Propositional Logic: Equivalences Equivalence Laws  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)

29 6/20/2018 Topic #1.1 – Propositional Logic: Equivalences 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 ( )

30 Implications / Biconditional Rules
1. P Q   P  Q 2. (P  Q)  P   Q 3. P Q  Q  P (contrapositive) 4. P  Q  (P Q)  (Q P)

31 Proving Equivalence via Truth Tables
6/20/2018 Topic #1.1 – Propositional Logic: Equivalences Proving Equivalence via Truth Tables Ex. Prove that pq  (p  q). “ De Morgan’s law” TAUTOLOGY

32 Example: 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

33 Section 1.3 Predicates and Quantifiers Predicates
6/20/2018 Topic #3 – Predicate Logic Section 1.3 Predicates and Quantifiers Predicates Example: “x is greater than 3” has two parts: First part: x Second part: the predicate “is greater than 3” SO: x is greater than 3 can be denoted by P(x). Where x is the variable and p denotes >3. P(x): x>3 , let x=4, then P(4) is true. Example: R(x,y,z) : x+y=z then R(1,2,3): 1+2=3 / True

34 Quantifiers Quantification Universal Quantification
Existential Quantification Universes of Discourse (U.D.s) (Domain): collection of all persons, ideas, symbols,………

35 The Universal Quantifier 
x P(x): “ P(x) is true for all/every values of x in the universe of discourse” Example: What is the truth value of x(x2 ≥ x) if: UD is all real numbers- False (0.5) this is called a counterexample If: UD is all integers - True

36 The Existential Quantifier 
6/20/2018 Topic #3 – Predicate Logic The Existential Quantifier   x P(x) : There exists an element x in the universe of discourse such that P(x) is true Example: Let Q(x):x=x+1, UD:all real numbers. the value of  x Q(x) is false for every number x

37 Negations  x P(x) ≡  x  P(x)   x Q(x) ≡ x  Q(x)

38 Translation using Predicates and Quantifiers
“Every student in this class has studied math and C++ course” . UD: students in this class Translated to: x( M(x)  CPP(x)) But if the UD is all people “ For every person x, if x is a student in this class then x has studied math and C++” translated to : x (S(x) M(x)  CPP(x))

39 Example “some student in this class has studied math and C++ course” .
UD: student in this class . Translated to:  x ( M(x)  CPP(x)) But if the UD: all people Translated to:  x (S(x)  M(x)  CPP(x) )

40 Free and Bound Variables
6/20/2018 Topic #3 – Predicate Logic Free and Bound Variables The variable is either bound or free Examples: P(x,y) x and y are free variables x P(x,y) x is bound and y is free “P(x), where x=3” is another way to bind x


Download ppt "6/20/2018 Discrete Math A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different."

Similar presentations


Ads by Google