Download Mathematical Logic: Properties of Binary Relations and Propositional Logic - Prof. Howard and more Exams Engineering in PDF only on Docsity!
Mathematical and Logical Basis of Computing:
a Workbook
Howard A. Blair
Copyright 2006 – 2009
Permission is granted for printing for academic purposes.
All commercial rights reserved.
February 3, 2009
- Task: The objective of this course is (1) to equip participants with a way of seeing based upon mathematical logic and the fundamental building blocks of mathematics: sets, relations, and functions, and (2) to assimilate a certain way of thinking, not merely just to know about these mathematical procedures. The purpose of this way of thinking is to empower one to analyze, design and engineer anything in the virtual worlds of computing, the only limits being those imposed by logical consistency.
Write a short, intelligent paragraph that gives your point of view about the course’s stated objective and purpose. Turn in your paragraph by email to blair at ecs.syr.edu by February 10th.
- Consider a graph S (a graph is a set of vertices together with a symmet- ric relation on the set of vertices called the edge relation) represented as a square in the Euclidean plane.
A B
C D
The relation depicted by this graph is a relation from {A, B, C, D} to {A, B, C, D} and is determined by one of the subsets of
{A, B, C, D} × {A, B, C, D}
In other words, the relation depicted by this graph is a triple
({A, B, C, D}, {A, B, C, D}, R)
where R ⊆ {A, B, C, D} × {A, B, C, D} Thus, R is a set of pairs.
- Task: List the pairs in R. [Hint: There are eight pairs (8 because the edges point both ways).]
Answer:
{(A, B), (B, A, ), (B, D), (D, B), (D, C), (C, D), (D, A), (A, D)}
The order within each pair is important. The order in which the pairs are listed in the set is not important. So
{(D, B), (D, C), (C, D), (D, A), (A, D) (A, B), (B, A, ), (B, D)}
is just as correct.
- Definition: (neighborhood ) Let D be the directed graph (V, E) (V is a set and E is a relation on V ). Let x ∈ V ; i.e. let x be a vertex of D. Any set of vertices of D that contains the set
{y ∈ V | (x, y) ∈ D}
is a neighborhood of x. In particular, {y ∈ V | (x, y) ∈ D} is the least neighborhood of x.
- Definition: (subset) Let A and B be sets. (They may, or may not, be the same set.) A is a subset of B (denoted by A ⊆ B) iff for every element y of A, y is a member of B. The subset relation is also called set-inclusion.
- Notice that the preceding definition gives a test to see whether one set is a subset is another. If you are given two sets P and Q, to see whether P ⊆ Q, you test each element of P to see whether it is a member of Q. This of course depends on already having a way to range over the elements of P , and a test to see whether or not something is an element of Q. The test for P ⊆ Q also depends on being able to test,
first member is a member of A and whose second member is a member of B.
- Task: Let U = { 1 , 2 , 3 } and V = { 1 , 2 }. Fill in the elements in the set below.
U ×V = { }
- Task: What is A × ∅, for any set A?
- Task: Suppose P is a set that has m elements, and Q is a set that has n elements. How many elements does the set P × Q have? (It’s actually a fair amount of work to prove the correct answer is really correct.)
- The next item contains the definition of binary relation. On the as- sessment exam, a simplified version of that definition was given. Here we will give the full, standard definition, and we will follow it by a few tasks that demonstrate the need for the extra detail.
- Definition: (Binary Relation from set A to set B) A binary relation from A to B is a triple (A, B, R), where R is a subset of A × B. If A = B then we say that R is a binary relation on A. The expressions (x, y) ∈ R, R(x, y) and x R y are used interchangeably to denote the statement that (x, y) is a member of R.
- Hereafter, we will abbreviate the expression “binary relation” to just “relation” when no confusion would be reasonably expected to result.
- Task:
- Definition: (transitivity) A binary relation R on a set A is transitive if, and only if, for every x ∈ A, y ∈ A and z ∈ A, if x R y and y R z, then x R z.
- Definition: (reflexivity) A binary relation R on a set A is reflexive if, and only if, for every x ∈ A, x R x.
- Definition: (symmetry) A binary relation R on a set A is symmetric iff for every x ∈ A and y ∈ A, if x R y, then y R x..
- Definition: (antisymmetry) A binary relation R on a set A is an- tisymmetric iff for every x ∈ A and y ∈ A, if x R y and y R x, then x = y.
- Definition: (reflexivity) A binary relation R on a set A is antisym- metric iff for every x ∈ A and y ∈ A, if x R y and y R x, then x = y.
- Task: The least neighborhood of the vertex A in S is {B, C}. What are the least neighborhoods of B, C and D?
Answer: Let LNbhd(x) be the least neighborhood of x. Then
LNbhd(A) = {B, C} LNbhd(B) = {A, D} LNbhd(D) = {B, C} LNbhd(C) = {A, D}
- What does least mean? To answer this question we will sort out the concepts of mimimal, minimum, maximal and maximum. least and smallest are synonyms for minimum. greatest and largest are synonyms for maximum. We will also consider lower bound and upper bound.
- Definition: (partial order ) A partial ordering on a set D is a relation on D that is reflexive, antisymmetric and transitive. The pair (D, v) is a partial order iff v is a partial ordering on D. A partial order is also called a poset. Comment: The sign v is variously read as “less than or equal to” or “below”. The latter usage stretches the English word “below” so that an element can be “below” itself.
- Definition: (minimum, maximum) Let (D, v) be a poset and let A ⊆ D. a is a minimum element of A iff a ∈ A and for every b ∈ A, a v b. a is a maximum element of A iff a ∈ A and for every b ∈ A, b v a.
- Definition: (minimal ) Let (D, v) be a poset and let A ⊆ D. a is a mimimal element of A iff a ∈ A and for every b ∈ A, if b v a, then b = a. Comment: Less formally, a minimal element of A is an element a of A such that there is no element of A below a.
- Definition: (maximal ) Let (D, v) be a poset and let A ⊆ D. a is a maximal element of A iff a ∈ A and for every b ∈ A, if a v b, then a = b.
- Definition: (lower bound, upper bound ) Let (D, v) be a poset and let A ⊆ D. An element x in D is a lower bound of A iff for every a in A, x v a. An element x in D is an upper bound of A iff for every a in
vertex A, the underlying partial order is set-inclusion ⊆, the poset is (2{A,B,C,D}, ⊆), and the subset of 2{A,B,C,D}^ to be considered is the set of all neighborhoods of vertex A.
- Definition: (homomorphism) Suppose we have two directed graphs (which might or might not actually be different) D 1 = (V 1 , E 1 ) and D 2 = (V 2 , E 2 ). Suppose ϕ : V 1 −→ V 2 ϕ is a homomorphism of D 1 and D 2 iff for all vertices x and y of D 1 , if (x, y) ∈ E 1 , then (ϕ(x), ϕ(y)) ∈ E 2.
- Consider the permutation (C D) of the vertices of S. (We are using cycle notation.) Let ρ = (C D). Then (recall the definition of the image of a set with respect to a function that was given in class)
ρ({A, C}) = {A, D}
Notice that there is an edge (A, C) in S, but there is no edge (A, D) in S. Therefore, π is not a homomorphism from S to S.
- Task: Find all of the permutations of the set of vertices of Sthat are homomorphisms from S to S. (There are eight such homomorphisms.)
Answer:
A B
C D
A C
B D
B A
D C
A B
C D
A B
C D
A B
C D
A B
C D
A B
C D
I (B C)(B C)(B C) (A B)(C D) (A B D C)
(A C D B) (A C)(B D) (B C) (A D)(B C)
- Definition: (left-inverse, retraction) Let A and B be nonempty sets and let f : A −→ B. The function g : B −→ A is a left-inverse of f iff for all x ∈ A, g(f (x)) = x. A left-iverse is also called a retraction. Comment: Intuitively, when f outputs a value f (x), g “takes it back” to x.
- Definition: (right-inverse, section) Let A and B be nonempty sets and let f : A −→ B. The function g : B −→ A is a right-inverse of f iff for all y ∈ B, f (g(y)) = y.
- Task: Prove that, given f : A −→ B, a left-inverse of f exists iff f is one-to-one.
Proof: Suppose a left-inverse g of f exists. Then, for every x ∈ A, g(f (x)) = x. Now consider any x 1 , x 2 in A such that suppose f (x 1 ) = f (x 2 ). To show that f is one-to-one, it remains to show that x 1 = x 2. Since f (x 1 ) = f (x 2 ), g(f (x 1 )) = g(f (x 2 )). But, g(f (x 1 )) = x 1 and g(f (x 2 )) = x 2. Therefore, x 1 = x 2.
- Task: Prove that, given f : A −→ B, a right-inverse of f exists iff f is onto.
Proof: Suppose a right-inverse g of f exists. Then, for every y ∈ B, f (g(y)) = y. Now consider any y ∈ A. To show that f is onto, it remains to show that there is some x such that f (x) = y. There is: let x = g(y).
- Definition: (inverse) Let A and B be nonempty sets and let f : A −→ B. g : B −→ A is an inverse of f iff g is both a left and a right inverse of f.
- Task: Prove that if f : A −→ B has an inverse, then that inverse is unique.
Proof: Suppose that both g 1 and g 2 are inverses of f. To show that the inverse of f , if it exists, is unique, it remains to show that g 1 (y) = g 2 (y) for every y ∈ B. Consider an arbitrary y ∈ B. Since g 1 and g 2 are inverses of f , g 1 and g 2 are both left-inverses of f and right-inverses of f. Therefore f is one-to-one and onto. Since f is onto, there is an x ∈ A such that f (x) = y. Therefore, since g 1 is a left-inverse of f ,
Answer: It is sufficient to find a function f : D −→ E that is neither one-to-one nor onto. Let A = { 0 , 1 } and let B = { 0 , 1 }. Let f : A −→ B be defined by f (0) = f (1) = 0. f has no left-inverse and no right-inverse. Let B = { 0 } or B = E. f −^1 (B) = A. Alternatively, if B = ∅ or B = { 1 }, then f −^1 = ∅.
- In the following sequence of tasks, let f : D −→ E, and let A and B be subsets of D. Let P and Q be subsets of E.
- Task: Consider
f (A ∩ B)? f (A) ∩ f (B)
Must the two sides be equal? Must either side be a subset of the other? Are the two sides equal if f is one-to-one? onto? both one-to-one and onto?
Answer: f (A ∩ B) ⊆ f (A) ∩ f (B), for the following reason. Let y be an arbitrary element in f (A ∩ B). Then for some x ∈ A ∩ B, y = f (x). x ∈ A and x ∈ B. Therefore, y ∈ f (A) and y ∈ f (B). Therefore, y ∈ f (A) ∩ f (B).
If f is not 1-to-1, then the two sides may not be equal. Example: Let D = { 0 , 1 } and E = { 0 }. Let f (0) = f (1) = 0. Let A = { 0 } and B = { 1 }. Then, f (A)∩f (B) = { 0 }∩{ 0 } = { 0 } 6 ⊆ ∅ = f (∅) = f (A∩B).
If f is 1-to-1, then f (A ∩ B) = f (A) ∩ f (B), for the following reason. Since f (A ∩ B) ⊆ f (A) ∩ f (B) whether or not f is 1-to-1, it suffices to show that f (A) ∩ f (B) ⊆ f (A ∩ f (B). Let y ∈ f (A) ∩ f (B). Then there exist x 1 ∈ A and x 2 ∈ B such that f (x 1 ) = f (x 2 ) = y. Since f is 1-to-1, x 1 = x 2. Therefore, x 1 is in B. So, x 1 ∈ A ∩ B. Therefore, y ∈ f (A ∩ B). Hence, f (A) ∩ f (B) ⊆ f (A ∩ f (B).
- Task: Consider
f −^1 (P ∩ Q)? f −^1 (P ) ∩ f −^1 (Q)
Must the two sides be equal? Must either side be a subset of the other? Are the two sides equal if f is one-to-one? onto? both one-to-one and onto?
Answer: The two sides are equal. Suppose x ∈ f −^1 (P ∩ Q). Then f (x) ∈ P ∩ Q. Therefore, f (x) ∈ P and f (x) ∈ Q. Therefore, x ∈ f −^1 (P ) and x ∈ f −^1 (Q). Hence, x ∈ f −^1 (P ) ∩ f −^1 (Q). Thus, f −^1 (P ∩ Q) ⊆ f −^1 (P ) ∩ f −^1 (Q). Conversely, suppose x ∈ f −^1 (P ) ∩ f −^1 (Q). Then x ∈ f −^1 (P ) and x ∈ f −^1 (Q). Therefore, f (x) ∈ P and f (x) ∈ Q. Hence, f (x) ∈ P ∩ Q. Therefore, x ∈ f −^1 (P ∩ Q).
- Task: Consider
f (A ∪ B)? f (A) ∪ f (B)
Must the two sides be equal? Must either side be a subset of the other? Are the two sides equal if f is one-to-one? onto? both one-to-one and onto?
Answer: The two sides are equal. Consider any y ∈ E. Then,
y ∈ f (A ∪ B) iff there exists x ∈ A ∪ B such that y = f (x) iff there exists x ∈ A such that y = f (x) or there exists x ∈ B such that y = f (x) iff y ∈ f (A) or y ∈ f (B) iff y ∈ f (A) ∪ f (B).
- Task: Consider
f −^1 (P ∪ Q)? f −^1 (P ) ∪ f −^1 (Q)
Must the two sides be equal? Must either side be a subset of the other? Are the two sides equal if f is one-to-one? onto? both one-to-one and onto?
Answer: The two sides are equal. Consider any x ∈ D. Then,
x ∈ f −^1 (P ∪ Q) iff f (x) ∈ P ∪ Q
y ∈ f (f −^1 (P )) implies there exists x ∈ f −^1 (P ) such that y = f (x) implies y = f (x) ∈ P.
If f is not onto, then the left side might not be a subset of the right side. Example: Let D = E = { 0 , 1 }. Let f (0) = f (1) = 0. Let P = E. Then,
P = E 6 ⊆ { 0 } = f (D) = f (f −^1 (P )).
If f is onto, then the two sides are equal for the following reason.
y ∈ P implies (since f is onto) there exists x ∈ f −^1 (P ) such that y = f (x) implies y = f (x) ∈ f (f −^1 (P )).
- Task: Give an example of a directed graph (V, E) and a permutation ρ : V −→ V that is a homomorphism of (V, E), but for which ρ−^1 is not a homomorphism.
Answer: Let (V, E) be the directed graph where V is the set of in- tegers Z and E = {(i, i + 1) | i ∈ Z, i ≥ 0 }. Let ρ(n) = n + 1. Then for any edge (i, i + 1), (ρ(i), ρ(i + 1)) = (i + 1, i + 2) ∈ E. Therefore ρ is edge-preserving. ρ−^1 (n) = n − 1. ρ−^1 does not preserve the edge (0, 1) since (− 1 , 0) is not edge.
- Task: Consider the the graph below represented as an equilateral triangle in the plane.
a
c b
Observe that every permutation of the set {a, b, c} is a homomorphism of the graph(i.e. is edge preserving). There are six permutations, of course, which we may list using cycle notation as: (), (a b), (a c), (b c), (a b c), (a c b). Suppose, for example, that we apply the permutation (b c) to the three vertices {a, b, c}. The resulting graph is
a
b c
Thus, the permutation (b c) corresponds to a symmetry of the equi- lateral triangle: a reflection through the central vertical axis running through vertex a and bisecting line segment cb, as depicted by
a
c b
The Task: For each of the remaining five permutations, identify the symmetry of the equilateral triangle that corresponds to the permuta- tion.
- Task: Complete the table below that defines the composition opera- tion on the six permutations of {a, b, c}. Also, verify that the entries already given are actually correct. (Take nothing for granted. Verify. Argue with the material until it logically forces itself on you.)
I
F = (b c)
R = (a b c) R = (a c b)^2
FR = (a c)^2 FR = (a b)
I is the identity permutation.
- To be continued.
February 24, 2009
- At Amazon if you search with
Epstein Carnielli
the first link returned will be to the book, Computability by Richard Epstein and Walter Carnielli. (cf. The course website in the Bibliog- raphy section.) The book is fully searchable. The material you will need for this section (September 5, 2006) will be found in Chapter 19, but you do not need all of it. Alternatively, you can go into the online Wikipedia at
http://en.wikipedia.org/wiki/Propositional logic (Propositional Logic)
There you will find a good comprehensive introduction to propositional logic. We do not need to study propositional logic in depth, although you should be aware that there is much more in it than you might at first suppose.
- You should also be aware that your experience in computer science has probably familiarized you already with much of what you need to know for present purposes about propositional logic and the main, classical, semantics associated with it: Boolean expressions built up purely from Boolean variables and Boolean connectives.
- The single most important idea to “get” is that formulas in logic (i.e. propositional formulas, or Boolean expressions, in the case of proposi- tional formulas) do not actually mean anything - until a semantics is specified.
- When propositional logic is presented two main things need to be specified: the syntax and the semantics. The syntax is concerned with grammar: what is a formula of the logic, and what isn’t. The semantics is concerned with what the formulas mean. To know something about logic you need to know about the grammar (syntax) of the logic, about the semantics of the logic, and how the logic relates to logic’s big question: What follows from what?
- The grammar rules for making formulas are:
(a) t is a formula. (b) f is a formula. (c) If A is an atom, then A is a formula. (d) If A is a formula, then ¬A is a formula. (e) If A and B are formulas, then (A → B) is a formula. (f) If A and B are formulas, then (A ↔ B) is a formula. (g) If A and B are formulas, then (A ∧ B) is a formula. (h) If A and B are formulas, then (A ∨ B) is a formula. (i) If A and B are formulas, then (A | B) is a formula. (j) If A, B and C are formulas, then (A? B : C) is a formula.
- If you are familiar with BNF-definitions, here is a similar, but more condensed, approach in BNF.
- Let Atom range over the set of atoms. Then
Formula ::= t | f | Atom | ¬ Formula | (Formula ◦ Formula) | (Formula? Formula : Formula)
◦ ::= → | ↔ | ∧ | ∨ | |
- When we write logical formulas we will often omit parentheses when it is clear how to parse the formula.
- That’s it for now with syntax.
- Semantics: Consider one of the easier, familiar propositional connec- tives, ∧. What does ∧ usually mean? Well, it usually means and. What does that mean? First of all, the the symbol ∧ joins together two propositional formulas to make a more complicated one. So does ∨, so what is the difference? Well, A ∧ B is just a different formula from A ∨ B, so that’s the difference. OK, but don’t ∧ and ∨ have
something to do with Boolean values, and don’t they get “defined by” truth tables? Yes, but what does all this cloud of vagueness mean? You might start to explain this business by saying that if you assign T to A and T to B then you must assign T to A ∧ B and if you assign F either to A or to B then you must assign F to A ∧ B, and so on. OK, what do you mean by assign? And on and on and on. How are we going to make this stuff sharp and precise?
- To start getting your mind out of this cloud of vagueness, go back and reconsider ∧. That symbol operates on a pair of formulas. But the meaning of ∧ operates on a pair of Boolean values, as you know if you’ve ever seen truth-tables. The symbol and the symbol’s meaning are different things. The symbol is a syntactic constructor that makes a slightly more complex formula out of two given formulas. The symbol’s meaning returns a Boolean value, given a pair of Boolean-values as input.
- A fancy symbol for “the meaning of” is [[ ]], as in [[∧]], which can be read as “the meaning of ∧”. Is this any better? After all, what’s a meaning? At least we have some notation for distinguishing between ∧ and what ∧ means - and that’s some progress. But we can do a lot better than that with this idea.
- We will write an interpreter - we’ll call it eval - to evaluate the truth- values of Boolean formulas in an environment.
- One possible move that we could make at this point is to make [[∧]] an operator on pairs of Boolean values that returns a Boolean value. We could declare
[[∧]] : {F, T } × {F, T } −→ {F, T }
which says that the meaning of ∧ is a function which takes as input
a pair of Boolean values (that’s the {F, T } × {F, T }) and returns a
Boolean value (that’s the −→ {F, T } part).
- Now that we have declared the function [[∧]] we need to define it. This is mathematics, not a fixed programming language, so there are lot’s of ways we can do that. The simplest one is perhaps the one you are familiar with: truth-tables. A truth-table is just an input/output lookup table for a function: