- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个类型定义为
Inductive bits : nat -> Set :=
| bitsNil : bits 0
| bitsCons : forall {l}, bool -> bits l -> bits (S l).
Lemma emptyIsAlwaysNil : forall {a: bits 0}, a = bitsNil.
intros
, 我试过
constructor 1
,
case a
,
intuition
,无济于事。
case a
似乎是最接近的,但它得到一个错误:
Abstracting over the terms "0" and "a" leads to a term
fun (n : nat) (a0 : bits n) => a0 = bitsNil
which is ill-typed.
Reason is: Illegal application:
The term "@eq" of type "forall A : Type, A -> A -> Prop"
cannot be applied to the terms
"bits n" : "Set"
"a0" : "bits n"
"bitsNil" : "bits 0"
The 3rd term has type "bits 0" which should be coercible to
"bits n".
最佳答案
是的,你基本上是对的:具体来说,Coq 试图构建一个 match
不是类型检查的。在 a:bits 0
(这就是 case
的作用):bitsCons
案件的结论错误。
这是一个无公理的证明。关键思想是手动将语句泛化到任何 n = 0
(我不知道如何用策略来做到这一点;他们都因依赖而绊倒了)。无论是什么n
,等式证明都会进行结论类型检查。是,我们可以忽略 bitsCons
案例,因为我们将有 n = S n'
.中更难bitsNil
案例,我们利用eq_rect_eq_dec
,这是 Axiom K 的结果,但是当类型索引( nat
,在这种情况下)具有可判定的相等性时是可证明的。见 Coq standard library documentation对于其他一些事情,你可以在没有可判定相等的公理的情况下做。
Require PeanoNat.
Require Import Eqdep_dec.
Import EqNotations.
Inductive bits : nat -> Set :=
| bitsNil : bits 0
| bitsCons : forall {l}, bool -> bits l -> bits (S l).
Lemma emptyIsAlwaysNil_general :
forall n (H: n = 0) {a: bits n},
rew [bits] H in a = bitsNil.
Proof.
intros.
induction a; simpl.
(* bitsNil *)
rewrite <- eq_rect_eq_dec; auto.
apply PeanoNat.Nat.eq_dec.
(* bitsCons - derive a contradiction *)
exfalso; discriminate H.
Qed.
Lemma emptyIsAlwaysNil : forall {a: bits 0},
a = bitsNil.
Proof.
intros.
change a with (rew [bits] eq_refl in a).
apply emptyIsAlwaysNil_general.
Qed.
rew H in x
符号来自
EqNotations
(它只是包装
eq_rect
,相等递归原则),但我发现它使事情更具可读性。
JMeq_eq
,您可以更简单地证明这个定理。 (更多细节见
CPDT's equality chapter),从那时起你可以使用
dependent induction
或
dependent destruction
:
Require Import Program.Equality.
Inductive bits : nat -> Set :=
| bitsNil : bits 0
| bitsCons : forall {l}, bool -> bits l -> bits (S l).
Lemma emptyIsAlwaysNil :
forall {a: bits 0}, a = bitsNil.
Proof.
intros.
dependent destruction a; reflexivity.
Qed.
Print Assumptions emptyIsAlwaysNil.
(* Axioms:
JMeq_eq : forall (A : Type) (x y : A), x ~= y -> x = y *)
关于coq - 证明唯一的零长度向量为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47945424/
(这不是关于定理证明,而是关于实践中的测试,例如 quickCheck) 让f一些通用函数 f :: RESTRICTIONS => GENERICS 具有一些“理想的”属性(即不是 hack,是不可
给定数组 arr 和索引数组 ind,以下算法就地重新排列 arr 以满足给定的索引: function swap(arr, i, k) { var temp = arr[i]; arr[i]
我有兴趣创建一个具有运行时间和空间限制的简单数组问题。看来我找到了解决问题的方法。请阅读以下java代码中问题的初始描述注释: /* * Problem: Given two integer ar
我是 isabelle 的新手,并试图证明以下简单的不等式: lemma ineq: "(a::real) > 0 ⟹ a 0 ⟹ b 0" proof have "1/a + 1/b >
是否有任何理论说缓存应该比文件系统更快? 我认为,由于文件系统也使用缓存,因此没有科学证据表明当文件系统的概念有些松散时,我们应该将内容从文件系统移动到诸如 memcache 之类的缓存中——比如下载
我正在做一个证明,我的一个子目标看起来有点像这样: Goal forall (a b : bool) (p: Prop) (H1: p -> a = b) (H2: p), neg
我有定义的归纳类型: Inductive InL (A:Type) (y:A) : list A -> Prop := | InHead : forall xs:list A, InL y (co
我知道 CRC 是一个线性函数,这意味着 CRC(x xor y) = CRC(x) xor CRC(y),但我不知道如何证明 CRC 的这个属性。 有谁有想法吗? 非常感谢! 最佳答案 这通常不是真
我是 Coq 的初学者。 虽然计算机为我验证了证明令人满意,但众所周知,满足 Coq 的证明对人类来说难以阅读。这是一个简单的例子,假设您没有看到任何评论: Theorem add_comm : fo
我试图了解是什么决定了类型参数是否必须是标称的。 虽然 GADT 和类型家族在某种意义上看起来不同,但它们不是“简单容器”,因为它们的实例定义可以“查看”它们的参数,但简单类型是否可以明显需要名义参数
我想使用 function 关键字定义来证明函数定义的正确性。以下是自然数的通常归纳定义上的加法函数的定义: theory FunctionDefinition imports Main begin
我定义了一个 Sygma-Type,如下所示: { R : nat -> nat -> bool | Reflexive R } 我有两个元素 r1 r2 : { R : nat -> nat ->
我有以下数据: new_pairs x y Freq start.latittude start.longitude start.station end.la
出于教育目的,我一直试图通过使用各种语言扩展和单例类型,在 Haskell 中重建《Type-Driven Development with Idris》(即 RemoveElem.idr )一书中的
我定义了一个 Sygma-Type,如下所示: { R : nat -> nat -> bool | Reflexive R } 我有两个元素 r1 r2 : { R : nat -> nat ->
我正在使用Ax DevTools,并且试图弄清楚如何使用相同的构建信息标记多个扫描。现在,我的测试运行如下: class MyTestCase : XCTestCase { func myTest
我正在尝试证明一个函数的正确性,该函数检查数组是否按递增/递减顺序排序或未排序。行为是返回 -1,如果按降序排序,1,如果按升序排序,大小为 1,或包含相同的值,0,如果没有已排序或为空。运行:Fra
我试图证明 Z3(Microsoft 的 SMT 求解器)中的一个归纳事实。我知道 Z3 通常不提供此功能,如 Z3 guide 中所述。 (第 8 节:数据类型),但是当我们限制要证明事实的域时,这
问题已编辑: 如代码中所述,HashSet 和 HashMap 是快速失败的(但这不是保证): void goHashSet() { Set set = new HashSet();
我试图使导航栏中的链接延伸到导航栏的全长。我环顾四周,发现了一些有用的信息,但无法使其正常工作 HTML: To
我是一名优秀的程序员,十分优秀!