Review for Midterm 1 Andreas Klappenecker
Topics Chapter 1: Propositional Logic, Predicate Logic, and Inferences Rules Chapter 2: Sets, Functions (Sequences), Sums Chapter 3: Asymptotic Notations and Complexity of Algorithms Ruby - but it will not be on the test
Chapter 1 Propositional Logic (true, false; and, or, not, conditional, biconditional; logical equivalence, tautology, satisfiability) Predicate Logic (all of the above plus predicates and quantifiers) Rules of Inference (modus ponens, modus tollens, etc.)
Grammar of Prop formula ::= formula ( formula formula ) ( formula formula ) ( formula formula ) ( formula formula ) ( formula formula ) symbol
Propositional Logic
Semantics Let B={t,f}. Assign to each connective a function M: B->B that determines its semantics. y if P M (P ) f t t f is false. P Q M (P, Q) M (P, Q) M (P, Q) M (P, Q) M (P, Q) f f f f f t t f t f t t t f t f f t t f f t t t t f t t
Summary Summary. Informally, we can summarize the meaning of the connectives as follows: 1) The and connective (a b) is true if and only if both a and b are true. 2) The or connective (a b) is true if and only if at least one of a, b is true. 3) The exclusive or (a b) is true if and only if precisely one of a, b is true. 4) The implication (a b) is false if and only if the premise a is true and the conclusion b is false. 5) The biconditional connective (a b) is true if and only if the truth values of a and b are the same. An interpretation of a subset S of Prop is an assignment of truth values to all variables that occur in the propositions contained in S. We showed that there exist a unique valuation extending an interpretation of all propositions.
Valuations A valuation v : Prop B is a function that assigns a truth value to each proposition in Prop such that V1. v a = M (va) V2. v(a b) = M (va,vb) V3. v(a b) = M (va,vb) V4. v(a b) = M (va,vb) V5. v(a b) = M (va,vb) V6. v(a b) = M (va,vb) holds for all propositions a and b in Prop. The properties V1 V6 ensure that the valuation respects the meaning of the connectives. We can restrict a valuation v to a subset of the set of proposition. If A and B are subsets of Prop such that A B, and v A : A B and v B : B B are valuations, then v B is called an extension of the valuation v A if and only if v B coincides with v A when restricted to A. The consistency conditions V1-V6 are quite stringent, as the next theorem
Tautology, Satisfiability,... Two predicates p and q are logically equivalent if and only if v[[p]] = v[[q]] holds for all valuations v. A predicate p is called a tautology if and only if v[[p]]=t holds for all valuations v A predicate p is called satisfiable if and only if v[[q]]=t for some valuation v.
Predicate Logic
Predicates A function P from a set D to the set Prop of propositions is called a predicate. The set D is called the domain of P. Example: Let D=Z be the set of integers. Let a predicate P: Z -> Prop be given by P(x) = x>3. The predicate itself is neither true or false. However, for any given integer the predicate evaluates to a truth value. P(4) is true P(2) is false
Universal Quantifier (1) Let P be a predicate with domain D. The statement P(x) holds for all x in D can be written shortly as xp(x)
Existential Quantifier The statement P(x) holds for some x in the domain D can be written as x P(x) Example: x (x>0 x 2 = 2) is true if the domain is the real numbers but false if the domain is the rational numbers.
Logical Equivalence (1) Two statements involving quantifiers and predicates are logically equivalent if and only if they have the same truth values no matter which predicates are substituted into these statements and which domain is used. We write A B for logically equivalent A and B.
De Morgan s Laws xp (x) x P (x) xp (x) x P (x) (p q) p q (p q) p q
Example x(p (x) Q(x)) x(p (x) Q(x)) Proof: x(p (x) Q(x)) x (P (x) Q(x)) x ( P (x) Q(x)) x( P (x) Q(x) x(p (x) Q(x))
Rules of Inference
Valid Arguments An argument in propositional logic is a sequence of propositions that end with a proposition called conclusion. The argument is called valid if the conclusion follows from the preceding statements (called premises). In other words, in a valid argument it is impossible that all premises are true but the conclusion is false.
Modus Ponens The tautology (p (p->q)) -> q is the basis for the rule of inference called modus ponens. p p -> q ------- q
Modus Tollens q p -> q ------ p The University will not close on Wednesday. If it snows on Wednesday, then the University will close. Therefore, It will not snow on Wednesday
Simplification p q ------ p
Formal Argument p q r p r s s t t
Formal Argument Argument p q r p r s s t t 1) p q Hypothesis 2) p Simplification of 1) 3) r p Hypothesis 4) r Modus tollens using 2) and 3) 5) r s Hyposthesis 6) s Modus ponens using 4), 5) 7) s t Hypothesis 8) t Modus ponens using 6), 7)
Functions, Sets, Sums
<< Work out on board >> Example
Big Oh, etc.
Big Oh Notation Let f,g: N -> R be functions from the natural numbers to the set of real numbers. We write f O(g) if and only if there exists some real number n 0 and a positive real constant U such that f(n) <= U g(n) for all n satisfying n >= n 0
Big Ω We define f(n) = Ω(g(n)) if and only if there exists a constant L and a natural number n 0 such that L g(n) <= f(n) holds for all n >= n 0. In other words, f(n) = Ω(g(n)) if and only if g(n) = O(f(n)).
Example In Analysis of Algorithms, you will learn that any comparison based sorting algorithm needs at least Ω(n log n) comparisons. Mergesort needs O(n log n) comparisons, so this is essentially an optimal sorting algorithm.
Big Θ We define f(n) = Θ(g(n)) if and only if there exist constants L and U and a natural number n 0 such that L g(n) <= f(n) <= U g(n) holds for all n >= n 0. In other words, f(n) = Θ(g(n)) if and only if f(n) = Ω(g(n)) and f(n) = O(g(n)).