CS 641 meeting -*- Outline -*- * quantified expressions (Cohen, Ch. 3) Context: Now we study universal and existential quantification. Plan: Cohen makes an interesting abstraction first, generalized expressions, and then specializes to universal and existential quantification In the following, we ``all'' for the universal quantifier, and ``exists'' for the existential quantifier. Note: all the theorems are here from Cohen's book, but it's not useful to just list them. Refer the students to the book or this file, and just work a few of their proofs. ** quantified expressions (3.1, can omit) Contrary to Cohen, we'll indicate dependence explicitly, so when we write R.i, you can see it depends on i, but Z does not. generalization of *symmetric and associative* binary operators doesn't work for, say subtraction or division. ---------------------- QUANIFIED EXPRESSIONS (OP i : R.i : T.i) -- where op is symmetric and associative Examples: (PLUS i : 1 <= i < 4 : i ) = 1 plus 2 plus 3 = 6 (MAX i : 1 <= i < 9 : i+7) = 15 ---------------------- definitions: i is a list of dummies, R.i is the range, T.i is the term (an expression) ranges of true are omitted def: a range is empty if it's false everywhere Q: Why doesn't this work for subtraction? in what follows, the underlining will be left off, due to limitations of ASCII, we'll just capitalize whatever. Cannonical examples: PLUS (summation), TIMES (product), AND (universal quantifier), OR (existential quantifier) other examples would be EQUIV, DIFFS but not implication or consequence *** laws ---------------- LAWS OF QUANTIFIED EXPRESSIONS ---------------- For each law, give concrete example, then law, and apply to universal and existential quantification ---------------- (MAX i : 1<=i<4 : (i+8) max (i+5)) = (1+8) max (1+5) max (2+8) max (2+5) max (2+8) max (2+5) = (1+8) max (2+8) max (2+8) max (1+5) max (2+5) max (2+5) = (MAX i : 1<=i<4 : i+8) max (MAX i : 1<=i<4 : i+5) ---------------- so this generalizes to the ---------------- term rule: (OP i : R.i : P.i op Q.i) = (OP i : R.i : P.i) op (OP i : R.i : Q.i) ----------------- in hints, left to right is called "splitting the term" and right to left is called "joining the term". Q: why is this correct (in terms of the semantics)? example: (AND i : 0<=i<5 : i<7 /\ i<8) equiv (AND i : 0<=i<5 : i<7) /\ (AND i : 0<=i<5 : i<8) ------------------ (MAX i : 1<=i<4 \/ 3<=i<5 : i+6) = (1+6) max (2+6) max (3+6) max (4+6) = (1+6) max (2+6) max (3+6) max (3+6) max (4+6) = (MAX i : 1<=i<4 : i+6) max (MAX i: 3<=i<5 : i+6) ------------------ but what about non-idempotent operators? ------------------ (PLUS i : 1<=i<4 \/ 7<=i<9 : i) = 1 + 2 + 3 + 7 + 8 = (PLUS i : 1<=i<4 : i) + (PLUS i: 7<=i<9 : i) but (PLUS i : i<=i<4 \/ 3<=i<5 : i) = 1 + 2 + 3 + 4 ? 1 + 2 + 3 + 3 + 4 = (PLUS i : i<=i<4 : i) + (PLUS i : 3<=i<5 : i)? ------------------ so we have... ------------------ range rule: if op is idempotent (i.e., for all P, P op P = P), or P.i diffs Q.i for all i, (OP i : P.i \/ Q.i : T.i) = (OP i : P.i : T.i) op (OP i : Q.i : T.i) ------------------ in hints, "splitting the range", "joining the range" Q: Are conjuction and disjunction idempotent? So example: (AND i : P.i \/ Q.i : T.i) equiv (AND i : P.i : T.i) /\ (AND i : Q.i : T.i) because conjunction is idempotent But only works for + if P.i diffs Q.i for all i ------------------ (MAX i : 1<=i<4 : 5*i) = 5*1 max 5*2 max 5*3 = <* distributes over max> 5 * (1 max 2 max 3) = 5 * (MAX i : 1<=i<4 : i) distributivity: if * distributes over op, and the range is non-empty, (OP i : R.i : Z * T.i) = Z * (OP i : R.i : T.i) ------------------ Recall, can move Z out because it doesn't depend on i Q: does conjunction distribute over disjunction? vice versa? yes, so for example (AND i : R.i : Z \/ Q.i) = Z \/ (AND i : R.i : Q.i) ----------------- (PLUS i : false : i+7) = 0 (TIMES i : false : i+7) = 1 (MAX i : false : i+7) = -infinity empty range rule: if op has a unit, 1_op, (OP i : false : T.i) = 1_op ----------------- Recall that a unit is x such that P op x = P (as for multiplication) Q: What's the unit of conjunction? true, so (AND i : false : T.i) = true for disjunction the unit is false, so (OR i : false : T.i) = false ---------------- (MAX i: 1<=i<4 : 641) = 641 constant term rule: if op is idempotent, and the range is non-empty, (OP i: R.i : Z) = Z ----------------- Q: So what is (AND i : 1 <= i < 27 : true)? Q: how about (OR i : 1 <= i < 27 : false)? note this latter works even if the range is empty A trick question... Q: How about (EQUIV i : 1 <= i < 5 : false)? false equiv false equiv false equiv false equiv < P equiv P equiv true, twice > true equiv true equiv < P equiv P equiv true> true why did that happen? --------------- (MAX i : 1<=i<4 : i) = 1 max 2 max 3 = (MAX i : 0<=j /\ j<3 : j+1) = (MAX i : 1<=j+1 /\ j+1<4 : j+1) = (MAX i : 1<=j+1<4 : j+1) dummy transformation rule: if f is invertible (i.e., i neq j equiv f.i neq f.j), (OP i : R.i : T.i) = (OP j : R.(f.j) : T.(f.j)) ---------------- Note: assumes by the notation, j does not appear in R.i or T.i invertability of f is needed to convert the one into the other. Remark, this allows renaming, see below. -------------- nesting rule: (OP i : P.i : (OP j : Q.i.j : T.i.j)) = (OP i,j : P.i /\ Q.i.j : T.i.j) -------------- from left to right this is called "nesting", from right to left this is called "unnesting". ------------- (MAX i : i = 3 : i+4) = 3+4 1-point rule: if T.Z is defined (OP i : i = Z : T.i) = T.Z -------------- Recall that by the notation, Z does not depend on i Q: why does T.Z have to be defined? *** theorems Thm (renaming the dummy): if j is not free in R or T, (OP i : R.i : T.i) = (OP j : R.j : T.j) Thm (generalized distributivity): if * distributes over op, and either the range, R.i, is non-empty or the unit of op is the same as the unit of *, then (OP i : R.i : Z * T.i) = Z * (OP i : R.i : T.i) ** Universal quantification (3.2) this is generalized conjuction The only additional thing that doesn't follow from the general theory is "trading" below. Also note "instantiation". ---------------- UNIVERSAL QUANTIFICATION (all i : R.i : T.i) term rule: (all i : R.i : P.i /\ Q.i) equiv (all i : R.i : P.i) /\ (all i : R.i : Q.i) ----------------- in hints, left to right is called "splitting the term" and right to left is called "joining the term". (Dijkstra calls this rule "all distributes over /\") Q: why is this correct? ------------------ range rule: (all i : P.i \/ Q.i : T.i) equiv (all i : P.i : T.i) /\ (all i : Q.i : T.i) ------------------ in hints, left to right is "splitting the range", right to left is "joining" ------------------ conjunction distributes over universal quantifier with non-empty range: if the range is non-empty, (all i : R.i : Z /\ T.i) equiv Z /\ (all i : R.i : T.i) disjunction distributes over universal quantifier: (all i : R.i : Z \/ T.i) equiv Z \/ (all i : R.i : T.i) ------------------ the latter follows from generalized distributivity (why?) ----------------- empty range rule: (all i : false : T.i) equiv true ----------------- Q: What's the unit of conjunction? true, so (AND i : false : T.i) = true ---------------- constant term rule: if the range is non-empty, (all i : R.i : Z) equiv Z ----------------- recall that conjunction is idempotent --------------- dummy transformation rule: if f is invertible (i.e., i neq j equiv f.i neq f.j), (all i : R.i : T.i) = (all j : R.(f.j) : T.(f.j)) ---------------- Note: assumes by the notation, j does not appear in R.i or T.i invertability of f is needed to convert the one into the other. -------------- nesting rule: (all i : P.i : (all j : Q.i.j : T.i.j)) = (all i,j : P.i /\ Q.i.j : T.i.j) -------------- from left to right this is called nesting, from right to left this is called unnesting. ------------- 1-point rule: if T.Z is defined, (all i : i = Z : T.i) = T.Z -------------- Recall that by the notation, Z does not depend on i Q: why does T.Z have to be defined? Thm: implication distributes over universal quantification. (all i : R.i : Z ==> T.i) equiv Z ==> (all i : R.i : T.i) --------------- trading: (all i : R.i : T.i) equiv (all i :: ~R.i \/ T.i) --------------- this needs to be postulated, as it doesn't follow from above. Gives meaning to the range. Thm (trading): (all i : R.i /\ S.i : T.i) equiv (all i : R.i : S.i ==> T.i) Thm (instantiation): (all i :: f.i) ==> f.x ** existential quantification (3.3) generalized disjunction The only additional thing that doesn't follow from the general theory is "trading" below. Also note "instantiation". --------------- EXISTENTIAL QUANTIFICATION (exists i : R.i : T.i) postulate (Generalized De Morgan): (exists i : R.i : T.i) equiv ~(all i : R.i : ~T.i) --------------- From this postulate, rules similar to the above follow. Thm (term rule): (exists i : R.i : P.i \/ Q.i) equiv (exists i : R.i : P.i) \/ (exists i : R.i : Q.i) Thm (range rule): (exists i : P.i \/ Q.i : T.i) equiv (exists i : P.i : T.i) \/ (exists i : Q.i : T.i) Thm (disjunction distributes over existentials with non-empty range): If the range is non-empty, then (exists i : R.i : Z \/ T.i) equiv Z \/ (exists i : R.i : T.i) Thm (conjunction distributes over existentials): (exists i : R.i : Z /\ T.i) equiv Z /\ (exists i : R.i : T.i) Thm (empty range rule): (exists i : false : T.i) equiv false Thm (constant term rule): If the range is non-empty, then (exists i: R.i : Z) equiv Z Thm (dummy transformation rule): If f is invertible (i.e., i neq j equiv f.i neq f.j), (exists i : R.i : T.i) equiv (exists j : R.(f.j) : T.(f.j)) Thm (nesting rule): (exists i : P.i : (exists j : Q.i.j : T.i.j)) equiv (exists i,j : P.i /\ Q.i.j : T.i.j) Thm (1-point rule): if T.Z is defined, then (exists i : i equiv Z : T.i) equiv T.Z Thm (dual of Generalized De Morgan): ~(exists i : R.i : ~T.i) equiv (all i : R.i : T.i) Thm (rule of instantiation): f.x ==> (exists i :: f.i) Q: Consider the following "rules", which are the converses to the rules of instantiation. p.x ==> (all x :: p.x) {universal generalization} (exists x :: q.x) ==> q.x {existential specialization} Using them, can you "prove" a contradiction? The existential one is really bad, the universal one is okay if x is fresh, and if used in a meta-mathematical way (do the proof for x, conclude holds for all x) Thm (trading): (exists i : R.i : T.i) equiv (exists i :: R.i /\ T.i) ** Arithmetic quantifications Summation is generalized plus. Numerical quantification is defined by the following (N i : R.i : T.i) = (PLUS i : R.i /\ T.i : 1) so it's the number of things such that R.i and T.i are true.