Complexity of Decidable Theories 137
Proof. This is a standard back-and-forth argument. Pick the first element
D in some enumeration of D that is not among the a
i
,0≤ i ≤ k − 1, and
call it a
k
. It lies in some relation to all the a
i
;thatis,foreacha
i
,either
a
k
>a
i
or a
k
<a
i
. Because E is dense and has no endpoints, there must
exist an element b
k
that lies in the same relationship to the b
i
,0≤ i ≤ k−1.
Pick the first such b
k
in some enumeration of E and set f(a
k
)=b
k
.We
have extended the domain of f by one and preserved the fact that it is a
local isomorphism.
Now do the same thing from the other side: pick the first unmatched
element b
k+1
of E and find an element a
k+1
of D to match with it (that
is, make f(a
k+1
)=b
k+1
) preserving local isomorphism. Go back and forth
like this forever. Every element of D and E is eventually matched with
something on the other side, so we get an isomorphism. 2
A Decision Procedure
Let D be a dense linear order without endpoints. (By the result of the
previous section, we might as well take D to be Q.) To decide the sentence
∃x ∀y ∃zx<y∧ (x ≥ z ∨ y = z),
for example, it suffices to pick an arbitrary point a ∈ D andthencheck
whether
∀y ∃za<y∧ (a ≥ z ∨ y = z). (21.1)
It does not matter which a is chosen, because all such a look the same: by
Theorem 21.1, for every a, a
∈ D, there is an automorphism of D mapping
a to a
. Now to check (21.1), we wish to check whether for all b ∈ D,
∃za<b∧ (a ≥ z ∨ b = z). (21.2)
However, there are essentially only three choices for b: either less than a,
equal to a, or greater than a.Ifwepickanyb
0
, b
1
,andb
2
representing
these three respective possibilities respectively, then any other pair (a
,b
)
of elements of D looks like one of (a, b
0
), (a, b
1
), or (a, b
2
). Therefore it
suffices to check (21.2) for b ∈{b
0
,b
1
,b
2
}. Finally, to eliminate the last
quantifier ∃z in (21.2), we pick a c ∈ D in one of finitely many ways. For
(a, b
0
), because b
0
<a, there are essentially five ways to pick c:either
c<b
0
, c = b
0
, b
0
<c<a, c = a,orc>a.For(a, b
1
), there are essentially
three ways to pick c,andfor(a, b
2
)therearefive.
Once we have chosen three elements a, b, c ∈ D and know their relative
order in D, we have enough information to determine the truth or falsity
of the quantifier-free part
a<b∧ (a ≥ c ∨ b = c). (21.3)