Mathematic for Computer Science Lecture 1
Introduction & Proof
A Proof is a method for ascertaing the truth.
Amathematical proof is a verification of a proposition by chain oflogical deductions from a set of axiom.
Def: A proposition is a statement that is either True or False.
Ex: 2 + 3 = 5.
Ex: 1 + 1 = 3.
Compound Proposition
truth table of NOT(P)
P | NOT(P) |
T | F |
F | T |
Def: the proposition "P AND Q" is true only when P and Q are both true.
P | Q | P AND Q |
T | T | T |
T | F | F |
F | T | F |
F | F | F |
Def: the proposition "P OR Q" is true when either P or Q is true.
P | Q | P OR Q |
T | T | T |
T | F | T |
F | T | T |
F | F | F |
P | Q | P XOR Q |
T | T | F |
T | F | T |
F | T | T |
F | F | F |
Def: An implication is true exactly when the if-part is false or the then-part is true.
P | Q | P IMPLIES Q |
T | T | T |
T | F | F |
F | T | F |
F | F | T |
Def: The proposition "P if and only if Q" asserts that P and Q are logically equivalent, either both are true or both are false.
P | Q | P IFF Q |
T | T | T |
T | F | F |
F | T | F |
F | F | T |
Logically Equivalent Implications
P | Q | P IMPLIES Q | NOT(Q) IMPLIES NOT(P) |
T | T | T | T |
T | F | F | F |
F | T | T | T |
F | F | T | T |
In general, "NOT(Q) IMPLIES NOT(P)" is called the contrapositive of the implication "P IMPLIES Q".
An implication and its converse together are equivalent to an iff statement.
Propositional Logic in Computer Programs
if ( x > 0 || (x <= 0 && y > 100))
...
further instruction
...
A | B | A OR (NOT(A) AND B) | A OR B |
T | T | T | T |
T | F | T | T |
F | T | T | T |
F | F | F | F |
if (x > 0 || y > 100)
...
further instruction
...
Simplifying expressions in software can increase the speed of your program. Chip designers try to minimize the number of analogous physical devices on a chip. A chip with fewer devices is smaller, consumes less power, has a lower defect rate, and is cheaper to manufacture.
Predicates & Quantifiers
Def: Apredicate is a proposition whose truth depends on the value of variable.
Def: An assertion that a predicate is always true, is called a universally quantified statement.
Def: An assertion that a predicate is sometimes true, is called an existentially quantified statement.
For all n in nature number N, n^2 + n + 41 is a prime
n | n^2 + n +41 | prime |
0 | 41 | True |
1 | 43 | True |
2 | 47 | True |
3 | 53 | True |
... | ... | ... |
20 | 461 | True |
... | ... | ... |
39 | 1601 | True |
40^2 + 40 + 41 = 1681 = 41^2
Ex: a^4 + b^4 + c^4 = d^4 has no positive integers solutions
a = 95800 b = 217519 c = 414560 d = 42248
There exists a, b, c, d in positive integers N*, s.t. a^4 + b^4 + c^4 = d^4.
Ex: 313(x^3 + y^3) = z^3 has no positive integer solutions
Ex: (Four-Color-Theorem) Every map can be colored with 4 colors so that adjacent regions have different colors.
Ex:(Goldbach's Conjecture) Every even integer n greater than 2 is the sum of two primes.
For every even integer n greater than 2, there exists primes p and q such that
n = p + q.
Let Evens be the set of even integer greater than 2, let Primes be the set of prime.
For all n belong to Evens, there exists p, q in Primes, s.t p + q = n.
Order of Quantifiers
Ex: Every American has a dream.
Let A be the set of American.
Let D be the set of dreams.
Define the predicate H(a, d) to be "American a has dream d".
The sentence could mean that there is a single dream that every American shares:
There exists d belong in D, for all a belong to A, s.t. H(a, d).
Or it could mean that every American has a personal dream:
For all a in A, there exists d in D, s.t. H(a, d).
Negating Quantifiers
Not(for all x. P(x)) <==> there exists x. Not(P(x))
Not(there exists x. P(x)) <==> for all x. Not(P(x))
The general principle is that moving a "not" across a quantifier changes the kind of quantifier.
Validity & Satisfiability
Def: A propositional formula is called valid when it evaluates to T no matter what truth values are assigned to the individual propositional variable.
Ex: [P AND (Q OR R)] iff [(P AND Q) OR (P AND R)]
Def: A predicate formula is called valid when it evaluates to T no matter what values its variables may take over unspecified domain, and no matter what interpretation a predicate variable may be given.
Ex: There exits x for all y. P(x, y) ==> For all y there exists x. P(x, y)
Def: A proposition is satisfiable if some setting of the variables makes the proposition true.
Def: An axiom is a proposition that is "assumed" to be true.
Ex: if a = b and b =c , then a = c.
Euclidean Geometry:
Given a line L and point P not on L, there is exactly one line thu P parallel to L.
Spherical Geometry:
Given a line L and point P not on L, there is no line thu P parallel to L.
Hyperbolic Geometry:
Given a line L and point P not on L, there are infinitely many lines thu P parallel to L.
Axioms should be
- consistent
- complete
Def: A set of axioms is consistent if no proposition can be proved T & F.
Def: A set of axioms is complete if it can be used to prove every proposition is T or F.
Reference:
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/