Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Review 1Andreas Klappenecker
Summary
Propositional Logic, Chapter 1
Predicate Logic, Chapter 1
Proofs, Chapter 1
Sets, Chapter 2
Functions, Chapter 2
Sequences and Sums, Chapter 2
Asymptotic Notations, Chapter 3
Time Complexity of Algorithms, Chapter 3
Strategy for Exam Preparation
- Start studying now!
- Make sure you know your definitions!
- Do odd numbered exercises
(Solutions are in the Appendix)
- Review your quizzes
- Review your homework
Logical Connectives - Summary
Let B={t,f}. Assign to each connective a function M: B->B
that determines its semantics. 4 The Semantics of Propositional Logic
Let B = {t, f} denote the set of truth values, where t and f represent trueand false, respectively. We associate to the logical connective ¬ the functionM¬ : B→ B given by
P M¬(P )f tt f
Thus, M¬(P ) is true if and only if P is false. This justifies the name negationfor this connective. The graph of the function M¬ given above is called thetruth table of the negation connective. Similarly, we associate to a connectiveX in the set {∧,∨,⊕,→,↔} a binary function MX : B × B → B. The truthtables of these connectives are as follows:
P Q M∧(P, Q) M∨(P,Q) M⊕(P, Q) M→(P, Q) M↔(P, Q)f f f f f t tf t f t t t ft f f t t f ft t t t f t t
You should very carefully inspect this table! It is critical that you memorizeand fully understand the meaning of each connective.
The semantics of the language Prop is given by assigning truth values toeach proposition in Prop. Clearly, an arbitrary assignment of truth values isnot interesting, since we would like everything to be consistent with the meaningof the connectives that we have just learned. For example, if the propositions aand b have been assigned the value t, then it is reasonable to insist that a ∧ bbe assigned the value t as well. Therefore, we will introduce the concept of avaluation, which models the semantics of Prop in an appropriate way.
A valuation v : Prop→ B is a function that assigns a truth value to eachproposition in Prop such thatV1. v�¬a� = M¬(v�a�)V2. v�(a ∧ b)� = M∧(v�a� , v�b�)V3. v�(a ∨ b)� = M∨(v�a� , v�b�)V4. v�(a⊕ b)� = M⊕(v�a� , v�b�)V5. v�(a→ b)� = M→(v�a� , v�b�)V6. v�(a↔ b)� = M↔(v�a� , v�b�)holds for all propositions a and b in Prop. The properties V1–V6 ensurethat the valuation respects the meaning of the connectives. We can restrict avaluation v to a subset of the set of proposition. If A and B are subsets ofProp such that A ⊆ B, and vA : A → B and vB : B → B are valuations, thenvB is called an extension of the valuation vA if and only if vB coincides withvA when restricted to A.
The consistency conditions V1-V6 are quite stringent, as the next theoremshows.
5
4 The Semantics of Propositional Logic
Let B = {t, f} denote the set of truth values, where t and f represent trueand false, respectively. We associate to the logical connective ¬ the functionM¬ : B→ B given by
P M¬(P )f tt f
Thus, M¬(P ) is true if and only if P is false. This justifies the name negationfor this connective. The graph of the function M¬ given above is called thetruth table of the negation connective. Similarly, we associate to a connectiveX in the set {∧,∨,⊕,→,↔} a binary function MX : B × B → B. The truthtables of these connectives are as follows:
P Q M∧(P, Q) M∨(P,Q) M⊕(P, Q) M→(P, Q) M↔(P, Q)f f f f f t tf t f t t t ft f f t t f ft t t t f t t
You should very carefully inspect this table! It is critical that you memorizeand fully understand the meaning of each connective.
The semantics of the language Prop is given by assigning truth values toeach proposition in Prop. Clearly, an arbitrary assignment of truth values isnot interesting, since we would like everything to be consistent with the meaningof the connectives that we have just learned. For example, if the propositions aand b have been assigned the value t, then it is reasonable to insist that a ∧ bbe assigned the value t as well. Therefore, we will introduce the concept of avaluation, which models the semantics of Prop in an appropriate way.
A valuation v : Prop→ B is a function that assigns a truth value to eachproposition in Prop such thatV1. v�¬a� = M¬(v�a�)V2. v�(a ∧ b)� = M∧(v�a� , v�b�)V3. v�(a ∨ b)� = M∨(v�a� , v�b�)V4. v�(a⊕ b)� = M⊕(v�a� , v�b�)V5. v�(a→ b)� = M→(v�a� , v�b�)V6. v�(a↔ b)� = M↔(v�a� , v�b�)holds for all propositions a and b in Prop. The properties V1–V6 ensurethat the valuation respects the meaning of the connectives. We can restrict avaluation v to a subset of the set of proposition. If A and B are subsets ofProp such that A ⊆ B, and vA : A → B and vB : B → B are valuations, thenvB is called an extension of the valuation vA if and only if vB coincides withvA when restricted to A.
The consistency conditions V1-V6 are quite stringent, as the next theoremshows.
5
Alternative Summary
The immediate successors of a in the formation tree are labeled by subformulasof a of degree less than n; hence, these successors have a valuation assigned.Therefore, v has a unique extension to a using the consistency rules V1–V6.We can conclude that v is a valuation on the set of all proposition of degree nextending v0. Therefore, the claim follows by induction.
The key reason that the previous argument by induction works is that theformation tree is unique. If there would exist several different trees for a singleformula, then such a recursive definition of a valuation would be ambiguous,and the definition of the valuation v might not be well-defined.Remark. Perhaps you would like to see a more direct argument based on thegrammar rather than on the degree of the formulas. One can use structuralinduction, a generalization of induction to so-called freely generated recursivelydefined sets. For a proof of the existence of valuations using structural induc-tion, see [J.H. Gallier, Logic for Computer Science – Foundations of AutomaticTheorem Proving, John Wiley & Sons, 1987].
In this section, we have been a little bit pedantic by distinguishing the purelysyntactical form of a proposition such as (a → b) from its meaning M→(a, b).Of course, it is a good idea to clearly distinguish between syntax and semanticsuntil the semantics of the connectives is clearly understood. From now on, wewill abuse notation and freely interpret (a→ b) as the function M→(a, b).
Summary. Informally, we can summarize the meaning of the connectives asfollows: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 allvariables that occur in the propositions contained in S. We showed that thereexist a unique valuation extending an interpretation of all propositions.
5 Tautologies and Satisfiability
In the previous two sections, we have introduced the language of propositionallogic and gave the propositions a meaning using valuations. In this section, wewill see propositional logic “at work”.
A proposition p is called a tautology if and only if v�p� = t for all valuationsv on Prop.
A proposition p is a tautology if and only if p evaluates to t under eachinterpretation of the variables in p. If the proposition p contains n variables,then we have to check all 2n possible interpretations of p.
7
Conditional
Perhaps the most important logical connective is the conditional, also known as implication:
p -> q
The statement asserts that q holds on the condition that p holds. We call p the hypothesis or premise, and q the conclusion or consequence. Typical usage in proofs:
“If p, then q”; “p implies q”; “q only if p”; “q when p”; “q follows from p”
“p is sufficient for q”; “a sufficient condition for q is p”; “a necessary condition for p is q”; “q is necessary for p”
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. E: Z->{t,f} with E(x)= x is an even integer, E(6) is true;
O: Z->{t,f} with O(x)= x is an odd integer; O(6) is false.
Logical Equivalence
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.
You use logical equivalences to derive more convenient forms statements.
Example: De Morgan’s laws.
De Morgan’s Laws
¬∀xP (x) ≡ ∃x¬P (x)
¬∃xP (x) ≡ ∀x¬P (x)
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
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 ∧ qr → p¬r → ss → t
∴ t
Argument
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)
Sets, Functions, Summations
Set Builder Notation
The set builder notation describes all elements as a subset of a set having a certain property.
Q = { p/q ∈ R | p ∈ Z, q ∈ Z, and q≠ 0 }
[a,b] = { x ∈ R | a <= x <= b }
[a,b) = { x ∈ R | a <= x < b }
(a,b] = { x ∈ R | a < x <= b }
(a,b) = { x ∈ R | a < x < b }
16
Equality of Sets
Two sets A and B are called equal if and only if they have the same elements.
A = B if and only if ∀x(x ∈ A ⟷ x ∈ B)
[To prove A=B, it is sufficient to show that both ∀x(x ∈ A ⟶ x ∈ B) and ∀x(x ∈ B ⟶ x ∈ A) hold. Why? ]
17
Subset
A set A is a subset of B, written A ⊆ B, if and only if every element of A is an element of B.
Thus, A ⊆ B if and only if ∀x(x ∈ A ⟶ x ∈ B)
18
Cardinality of a Set
Let S be a set with a finite number of elements. We say that the set has cardinality n if and only if S contains n elements. We write |S| to denote the cardinality of the set.
For example, |∅| = 0.
19
Power Sets
Given a set S, the power set P(S) of S is the set of all subsets of S.
Example: P( {1} ) = { ∅, {1} }
P( {1,2} ) = { ∅, {1}, {2}, {1,2} }
P(∅) = { ∅ } since every set contains the empty set as a subset, even the empty set.
P({∅}) = {∅, {∅}}.
20
Cartesian Products
Let A and B be sets. The Cartesian product of A and B, denote AxB, is the set of all pairs (a,b) with a ∈A and b∈B.
AxB = { (a,b) | a ∈A ⋀ b∈B }
21
Set Operations
Give two sets A and B. You should know
- the union of A and B
- the intersection of A and B
- the set difference between A and B
- the complement of A
22
De Morgan Laws
A ∩B = A ∪B
Proof :
A ∩B = {x | x �∈ A ∩B} by definition of complement
= {x | ¬(x ∈ A ∩B)}= {x | ¬(x ∈ A ∧ x ∈ B)} by definition of intersection
= {x | ¬(x ∈ A) ∨ ¬(x ∈ B)} de Morgan’s law from logic
= {x | (x �∈ A) ∨ (x �∈ B)} by definition of �∈= {x | x ∈ A ∨ x ∈ B} by definition of complement
= {x | x ∈ A ∪B} by definition of union
= A ∪B
23
Terminology
Let f: A -> B be a function.
We call
- A the domain of f and
- B the codomain of f.
The range of f is the set
f(A) = { f(a) | a in A }
24
Functions
Let A and B be sets. Consider a function f: A-> B.
- When is f surjective?
- When is f injective?
- When is f bijective?
25
Floor Function
The floor function ⎣⎦: R -> Z assigns to a real
number x the largest integer <= x.
⎣3.2⎦= 3
⎣-3.2⎦= -4
⎣3.99⎦= 3
26
Ceiling Function
The ceiling function ⎡⎤: R -> Z assigns to a real
number x the smallest integer >= x.
⎡3.2⎤= 4
⎡-3.2⎤= -3
⎡0.5⎤= 1
27
Basic Facts
We have⎣x⎦= n if and only if n <= x < n+1.
We have⎡x⎤=n if and only if n-1< x <= n.
We have⎣x⎦= n if and only if x-1 < n <= x.
We have⎡x⎤=n if and only if x<= n < x+1.
28
Example
29
Prove or disprove:
��
�x�� = �√x�
Example 3
30
Let m = ���x��
Hence, m ≤��x� < m+ 1
Thus, m2 ≤ �x� < (m+ 1)2
It follows that m2 ≤ x < (m+ 1)2
Therefore, m ≤√x < m+ 1
Thus, we can conclude that m = �√x�
This proves our claim.
Geometric SeriesIf a and r �= 0 are real numbers, then
n�
j=0
arj =
�arn+1−a
r−1 if r �= 1
(n+ 1)a if r = 1
Proof:The case r = 1 holds, since arj = a for each of then+ 1 terms of the sum.
The case r �= 1 holds, since
(r − 1)�n
j=0 arj =
n�
j=0
arj+1 −n�
j=0
arj
=n+1�
j=1
arj −n�
j=0
arj
= arn+1 − aand dividing by (r − 1) yields the claim.
Extremely useful!
Sum of First n Positive Integers .
For all n ≥ 1, we haven�
k=1
k = n(n+ 1)/2
We prove this by induction.Basis step: For n = 1, we have
1�
k=1
k = 1 = 1(1 + 1)/2.
Extremely useful!
Sum of the First n Positive Integers
Induction Hypothesis: We assume that the claim
holds for n− 1.
Induction Step: Assuming the Induction Hypoth-
esis, we will show that the claim holds for n.
�nk=1 k = n+
�n−1k=1 k
= 2n/2 + (n− 1)n/2 by Induction Hypothesis
=2n+n2−n
2
=n(n+1)
2
Therefore, the claim follows by induction on n.
Infinite Geometric Series
Let x be a real number such that |x| < 1. Then
∞�
k=0
xk =1
1− x.
Infinite Geometric Series
Since the sum of a geometric series satisfies
n�
k=0
xk =xn+1 − 1
x− 1,
we have
∞�
k=0
xk = limn→∞
n�
k=0
xk = limn→∞
xn+1 − 1
x− 1
As limn→∞ xn+1 = 0, we get
∞�
k=0
xk =−1
x− 1=
1
1− x.
Asymptotic Notations
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 n0 and a positive real constant U such that |f(n)| <= U|g(n)| for all n satisfying n >= n0
Big Ω
We define f(n) = Ω(g(n)) if and only if there exists a constant L and a natural number n0 such that
L |g(n)| <= |f(n)|
holds for all n >= n0.
In other words, f(n) = Ω(g(n)) if and only if g(n) = O(f(n)).
Big Θ
We define f(n) = Θ(g(n)) if and only if there exist constants L and U and a natural number n0 such that
L|g(n)| <= |f(n)| <= U|g(n)|
holds for all n >= n0.
In other words, f(n) = Θ(g(n)) if and only if
f(n) = Ω(g(n)) and f(n) = O(g(n)).