我不确定我是否能完全回答您的问题,但是我会试一试,并提出一些我自己的问题,这些问题可能会激发对此问题的进一步讨论。
我的第一点是这样的:两个术语在无类型λ演算被说成是可观察地等于每术语IFF 中号:
中号吨 终止 ⇔ 中号吨' 终止
在哪里终止装置“具有β -正常形式”t,t′
λM
M t terminates ⇔M t′ terminates
β
我发现考虑带有“空洞”或上下文
的术语而不是简单地使用术语M并写E [ t ]而不是M t更为自然。这两种观点当然是相当的(如果变量没有上下文的约束),作为抽象允许你打开上下文
é [ _ ]进入长期λ X 。E [ x ]。E[_]ME[t]M tE[_]λx.E[x]
现在,这是一个事实,即在无类型演算观察平等没有捕获由 -equality!确实存在一整类术语,它们既不终止也不具有正态范式,因此可以观察到地相等。这些有时被称为永久术语或不可解术语,这里是两个这样的术语:
(λ X 。X X )(λ X 。X X )
和
(λ X 。X X X )(λ X 。βη
(λx.x x)(λx.x x)
这是很容易证明,这些条件不
β η -EQUal。
(λx.x x x)(λx.x x x)
βη
如果确定了所有永久性术语,则经典结果将完全捕获观察相等性(请参见Barendregt定理16.2.7)。
现在用于键入结石。让我们首先考虑不带自然数的简单类型的
演算。随着每个术语的归一化,上述观察性平等的定义变得微不足道!我们需要更好的区分。对于封闭项,我们将使用值相等性
t 1 ↓ t 2,由对t 1和t 2的类型的归纳定义。让我们先来添加每种类型的一个,常量无限数量的ç 一,ç ' 一,ç “ 一,...。我们将选择一些常数c xλt1↓t2t1t2AcA,c′A,c′′A,…cx对应于每个变量的适当类型。x
在基本类型,吨1 ↓ 吨2当且仅当β的-head正常形式吨1是ç Ù 1 ... Ü Ñ和的吨2是d v 1 ... v Ñ和C ^ = d和ü 1 ↓ v 1,... ,ü ñ ↓ v ň在各自的类型。Bt1↓t2βt1c u1…unt2d v1…vnc=du1↓v1,…,un↓vn
如果使用箭头类型,则均将两个项β-都减小为
λ-吸收量。t1↓t2βλ
注意,在此定义中我仅使用 conversion。β
现在,我定义背景是:
具有标题上下文,应用,抽象和替换(按闭合术语)。
[_]∣E[_] u∣t E[_]∣λx. E[_]∣E[_]θ
然后,当且仅当对于每个上下文E [ _ ]
使得E [ t ] ,E [ t ' ]的类型正确且封闭时,我们才能将类型为T的和t '定义为在观察上等效。
E [ t ] ↓ E [ t ' ]tt′TE[_]E[t],E[t′]
E[t]↓E[t′]
,我们将写
在这种情况下
t=obst′
现在很容易观察到,如果然后
吨= ö b 小号吨'。另一个方向是没有价值的,但也适用:事实上,如果吨= ö b 小号吨',那么我们可以表明,该术语是相等的β η通过感应的类型:t=βηt′t=obst′t=obst′βη
E[_][_]θθxcxE[t]=tθE[t′]=t′θtθ→βcx u1θ…unθt′θ→βcx′ v1θ…vnθ. We
then have cx=cx′ and so x=x′. Now we can't immediately conclude that
uiθ=βηviθ. Indeed, if ui and vi are
λ-abstractions, then trivially uiθ↓viθ! The trick here is to send x to
λy⃗ .cx~ (y1c1→)…(yncn→)
and to repeat this as many times as necessary. I'm a bit fuzzy on the
details here, but the idea is similar to Böhm's theorem (Barendregt again
10.4.2).
At arrow type, take E[_] to be [_] cy, i.e. application to
cy with cy and y not in t or t′. By the induction hypothesis we have:
t cy =βη t′ cy
and so
t y =βη t′ y
Which gives λy.t y =βη λ.t′ y and
finally by η-equality:
t =βη t′
That was harder than expected!
Alright let's tackle system T. Let's add a type N to the mix,
constructors 0 and S, and a recursor recT for each
type T, with the "β-rules"
recT u v 0→βu
recT u v (S n)→βv n (recT u v n)
We want to prove the same theorem as above. It's tempting to add
"η-rules" to prove equivalences like:
λx.x =βη recN 0 (λk m.S m)
where the term on the right is the "stupid
identity" that peels off
m successors just to add them again.
For example let's add this rule:
f (S x) =βη h x (f x)f t =βηrecT (f 0) h t
where
x is a fresh variable as in the usual
η rule. Now note that
this rule is recursively enumerable (you can try every possible
choice for
h).
Can we prove the same theorem as above? Unfortunately, as you
suspected, you're going to run into some Gödel nastiness, or rather,
the Kleene variant (see Wikipedia). For every Turing machine M, it's easy to build a term tM in system T such that tM (S… S 0) (with n Ses) returns 1 if M finishes
in at most n steps and 0 otherwise.
So now if M does not terminate, you can ask whether the
(true) equation
tM =λx.0
is provable using the
βη rules above. But taking
M
to be the machine that terminates iff
0 =βη S 0
is provable in system
T (with the above rules), you're going to
run into trouble, i.e. the equation
tM=λx.0 is true but not provable (or
Peano Arithmetic is inconsistent!).