0% found this document useful (0 votes)
275 views

CS103 Midterm 1 Reference Sheet

This document contains information about logic and proofs including: 1) Definitions of logical operators such as negation, implication, biconditional, existential and universal quantifiers. 2) Examples of propositional logic statements like "All As are Bs" and how to negate them. 3) Rules for logical proofs including proof by contradiction and contrapositive. 4) Examples of mathematical proofs, such as proving a squared sum of rational numbers is rational. 5) Discussion of operator precedence and De Morgan's laws.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
275 views

CS103 Midterm 1 Reference Sheet

This document contains information about logic and proofs including: 1) Definitions of logical operators such as negation, implication, biconditional, existential and universal quantifiers. 2) Examples of propositional logic statements like "All As are Bs" and how to negate them. 3) Rules for logical proofs including proof by contradiction and contrapositive. 4) Examples of mathematical proofs, such as proving a squared sum of rational numbers is rational. 5) Discussion of operator precedence and De Morgan's laws.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS103 Negations:

If n is an even number, then n² is an even no Parentheses show scope ∃x ∈ N. (...) p ↔ q: (p^q) ∨ ¬(p ∨ q) Midterm 1 Predict: 1. ∀p. (Person(p) → ∃c. (Cat(c) ∧ Loves(p,
Antecedent Consequent e.g. ∀n. (n ∈ N→(Even(n) p ∨ q: ¬(¬p ^ ¬q) An elem may be a set, might need c) ∧ ∀r. (Robot(r) → ¬Loves(c, r)) ) )
Proposition: a statement that is either ↔Even(n²))) ⊤: ⊥→⊥ to take elem of elem x. where x ∃p. (Person(p) ∧
true or false. e.g. n is an integer ∃ is paired with ∧ and ∀ is ¬p: p→⊥ ∈ A. ∀c. (¬Cat(c) \/ ¬Loves(p,c) \/ ∃r. (Robot(r)
Negation of a proposition that is always paired with → p ∧ q: (p→q→⊥)→⊥ ∧ Loves(c,r)) ) )
true whenever X if false & false when x is
¬(A→B) = A ∧ ¬B CHECK RIGHT ASSOCIATIVE 2. (∀x. (Person(x) ↔ ∃r. (Robot(r) ∧
true. (e.g. N(x<3) = x>=3. Negation of
¬(A↔B) = ¬A↔B or A↔¬B “There is a set S where every element ¬(p→q→r) = ¬(p→(q→r)) !!! Loves(x, r)))) → (∀r. ∀c. (Robot(r) ∧ Cat(c)
Existential Statements: universal
Remember DOT after ∀x. or ∃x ∈ S. of S is also a subset of S”:∅. because → Loves(r, c)))
statement. (there is no P that is Q) ∃ p ∧ ¬(q→r) = p ∧ q ∧ ¬r
SETS: ∀x (x∈ S→x⊆S). Satisfied as (∀x. (Person(x) ↔ ∃r. (Robot(r) ∧ Loves(x,
Universal Statements: existential ¬(A∧B) = A →¬B
¬∀x. A = ∃x. ¬A r)))) ∧ (∃r. ∃c. ((Robot(r) ^ Cat(c)) ^
statement. (there is a P that is not Q that F->F=T.
¬∃x. A = ∀x. ¬A
disproves it) ∀ And {∅}, {∅, {∅}} ¬Loves(r, c)))
¬∀x ∈ S. A = ∃x ∈ S. ¬A Negate Biconditional
Implication: For every x, if P(x) is true,
¬∃x ∈ S. A = ∀x ∈ S. ¬A 3. ∀c. (Cat(c) → ∃r. (Robot(r) ∧ ∀x.
then Q(x) is true. (there is an x where P(x) The Aristotelian Forms: ¬( ((p∧q)∨r) ↔ ((q∨r)→p))
Focus that all rational numbers: p/q (Loves(c, x) ↔ r = x) ) )
is true and Q(x) is false) “All As are Bs” : ∀x. (A(x)→B(x)) ¬A↔B and A↔¬B. REVERSE
where q≠0 ∃c. (Cat(c) ∧ (∀r. (¬Robot(r) \/ ∃x.
Proof by contrapositive: “Some As are Bs” : ∃x. (A(x)∧B(x)) ORDER, so easier
(Loves(c,x) ↔ r ≠ x) ) ))
P->Q : N(Q) -> N(P) “No As are Bs” : ∀x. (A(x)→¬B(x)) ( (p∧q)∨r) ↔ (q∨r) ∧ ¬p )
Biconditional: P if and only if Q “Some As aren’t Bs”: ∃x. (A(x)∧¬B(x)) Pick arbitrary rational numbers a and b. 4. ∃x. (Cat(x) ∧ (∀r. (Loves(r, x) →
P->Q and Q->P need to be proven We want to show that a²+b² is rational. Robot(r)) ∨ ∀p. (Loves(p, x) → Person(p))) )
Proof by Contradiction: assume “Every person loves someone else” ∀x(¬Cat(x) ∨ (∃r. ( Loves(r,x) ∧ ¬Robot(r)))
Since a is rational, we know there exist Thm: For all sets A and B, if A ⊆
consequent is false, show that is not ∀p. (Person(p)→ ∧ ∃p. (Loves(p,x) ∧ ¬Person(p)) )
integers p and q such that a=p/q, and B, then ℘(A ∪ B) ⊆ ℘(B). Prf:
possible. Conclude we must know it’s ∃s. (Person(s) ∧ (s≠p) ∧ Loves(p,s)) ) This but not that:
q≠0. Similarly, since b is rational, we Pick arbitrary sets A and B where
true. (¬p→⊥) → p “There is a person that everyone else loves” ∀y. ∃x. Loves(x, y), but not ∃x. ∀y.
∃p. (Person(p) ∧ know there exist integers s and t such A ⊆ B. We want to show that ℘(A Loves(x, y): Empty world
(∀q. (Person(s) ∧ (q≠p) → Loves(q,p))) ) that b=s/t, and t≠0. We can substitute ∪ B) ⊆ ℘(B). First, we will show ∀x. (Person(x) ∨ Cat(x)), but not (∀x.
“The empty set exists” these into the sum of squares of and as that since A ⊆ B, A ∪ B = B. By Person(x)) ∨ (∀x. Cat(x)): Cat(A); Person(B)
∃S. (Set(S) ∧ ∀x. (x∉S) ) follows: a²+b²= (p²t²+s²q²) / q²t². So we the definition of the union (∃x. Robot(x)) ∧ (∃x. Loves(x, x)), but not
see that a²+b² can be written as c/d, operator, every element of B is an
Operator Precedence ∃x. (Robot(x) ∧ Loves(x, x))
where c=p²t²+s²q² and d=q²t². We element of A ∪ B. Now, we show
1. ¬ 1 is highest Robot(A); Person(B); Loves(B,B)
2. ∧ further observe that because p,q,s,t ∈ that ev- ery element of A∪B is an (∀x. Cat(x)) → (∀y. Loves(y, y)), but not ∀x.
3. ∨ Associate Z, and integers are closed under element of B. Consider an ∀y. (Cat(x) → Loves(y, y))
4. → right most addition and multiplication, then . arbitrary element x ∈ A∪B. Cat(A); Person(B)
5. ↔ first Finally, because q≠0 and t≠0, d≠0. So There are two possibilities: Case ∃x. (Robot(x) → ∀y. Robot(y)), but not (∀x.
“p if q” = q→p. “but” = “and” a²+b² is rational. 1: x ∈ A. Since A ⊆ B, x ∈ B. Robot(x)) ∨ (∀x. ¬Robot(x))
De Morgan’s Law: Case 2: x ∈ B. In either case, x
¬(p∧q) = p→¬q ¬(p→q) = Robot(A); Person(B)
¬(p→q) = p∧¬q Y(p,q,r): T,T,F,…,F,T:
p∧¬q ∈ B, so (A ∪ B) ⊆ B. Since (A # set true statement antecedent to false (there
(p→q) = ¬p∨q Y(p,q,r) = (p∧q) ∨ (¬p∧¬q∧¬r)
Negate “there exists a puppy who is ∪ B) ⊆ B and B ⊆ (A ∪ B), we exists a no robot)
First-order Logic ¬p = Y(⊥,⊥,p)
predicates: describe properties cute. see that A ∪ B = B. Thus, ℘(A ∪ Translating into Logic
¬(∃x. (Puppy(x) ∧ Cute(x))) = p→q = Y(Y(⊥,⊥,p) ,Y(⊥,⊥,p) ,Y(⊥, B) = ℘(B). Since every set is a
of objects (function that returns "Robots do not love."
bool) ∀x. (Puppy(x)→¬Cute(x)) (If puppy, ⊥,q)) subset of itself, ℘(A ∪ B) ⊆ ℘(B), ∀x. (Robot(x) → ¬(∃y (Loves(x,y))))
functions: map objects to one cannot be cute) is easier to read than as required. "Each robot loves every cat, but no cat loves
another ∀x. (¬Puppy(x)∨¬Cute(x))
Expressing Uniqueness: any person."
Quantifiers allow us to reason ∃a. ((WaytoFindOut(a) ∧ ¬(∃b. (WaytoFindOut(b) ∧ (a≠b))))
(∀x. (∀y. (Robot(x) /\ Cat(y) → Loves(x,y))))
about multiple objects = ∃w. ((WaytoFindOut(a) ∧
Connections work on predicates ∀x. (WaytoFindOut(b) → (a=b)) ) /\ ¬(∃x. (∃y. ((Cat(x) /\ Person(y)) /\
(∧,¬,→,...) Loves(x,y))))
Contradiction Sandwich: contradiction, prove using same
Equality: (a special predicate) method as without contradiction reached and reverse. "Each cat only loves itself."
states whether 2 objects are ∀x. (Cat(x) → (¬(∃y (Loves(x,y) /\ (x ≠ y))) /\
equal to one another. 1. Assume, for the sake of contradiction that he theorem
is false. Loves(x,x)))
Numbers are constant terms
2. Prove the theorem using a direct proof. "if you pick a person, you’ll find that they love
Type-Checking 3. This contradicts that the theorem is false, so the a cat if and only if they also love a robot."
theorem is true. ∀x. ( Person(x) → ( (∃r(Robot(r) /\
The set of all committees you can make from Stanford Loves(x,r))) ↔ (∃c (Cat(c) /\ (Loves(x,c)))) ) )
students and faculty that contain at least one student and at "No two robots love exactly the same set of cats." = Every two "Each person loves exactly two cats and
least one faculty member. You can assume no one is both a robots have at least one cat one likes and the other does not ∀a. nothing else."
student and a faculty member: ℘ (S ∪ F ) \ (℘ (S) ∪ ℘ (F )) ∀b. ( ( Robot(a) /\ Robot(b) /\ (a ≠ b) ) → (∃c. ( Cat(c) /\ ∀x. ( Person(x) → (∃c. (∃d. ((c ≠ d) /\ Cat(c)
((Loves(a,c) /\ ¬Loves(b,c)) \/ (¬Loves(a,c) /\ Loves(b,c))) ) ) ) /\ Cat(d) /\ Loves(x,c) /\ Loves(x,d) /\ ¬(∃e. ((e
≠ c) /\ (e ≠ d) /\ Loves(x,e))) )) ) )
{{}} Thm: Prove for all natural numbers n that if ⌊n/2⌋· Thm: For all integers n, if n is odd, then n² is odd. Prf:
/* True or false: S and T are sets, and S is a subset
{ } ⌈n/2⌉ is odd, then n is even. Prf: We will prove the Pick an odd integer n. We want to show that n² is odd.
of P(P(T))? [P=PowerSet)*/ contrapositive of this statement, namely, for all natural Since n is odd, there is an integer k where n = 2k +
{{},{{}}}
{} bool isSubsetOfDoublePSet(Object S, Object T) numbers n, if n is odd, then ⌊n/2⌋·⌈n/2⌉ is even. To do 1.Then we see that n² = (2k + 1)² = 4k²+4k+1 =2(2k² +
{{},{{}}} { if (!isSet(S) || !isSet(T)) return false; so, pick an odd natural number for n. We want to 2k)+1. Therefore, there is an integer m (namely, 2k² +
for (Object x: asSet(S)) { // loop across x in S show that ⌊n/2⌋·⌈n/2⌉ is even. Since n is an odd 2k) such that n²=2m+1, so n² is an odd number, as
{ {}, { {} }, { { {} } }, { {}, { {} } } } natural number there exists a non-negative number k required.
if (!isSet(x)) return false;// is x is not a set, stop
/* True or false: S in T? */ for (Object y: asSet(x)) { // everything in x should such that n = 2k+1.Thus, ⌊n/2⌋·⌈n/2⌉ = ⌊(2k+1)/2⌋· Thm: For all integers a, b, and c, if a²+b²=c², then at
bool isElementOf(Object S, Object T) { ⌈(2k+1)/2⌉ = ⌊k+(1/2)⌋·⌈k+(1/2)⌉ = k·(k + 1) = k²+k.
Be a subset of T -> equivelant to double set least one of a, b, and c is even. Prf: We will prove
There are two cases to examine. One in which k is
if (!isSet(T)) return false; return (asSet(T).count(S)); if (!isSubsetOf(y,T)) return false; the contrapositive of this statement, namely, for all
even and the other in which k is odd. Case 1: k is
} } } return true; } integers a, b, and c, if a, b, and c are odd, then a²+
even and, thus, exists an integer a so that k=2a.
/* True or false: S is a subset of T? */ /* ∃ x. Cat(x) */ bool a( b² ̸ =c². To do so, pick odd integers for a, b, and c.
Through substitution, we see that ⌊n/2⌋·⌈n/2⌉ = k² + k
bool isSubsetOf(Object S, Object T) { We want to show that a²+b² ̸ =c². Since a, b, and c
std::set<Entity> world) { = (2a)²+(2a)=4a²+2a=2(2a² + a). Case 2: k is odd
are odd numbers, we know by our result from the
if (!isSet(S) || !isSet(T)) return false; for (Entity x: world) { if (Cat(x)) return true; } and, thus, exists an integer b so that k=2b+1.Through
previous problem that a²,b², and c² are odd.
std::set<Object> large = asSet(T); return false;} substitution, we see that ⌊n/2⌋·⌈n/2⌉ = k²+k= (2b+1)²
Because a² and b² are odd, there exist integers p
for (Object x: asSet(S)) { if (!large.count(x)) return + (2b+1) = 4b²+4b+1+2b+1 =2(2b²+3b+1). In either
/* ∀ x. Robot(x) */ bool b(std::set<Entity> world) { and q such that a² = 2p+1 and b² = 2q+1. This
case, both are shown to be even in the form 2m (m=
false; } return true; for (Entity x: world) { if (!Robot(x)) return false; means that a² + b² = (2p+1) + (2q+1) = 2(p+q+1),
2a² + a in the even case and m=2b²+3b+1 in the odd
} } return true; } which means that a² + b² is even. However, as
case) which is what we needed to show. ■
/* True or false: S and T are sets, and S n T = mentioned earlier we know that c² is odd. Therefore,
/* ∃ x. (Person(x) ∧ Loves(x, x)) */
emptyset? */ we see that a² + b² ̸ = c² as required.■
bool c(std::set<Entity> world) Thm: For all sets A, B, and C, if A ∩ C = ∅., then A - (B -
Thm: For all integers m and n, if mn is even and m is
bool areDisjointSets(Object S, Object T) { { for (Entity x: world) { C) ⊆ (A - B) - C.Prf: Pick arbitrary sets A, B, and C, odd, then n is even. Prf: Assume for the sake of
if (!isSet(S) || !isSet(T)) return false; if (Person(x) && Loves(x,x)) return true; where A ∩ C = ∅.. We want to show that A - (B - C) ⊆ (A - contradiction that there exist integers m and n where
std::set<Object> large = asSet(T); } return false; } B) - C. Pick an arbitrary x ∈ A - (B-C). We want to show mn is even and m is odd and n is odd. Since m is odd,
for (Object x: asSet(S)) { if (large.count(x)) return /* ∀ x. (Cat(x) → Loves(x, x)) */ that x ∈ (A-B)-C. In other words, we need to show three we know that there is an integer k where m = 2k + 1.
false; }return true; bool d(std::set<Entity> world) { things: x ∈ A ,x ∉ B , and x ∉ C. Since x ∈ A - (B-C), we Similarly, since n is odd, there is an integer r where n =
} 2r + 1. Then we see that mn = (2k+1)(2r+1) = 4kr +
for (Entity x: world) { know that x ∈ A, and that x ∉ B or x ∈ C. This shows that
/* True or false: S = {T}? */ 2k+2r+1 =2(2kr+k+r)+1 which means that mn is odd,
if (Cat(x)) { if (!Loves(x, x)) { return false; } } x ∈ A,. Since x ∈ A, and A ∩ C=∅, we know that x ∉ C. but this is impossible because mn was assumed to be
bool isSingletonOf(Object S, Object T) { }return true; } Since x ∉ B or x ∈ C, and we already know that x ∉ C, it even. We have reached a contradiction, so our
if (!isSet(S)) return false; return isElementOf(T, S) /* ∀ x. (Cat(x) → ∃ y. (Person(y) ∧ ¬Loves(x, y)))*/ must be that x ∉ B, which is what we wanted to show. assumption must have been wrong. Therefore, if mn is
&& asSet(S).size() == 1;} bool e(std::set<Entity> even and m is odd, then n is even.■
// Reasoning: if T is a set -> {T} is a set of one world) { for (Entity x: world) { Thm: Let T be an arbitrary tournament and c be a player Thm: For all integers x and y and any integer k, if x ≡k
element, therefore T must be a element of S. if T is if (Cat(x)) { bool found = false; in that tournament. If c won more games than anyone y, then y ≡k x. Prf: Let x, y, and k be arbitrary integers
not a set it must be just one item, -> must be an else in T or is tied for winning the greatest number of where x ≡k y. We want to show that y ≡k x. To do so,
for (Entity y: world) {
element of S. size == 1 limit as otherwise T could be games, then c is a tournament champion in T. Prf: We we will show that there is an integer q where y = x +
if (Person(y) && !Loves(x, y)) { qk. Because x ≡k y, we know there is an integer r such
an element but S could have more elements (S must found = true; break; } } will prove that if c won more games than anyone else in
that x = y + rk. Now, let q = -r. Then we see that y = x −
have the same no of elements) if (!found) return false; T or is tied for winning the greatest number of games,
rk = x − (−q)k = x + qk which ....
/* True or false: S and T are sets, and S in P(T)? */ } }return true; } then c is a tournament champion in T. To do this, we will Thm: For all integers x, y, z, and k that if x ≡k y and y
bool isElementOfPowerSet(Object S, Object T) { /*∃ x. (Robot(x) ↔∀ y. Loves(x, y))*/ bool prove the contrapositive of this statement, namely, if c is ≡k z, we have x ≡k z. Prf: Let x, y, z, and k be arbitrary
return isSubsetOf(S,T); } f(std::set<Entity> world) { not a tournament champion in T, then some player in T integers where x ≡k y and y ≡k z. We want to show
/* True or false: S and T are sets, and S is a subset of won more games than c. If c is not a tournament that x ≡k z. To do so, we will show there is an integer
for (Entity x: world) {
champion, then its negation holds, namely, there exists a m where x = z + mk. Because x ≡k y, we know there is
P(T)? */ bool found = true;
player p such that p beat c, and for any player q, q beat c an integer r such that x = y + rk and because y ≡k z,
bool isSubsetOfPowerSet(Object S, Object T) { for (Entity y: world) { we know there is an integer s such that y = z + sk.
if (!isSet(S) || !isSet(T)) return false; if (!Loves(x, y)) {found = false; break;} or p beat q. Consider any player r. There are two cases: Using this we can see that x = y + rk = (z + sk) + rk = z
for (Object x: asSet(S)) { } Case 1: If r beat c, then c’s win tally did not change. + (s + r)k = z + mk which ...
if (!isSubsetOf(x,T)) return false; if (found && Robot(x)) { Case 2: If c beat r, the statement "r beat c or p beat r" Thm: For all integers x and k,x ≡k x.Prf:Let x and k be
} return true; } return true; must still be satisfied. Since r did not beat c, p must have arbitrary integers. We want to show that x ≡k x. To do
beaten r. Then c’s and p’s win tallies both increased by this, we will show that there is an integer r where x = x
Proof: Pick arbitrary sets A, B, where A ∈ B. We } else if (!found && !Robot(x)) return true;
one. Thus, p beat every + rk. Pick r = 0. Then we see that x=x+0(k) = x+rk ...
want to show that (A U B) ⊆ p(B). Pick } return false; }
player that c beat, so p won at least Look at odd no starting at 3, analyzing pattern show m=k². Thm: If n is an
an arbitrary element S ⊆ p(A U B). We want to show
that S ⊆ (B). In other words, we want as many matches as C. Furthermore, odd natural number and n ≥ 3, then there is an m ∈ N where m > 0 and m² +
mn is a perfect square. Prf: Pick an odd natural number n where n ≥ 3. We
to show that S ∈ B. Pick a ∈ S. We want to show p beat c, which adds an additional
want to show that there exists an integer m such that m² + mn is a perfect
that x ∈ B. Since S ∈ p(AUB), S ∈ AUB. win to p’s tally. Thus, p must have square. Since n is an odd natural number there is an integer k such that
Since x ∈ S and S S A U B, then we know that x ∈ A won at least one more match than c. n=2k+1. Let m= k². Because 2k+1 ≥ 3, we know that k ≥ 1, which means that
U B. So then x ∈ A or x ∈ B. If x ∈ A,
So, some player in T won more m=k²≥ 1. m² + mn = (k²)² + (k²)n = k4 + (k²)(2k + 1) = k4 + 2k3 + k² = (k² + k)².
then since A ⊆ B, x ∈ B. In either case, x ∈ B,
games than c, as required. Therefore there is an integer r (namely, k(k+1)) such that m²+mn=r². Thus
which is what we wanted to show.
m²+mn is a perfect square, as required.

You might also like