On observing β equivalence

On observing β equivalence
Ralph Loader
June 2003
Abstract
We consider at a notion of observational equivalence for λ→ , that
includes β conversion but not η conversion, and prove an undecidability result.
The proof proceeds by encoding β matching [1].
The equivalence, and the idea of encoding β matching in this, were
suggested by Jim Laird.
1
With top
We make use of λ→ with a single ground type 0, and a constant ⊥A of each
type A and another constant > : 0. Depending on your favourite formulation
of λ→ , we quotient syntax by α-conversion and now ignore it. Weak-head
reduction gives an operational semantics for the closed terms: Every r : A
has a weak-head normal form which is either a λ-abstraction λx: B. t or >
(we write r ⇓ λx: B. t or r ⇓ > or just r ⇓) or has head symbol ⊥C (we write
r ⇑).
We now define the observational pre-order 6>
obs on closed terms, by recursion on types using a logical relations style definition:
0
0
• If r, r0 : 0, then r 6>
obs r iff r ⇓ implies r ⇓.
0
• If f, f 0 : A ⇒ B and f ⇑ then f 6>
obs f .
0
0
• If f, f 0 : A ⇒ B and f ⇓ then f 6>
obs f iff f ⇓ and
0 0
f r 6>
obs f r
0
for all closed r, r0 : A such that r 6>
obs r .
There is a logical relations lemma. The logical relations lemma proof needs
to be slightly modified to take account of ⇓.
1
0
Lemma 1 Suppose that x1 : A1 . . . xm : Am ` s : B and that ri 6>
obs ri for
i = 1 . . . m. Then
>
0 m
s[xi /ri ]m
i=1 6obs s[xi /ri ]i=1
The logical relations lemma implies that 6>
obs really is a pre-order, that it
agrees with the usual simulation style of defining observational pre-orders,
and that it includes β-equivalence.
Lemma 2
1. 6>
obs is reflexive.
>
2. If r1 ≡β r2 6>
obs r3 ≡β r4 then r1 6obs r4 .
0
0
3. Suppose f 6>
obs f : A ⇒ B. Then f 6obs f is equivalent to: if
0
0
f ⇓ λx: A. s, then there is s : B with f ⇓ λx: A. s0 and such that
0
s[x/r] 6>
obs s [x/r] for all closed r : A.
4. 6>
obs is transitive.
0
>
We define observational equivalence from the pre-order: r ≡>
obs r iff r 6obs
r0 6>
obs r.
The following lemma follows by induction on the type:
Lemma 3 ≡>
obs has only finitely many equivalence classes at each type.
2
Encoding β-matching
The proof of the result of [1] makes essential use of distinguishing βη-equivalent
but β-inequivalent terms. As 6>
obs makes such a distinction, one wonders if
it is possible to relate them.
We show that in fact we can encode β-matching within 6>
obs in a certain
manner. We do not carry out a general encoding of β-matching, but restrict
ourselves to the form of equations used in [1].
The exact form of equations we use are pairs of equations in the form:
F X = λz: 7 . z
G X = λx, y: 0 . x
where 7 is the type 0 ⇒ . . . ⇒ 0 ⇒ 0 with 7 parameters, and F : A ⇒ 7,
G : A ⇒ 0 ⇒ 0 ⇒ 0 for some arbitrary type A. We call such a pair of
equations a β-pair. A solution to a β-pair is a closed term r : A that makes
both the equations true, up to β-conversion. Then from [1] we have:
2
Theorem 4 The existance of solutions to β-pairs is not decidable.
To prove the above takes a little care, due to the constants in our language.
It turns out that solving β-pairs up to β-equivalence is the same as solving
them up to ≡>
obs :
Lemma 5
1. For closed f : 7⇒7, we have f ≡β λz: 7. z iff f ≡>
obs λz: 7. z.
2. For closed g : 0 ⇒ 0 ⇒ 0, we have g ≡β λx, y: 0. x iff g ≡>
obs λx, y: 0. x.
3. A β-pair is solvable up to ≡β iff it is solvable up to ≡>
β.
Putting together lemmas 3 and 5 with theorem 4, we get:
Theorem 6 The number of equivalence classes of ≡>
obs at a type A is not a
computable function of A.
>
We conjecture that ≡>
obs is not decidable (which would imply that 6obs is not
decidable either).
3
Topless
The next step is to remove the constant > from the language. For this
topless language, we can repeat the definitions of the observational pre-order
and equivalence, but this time equating all closed terms of type 0. We denote
these by 6obs and ≡obs .
The basic properties of 6>
obs carry over unchanged to 6obs . However, 2 of
lemma 5 does not carry over; at type 0⇒0⇒0, ≡obs has only two equivalence
classes (⊥ and values).
Also, the equivalence classes of ≡obs at type 0⇒0 are ⊥0⇒0 and λx: 0. x ≡obs
λx: 0. ⊥0 , which is isomorphic to 6>
obs at type 0. This observation carries over
to higher types, and this allows us to encode the topped setting into the topless.
We define type lifting on the topless language as usual. If T is a type,
then (·)T denotes the operation of substituting T for the ground type 0. On
types, 0T = T , (A ⇒ B)T = AT ⇒ B T . Type-lifting can also be done on
terms, by lifting all type decorations. In particular, (⊥A )T = ⊥AT .
We extend (·)0⇒0 to map the topped language into the topless language,
by setting >0⇒0 = λx: 0. x.
Lemma 7
1. For every closed topless s : B 0⇒0 there is topped s> : B
such that s0⇒0
≡obs s. s> is a computable function of s.
>
3
0⇒0
2. This gives a computable order isomorphism between B/ ≡>
/ ≡obs .
obs and B
Proof: β-conversion is contained in ≡obs . By β-reducing s if needed, we
may assume that s has the property that all sub-terms have a type which
either is 0 or is in the for A0⇒0 .
We construct s> by recursion on
x1 : A0⇒0
. . . xm : A0⇒0
` s : B 0⇒0 .
1
m
If s is in the form λx: 0 . . . , so that B = 0, then set s> = >. Otherwise s is in
one of the forms λx: B00⇒0 . s0 or ⊥B 0⇒0 or f r, and we define s> by applying
the construction to the immediate sub-terms. (Note that by our assumed
form of s is normal, the types of f and r must be in the form (·)0⇒0 ).
One can verify that this gives the required isomorphism when B = 0 as
follows. First show that (·)> commutes with substitution, and that if s>
weak-head reduces to s0> then s weak-head reduces to s0 . Now, if s> weakhead reduces to a term with weak-head symbol ⊥C then s weak-head reduces
to a term with weak-head symbol ⊥C 0⇒0 , while if s> weak-head reduces to
>, then s weak-head reduces to a λ-abstraction λx: 0 . . . .
An induction on the type B shows that (·)> and (·)0⇒0 give the required
order isomorphism.
As an immediate consequence we can encode theorem 6 to give:
Theorem 8 The number of equivalence classes of ≡obs at a type A is not a
computable function of A.
Similarly, our conjecture that ≡>
obs is not decidable would also imply that
≡obs and 6obs are not decidable.
References
[1] Ralph C. Loader. Higher order β matching is undecidable. Logic Journal
of the IGPL, 11(1):51–68, 2003.
4