[英]Proving False with negative inductive types in Coq
The third chapter of CPDT briefly discusses why negative inductive types are forbidden in Coq. CPDT的第三章简要讨论了为什么在Coq中禁止负归纳类型。 If we had 如果我们有
Inductive term : Set :=
| App : term -> term -> term
| Abs : (term -> term) -> term.
then we could easily define a function 然后我们可以轻松定义一个函数
Definition uhoh (t : term) : term :=
match t with
| Abs f => f t
| _ => t
end.
so that the term uhoh (Abs uhoh)
would be non-terminating, with which "we would be able to prove every theorem". 因此, uhoh (Abs uhoh)
一词将是非终止的,“我们将能够证明每一个定理”。
I understand the non-termination part, but I don't get how we can prove anything with it. 我理解非终止部分,但我不知道如何用它来证明任何东西。 How would one prove False
using term
as defined above? 如何使用上面定义的term
证明False
?
Reading your question made me realize that I didn't quite understand Adam's argument either. 阅读你的问题让我意识到我也不太了解亚当的论点。 But inconsistency in this case results quite easily from Cantor's usual diagonal argument (a never-ending source of paradoxes and puzzles in logic). 但是在这种情况下的不一致很容易从Cantor通常的对角线论证 (逻辑上的悖论和谜题的永无止境的来源)中得到。 Consider the following assumptions: 考虑以下假设:
Section Diag.
Variable T : Type.
Variable test : T -> bool.
Variables x y : T.
Hypothesis xT : test x = true.
Hypothesis yF : test y = false.
Variable g : (T -> T) -> T.
Variable g_inv : T -> (T -> T).
Hypothesis gK : forall f, g_inv (g f) = f.
Definition kaboom (t : T) : T :=
if test (g_inv t t) then y else x.
Lemma kaboom1 : forall t, kaboom t <> g_inv t t.
Proof.
intros t H.
unfold kaboom in H.
destruct (test (g_inv t t)) eqn:E; congruence.
Qed.
Lemma kaboom2 : False.
Proof.
assert (H := @kaboom1 (g kaboom)).
rewrite -> gK in H.
congruence.
Qed.
End Diag.
This is a generic development that could be instantiated with the term
type defined in CPDT: T
would be term
, x
and y
would be two elements of term
that we can test discriminate between (eg App (Abs id) (Abs id)
and Abs id
). 这是一个通用的开发,可以使用CPDT中定义的term
类型进行实例化: T
将是term
, x
和y
将是我们可以测试区分的两个term
元素(例如App (Abs id) (Abs id)
和Abs id
)。 The key point is the last assumption: we assume that we have an invertible function g : (T -> T) -> T
which, in your example, would be Abs
. 关键点是最后的假设:我们假设我们有一个可逆函数g : (T -> T) -> T
,在你的例子中,它是Abs
。 Using that function, we play the usual diagonalization trick: we define a function kaboom
that is by construction different from every function T -> T
, including itself. 使用该函数,我们使用通常的对角化技巧:我们定义一个函数kaboom
,它的构造不同于每个函数T -> T
,包括它自己。 The contradiction results from that. 矛盾的结果就是这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.