Homework 2

CMU 15-251
Spring 2015
Homework 2 — Writing session on Wednesday January 28
NOTE: On this homework, you may only use facts about regular languages that we proved in
class. More precisely: You may use the fact that if L1 and L2 are regular then so is L1 ∪ L2 . You
may not use the fact that L1 · L2 is regular, or the fact that L∗1 is regular (unless you prove these
facts yourself!). You may not use the theorem that every regular language has a corresponding
regular expression.
1. (SOLO) For each of the following sentences in First Order Logic, determine (and prove)
whether it is “unsatisfiable”, “satisfiable but not a tautology”, or “tautology”.
(a) (∀x (IsPerson(x) ∧ IsCool(x))) ∧ ¬IsCool(a)
(Here IsPerson(·) and IsCool(·) are relation names and a is a constant name.)
(b) ∀x ∀y Plus(x, y) = Plus(y, x)
(Here Plus(·, ·) is a 2-argument function name.)
(c) (∃x ∀y (Next(x) = x ∨ Next(y) = x)) → (∀z ∃x ∀y (Next(x) = x ∨ Next(y) = x))
(Here Next(·) is a 1-argument function name.)
2. (SOLO) Which of the following languages are regular? Prove your answer.
(Remark: if your answer involves drawing a DFA, then you should give some sentences of
explanation for why your DFA is correct. For example, for each state in your DFA, you could
explain in words its “purpose” or “meaning”.)
(a) L = {an bm | n, m > 0, n ≡ m mod 3}, where Σ = {a, b}.
(b) L ⊆ {a, b}∗ is the set of all strings whose second-to-last character is a b.
(c) L = {xwxR | x, w ∈ Σ∗ , |x|, |w| > 0}, where Σ = {a, b} and xR means the reversal of x.
(d) L = {x | x = xR , x ∈ Σ∗ }, where Σ = {a, b}.
(e) L = {x ∈ {1}∗ | x is the unary representation of a nonnegative integer power of 2},
where Σ = {1}, and the unary representation of, e.g., 5 is 11111.
(f) L = {x ∈ {0, 1}∗ | x is the binary representation of a nonnegative integer power of 2},
where Σ = {0, 1}. Any string beginning with the character 0 is not the valid binary
representation of any positive number; e.g., the only correct representation of 5 in binary
is 101.
3. (GROUP) Let L denote the set of all strings in {a, b}∗ that contain abb or aab as a substring.
(a) Draw a DFA with five states that recognizes L.
(b) Show that any DFA that decides L must have at least five states.
1
4. (GROUP) In this question we will define a new computing machine: DFAs with magical
superpowers. We’ll call them MFAs. Just like a DFA, an MFA is a 5-tuple (Q, Σ, δ, q0 , F ).
The only difference is that in an MFA, the transition function δ has the form δ : Q × Σ →
P(Q), where P(Q) denotes the powerset of Q (which includes the empty set). A string
w = a1 a2 . . . an is accepted by an MFA if there exists a sequence of states (r0 , r1 , r2 , . . . , rn )
such that:
(i) r0 = q0 , i.e., r0 is the initial state,
(ii) ri ∈ δ(ri−1 , ai ), for i ∈ {1, 2, . . . , n},
(iii) rn ∈ F .
We can draw an MFA similar to how we draw a DFA. For example, the following is an MFA:
Note that there are a few differences from a DFA. Given a state, there might be multiple edges
going out of it corresponding to the same symbol. For example, q0 has two edges going out of
it labeled with 1. Also, there is not necessarily an edge going out of a state that corresponds
to every possible symbol. For example, there is no edge going out of q1 with the label 1. Let’s
say we have the string 101. There are multiple paths we can take when we read this string
since at q0 we have two options when reading a 1. If one of these possible paths ends in an
accepting state, then the MFA accepts the string. In the case of 101, the string is accepted
because the sequence (q0 , q0 , q0 , q1 ) is one of the allowed paths, and it ends in an accepting
state.
We will now extend our definition even more. Define an SFA to be a machine that is just like
an MFA, but it is allowed to have transitions (edges) labeled with ε. For example:
When processing a string, if we are at some state q, and this state has an edge labeled with ε,
then we are allowed to follow that edge and go to the next state without consuming any
2
input symbol. (In the example above, the ε transitions basically allow us to start at state
q1 or state q3 .) As in an MFA, a string is accepted if there is some path we can follow that
ends in an accepting state. For example, the string 00 is accepted by the SFA above because
we can first take the ε transition to go to state q3 (without consuming the first symbol of the
string), and then read a 0 symbol to stay at q3 , and finally read a 0 symbol again to go from
q3 to q4 .
(a) (Optional.) Give a more symbolically precise definition of what it means for an SFA to
accept a string w, akin to the (i),(ii),(iii) description above for MFAs.
(b) Show that a language recognized by any SFA is a regular language.
Hint: It might help to first do this for an MFA.
(c) Show that if L1 and L2 are regular languages, then so is L1 · L2 .
(d) Show that if L is a regular language, then so is L∗ .
5. (OPEN) Consider First Order Logic together with the following vocabulary:
One constant name:
One two-argument function name:
Z
+(·, ·)
No relation names.
Suppose we take the following axioms:
A1:
A2:
A3:
A4:
A5:
∀x ((+(x, Z) = x) ∧ (+(Z, x) = x))
∀x ∃y (+(x, y) = Z ∧ +(y, x) = Z)
∀w ∀x ∀y +(+(w, x), y) = +(w, +(x, y))
∃a ∃b ∃c (¬(a = b) ∧ ¬(b = c) ∧ ¬(c = a) ∧ ¬(a = Z) ∧ ¬(b = Z) ∧ ¬(c = Z))
∀v ∀w ∀x ∀y (v = w)∨(v = x)∨(v = y)∨(v = Z)∨(w = x)∨(w = y)∨(w = Z)∨(x = y)∨(x = Z)∨(y = Z)
(a) Suppose I is an interpretation making all five axioms true. What must be the cardinality
of I’s universe?
(b) Prove that the axioms are simultaneously satisfiable; i.e., that there exists an interpretation I that simultaneously makes all five axioms true.
(c) Deduce that this set of axioms is “consistent”, meaning there does not exist a FOL
sentence R such that both A1, . . . , A5 |= R and A1, . . . , A5 |= ¬R.
(d) Prove that this set of axioms is “incomplete”, meaning there exists a FOL sentence S
such that neither A1, . . . , A5 |= S nor A1, . . . , A5 |= ¬S.
(e) (Optional.) Suppose you take your sentence S from part (d) and add it in as a new
axiom, calling it A6. Is the collection {A1, . . . , A6} then “complete”? Argue informally
why or why not.
6. (SOLO/OPEN) Read the article by Hales at http://arxiv.org/pdf/1302.2898v1.pdf
If you don’t understand all the mathy parts that’s okay.
Do some reading about any topic or idea mentioned in the article. You may use Internetsearching for this! Write an interesting paragraph or two explaining what you learned. This
problem is “OPEN” in the sense that you can talk to anyone you want about the article and
your reading. It is “SOLO” in the sense that you should choose what you will read and write
about yourself.
3