简体   繁体   English

使用Coq中的负归纳类型证明为假

[英]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将是termxy将是我们可以测试区分的两个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.

相关问题 负平方根的二分算法 - Bisection algorithm for negative square roots Silverlight:尽管HasMorePages为false,但PrintPage无限循环 - Silverlight: PrintPage infinite loop although HasMorePages is false 为什么hasNext()不会为假? - Why won't hasNext() become false? Scala无限while循环,即使条件更改为false - Scala infinite while loop even though condition changed to false 当条件为假时,为什么这个 for 循环会不断增加? - Why does this for loop keep incrementing when the condition is false? Java while循环不会中断(我也将条件设置为false) - Java while loop won't break (I've set my condition to false, too) 使用近似方法实现sqrt方法。 即使条件为假,也无法退出循环 - Implement sqrt method using the approximation approach. Cannot exit loop even the condition is false Scanner method.hasNextInt() 和 if 语句 - 只工作 1 次。 对于下一个循环 - 自动(不等待任何输入)给出 false - Scanner method .hasNextInt() and if statement - works only 1 time. For next loop - automatically (didn't wait any input) gives false Objective-C-循环播放但循环条件为假 - Objective-C - Loop played but loop condition is false 为什么即使条件为假,我的 while 循环仍在运行? - Why is my while loop still running even when the condition is false?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM