You are on page 1of 4

Formal languages and automata 2023

Solutions to tutorial 8
6 October 2023

1. The signature of the language of arithmetic contains the following symbols:


ˆ the constant symbol 0;
ˆ the unary function symbol s (‘successor’; intuitively, if x stands for a natural
number n, then s(x) stands for the number n + 1);
ˆ the binary function symbols + (addition) and × (multiplication).
As usual, the language of arithmetic contains the equality symbol =.

(a) Define the symbol < so that is has its usual intuitive meaning: x < y means that
x is strictly less than y. In other words, write a formula φ(x, y) containing two
free variables, x and y, such that, from the intuitive point of view, φ(x, y) is true
of natural numbers n and m if, and only if, n < m. Once this is done, you may
assume, for the rest of the questions, that you have < available as part of the
signature.

x < y := ∃z ¬(z = 0) ∧ (x + z = y) .

(b) Translate into the language of arithmetic the following sentences (you may now
freely use the symbol <):
i. There is no largest natural number.

∀x ∃y (x < y).

ii. For every natural number n, there exists no natural number bigger than n
and smaller than n + 1.

∀x ¬∃y (x < y ∧ y < s(x)).

iii. If a natural number is bigger than 0, but less than 3, then it is either 1 or 2.

∀x (0 < x ∧ x < s(s(s(0)))) → (x = s(0) ∨ x = s(s(0))) .

(c) Define the unary predicate letter Prime so that, intuitively, Prime(x) is true if,
and only if, x stands for a prime number. Once this is done, you may assume, for
the rest of the questions, that you have Prime available as part of the signature.

Prime(x) := ∀y ∀z (y × z = x) → (y = s(0) ∨ z = s(0)) ∧ ¬(x = s(0)).

1
(d) Translate into the language of arithmetic the following sentences (you may now
freely use the symbol Prime):
i. There are infinitely many prime numbers.

∀x Prime(x) → ∃y (x < y ∧ Prime(y)) .

ii. Every even number greater than two can be expressed as the sum of two
primes (this is the Goldbach Conjecture).

Even(x) := ∃y y × s(s(0)) = x ;

∀x (Even(x) ∧ s(s(0)) < x)→∃y∃z (Prime(y) ∧ Prime(z) ∧ y + z = x) .

iii. There are infinitely many pairs (n, m) of natural numbers such that m = n + 2
and both n and m are prime (this is the Twin Prime Conjecture).

∀x∀y (Prime(x) ∧ Prime(y) ∧ y = x + s(s(0)))→ 


∃z∃v(Prime(z) ∧ Prime(y) ∧ (y < z ∨ y = z) ∧ v = z + s(s(0))) .

2. Consider again the language of arithmetic from Question 1 and consider the formula
φ = ∀x ∃y (s(x) < y) in this language.
(a) Find a model M1 such that M |= φ.

(N, I), where I(s) is the successor function on N.

M2 = ({0, 1}, I), where I(s) is the following function on {0, 1}: I(s)(0) = 1 and I(s)(1) = 1.
(b) Find a model M2 such that M |= ¬φ.

(c) Write a formula that is true in a model if, and only if, the domain of the model
consists of exactly two elements.

3. Prove, using models, that the following formulas are validities of first-order logic:
(a) ∀x (P (x) ∧ Q(x)) → (∀x P (x) ∧ ∀x Q(x));

Suppose otherwise. Then there exists a model M = (D, I) such that M ̸|= ∀x (P (x)∧Q(x)) →
(∀x P (x) ∧ ∀x Q(x)). Then,
(1) M |= ∀x (P (x) ∧ Q(x));
(2) M |̸ = ∀x P (x) ∧ ∀x Q(x).
By (2), either M ̸|= ∀x P (x) or M ̸|= ∀x Q(x). We consider two cases.
Case M ̸|= ∀x P (x): In this case, there exists a ∈ D such that M ̸|= P (a). By (1),
M |= P (b) ∧ Q(b), for every b ∈ D; in particular, M |= P (a) ∧ Q(a). But then M |= P (a), in
contradiction with M ̸|= P (a).
Case M ̸|= ∀x Q(x): In this case, there exists a ∈ D such that M ̸|= Q(a). By (1),
M |= P (b) ∧ Q(b), for every b ∈ D; in particular, M |= P (a) ∧ Q(a). But then M |= Q(a), in
contradiction with M ̸|= Q(a).

2
(b) ∃x (P (x) ∨ Q(x)) → (∃x P (x) ∨ ∃x Q(x)).

Suppose otherwise. Then there exists a model M = (D, I) such that M ̸|= ∃x (P (x)∨Q(x)) →
(∃x P (x) ∨ ∃x Q(x)). Then,
(1) M |= ∃x (P (x) ∨ Q(x));
(2) M |̸ = ∃x P (x) ∨ ∃x Q(x).
By (2), M ̸|= ∃x P (x) and M ̸|= ∃x Q(x). By (1), there exists a ∈ D such that M |= P (a) ∨ Q(a).
Hence, M |= P (a) or M |= Q(a). We consider two cases.
Case M |= P (a): Since M ̸|= ∃x P (x), it follows that M ̸|= P (b) whenever b ∈ D. In particu-
lar, M ̸|= P (a), in contradiction with M |= P (a).
Case M |= Q(a): Since M ̸|= ∃x Q(x), it follows that M ̸|= Q(b) whenever b ∈ D. In particu-
lar, M ̸|= Q(a), in contradiction with M |= Q(a).
4. Prove, using models, that the following formulas are not validities of first-order logic:
(a) ∀x (P (x) ∨ Q(x)) → (∀x P (x) ∨ ∀x Q(x));

Consider the following model: M = (D, I), where D = {a, b}, I(P ) = {⟨a⟩}, and I(Q) =
{⟨b⟩}. Then M |= P (a) and M |= Q(b). Since D = {a, b}, it follows that M |= ∀x (P (x) ∨ Q(x)).
On the other hand, since M ̸|= P (b), surely M ̸|= ∀x P (x), and since M ̸|= Q(a), surely M ̸|=
∀x Q(x). Hence, M ̸|= ∀x P (x)∨∀x Q(x). Thus, M ̸|= ∀x (P (x)∨Q(x)) → (∀x P (x)∨∀x Q(x)).
This means that ∀x (P (x) ∨ Q(x)) → (∀x P (x) ∨ ∀x Q(x)) is not valid.

(b) (∃x P (x) ∧ ∃x Q(x)) → ∃x (P (x) ∧ Q(x)).


Consider the following model: M = (D, I), where D = {a, b}, I(P ) = {⟨a⟩}, and I(Q) =
{⟨b⟩}. Then M |= P (a); hence, M |= ∃x P (x). Also, M |= Q(b); hence, M |= ∃x Q(x).
Therefore, M |= ∃x P (x) ∧ ∃x Q(x)). On the other hand, there does not exist any c ∈ D such
that both M |= P (c) and M |= Q(c); hence, M ̸|= ∃x (P (x) ∧ Q(x)). Thus, M ̸|= (∃x P (x) ∧
∃x Q(x)) → ∃x (P (x) ∧ Q(x)). This means that (∃x P (x) ∧ ∃x Q(x)) → ∃x (P (x) ∧ Q(x)) is
not valid.

5. Consider the following signature of a language meant for describing a fixed compu-
tation by a fixed Turing machine M (the presumed domain of discourse is natural
numbers, which shall be used to number the steps of the computation and the cells
of M ’s tape; it shall be assumed that the tape of M extends infinitely to the right,
but has the leftmost cell, numbered 0; we shall need a special symbol, the end-of-tape
marker, which shall always be written in the leftmost cell, so that M knows not to
move left of the leftmost cell; the states of M are assumed to be q0 , q1 , etc., with q0
being the starting state, q1 the accepting state, and q2 the rejecting state; the symbols
of M ’s alphabet are assumed to be s0 , s1 , etc., with s0 being the blank and s1 being
the end-of-tape marker):
ˆ the constant symbol 0;
ˆ the unary function symbol s (‘successor’ on natural numbers);
ˆ the binary predicate letter x < y (‘number x is strictly less than number y’);
ˆ the binary predicate letter C(x, y) (‘at step x, the machine M scans cell tape
number y’);
ˆ the unary predicate letter Qk (x) (‘at step x, the machine M is in state qk ’);

3
ˆ the binary predicate letter Sk (x, y) (‘at step x, the cell y contains symbol sk ’).

(a) Write a formula describing the initial configuration of M on the empty word given
as input.
φε = C(0, 0) ∧ Q0 (0) ∧ S1 (0, 0) ∧ ∀x (x ̸= 0 → S0 (0, x)).

(b) Write a formula saying that, at every step of the computation, M scans exactly
one cell of its tape.

φ1 = ∀x ∃y C(x, y) ∧ ∀z (C(x, z) → z = y) .

(c) Write a formula saying that, at every step of the computation, M is in a unique
state.
|Q−1|
_ ^
φ2 = ∀x (Qk (x) ∧ ¬Qj (x)).
k=0 j̸=k

(d) Write a formula saying that, at every step of the computation, each cell of the
tape contains exactly one symbol.
|Γ−1|
_ ^
φ3 = ∀x∀y (Sk (x, y) ∧ ¬Sj (x, y)).
k=0 j̸=k

(e) Suppose that the program of M contains the command qi sk → qj sl R. Write a


formula describing the effect the execution of this command has on the compu-
tation. 
φc = ∀x∀y Qi (x) ∧ Sk (x, y) ∧ C(x, y) →
Qj (s(x)) ∧ Sl (s(x), y) ∧ C(s(x), s(y)) ∧
|Γ−1| 
^ 
∧ ∀z (z ̸= y → (Sk (x, z) → Sk (s(x), z)))) .
k=0

(f) Do the same for the command qi sk → qj sl L.



φc = ∀x∀y Qi (x) ∧ Sk (x, y) ∧ C(x, y) →
Qj (s(x)) ∧ Sl (s(x), y) ∧ ∃v(s(v) = y ∧ C(s(x), v)) ∧
|Γ−1| 
^ 
∧ ∀z (z ̸= y → (Sk (x, z) → Sk (s(x), z)))) .
k=0

(g) Write a formula asserting that M halts.

φhalt = ∃x (Q1 (x) ∨ Q2 (x)).

You might also like