- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
任务。
假设我们给 Coq 如下定义:
Inductive R2 : nat -> list nat -> Prop :=
| c1 : R2 0 []
| c2 : forall n l, R2 n l -> R2 (S n) (n :: l)
| c3 : forall n l, R2 (S n) l -> R2 n l.
以下哪些命题是可以证明的?
我证明了三分之二。
Example Example_R21 : R2 2 [1;0].
Proof.
apply c2. apply c2. apply c1.
Qed.
Example Example_R22 : R2 1 [1;2;1;0].
Proof.
repeat constructor.
Qed.
3-rd不可证,因为c3只会增加n,永远不会等于表头+1。但是如何形式化地证明它不可证呢?
Example Example_R23 : not (R2 6 [3;2;1;0]).
Proof.
Qed.
更新 1
Fixpoint gen (n: nat) : list nat :=
match n with
| 0 => []
| S n' => (n' :: gen n')
end.
Lemma R2_gen : forall (n : nat) (l : list nat), R2 n l -> l = gen n.
Proof.
intros n l H. induction H.
- simpl. reflexivity.
- simpl. rewrite IHR2. reflexivity.
- simpl in IHR2. ?
最佳答案
您必须在 R2
上进行归纳。基本上,如果您有 R2 6 (3::_)
,那么它必须是一个 c3
(没有其他构造函数适合),因此它包含一个 R2 7 (3::_)
,也一定是c3
,其中包含R2 8 (3::_)
等,这个链是无限的,所以你永远不会到达尽头。因此,您可以使用 False
作为归纳的目标,您将永远不会达到 实际上 必须生成 False
的基本情况。仅仅使用 inversion
是不够的。反转实际上只是所需归纳的一个步骤,对上下文中的任何其他事物进行归纳都无济于事。
在归纳过程中,第一个参数会发生变化。具体来说,它总是大于 S 3
(这就是让我们排除其他构造函数的原因),因此我们需要对 k
进行概括,其中第一个参数是总是 5 + k
(对于我们有 6
的情况,从 k = 1
开始)。
Example Example_R23 : not (R2 6 [3;2;1;0]).
Proof.
set (xs := [2; 1; 0]).
change 6 with (5 + 1).
set (x := 3). (* sets are not strictly needed, but help clean things up *)
generalize 1 as k.
intros k.
(* Everything up to here is just generalizing over k *)
remember (S (S x) + k) as n eqn:prf_n.
remember (x :: xs) as l eqn:prf_l.
intros no.
revert k prf_n prf_l.
induction no as [ | n' l' _ _ | n' l' _ rec_no]
; intros k prf_n prf_l.
- discriminate.
- injection prf_l as -> ->.
discriminate.
- subst.
(* Everything up to here is combined inversion and induction *)
eapply rec_no.
+ apply plus_n_Sm.
+ reflexivity.
Defined.
我们可以通过使用实验性的 dependent induction
策略极大地减少这个证明,它取代了中间的 inversion
y 部分。
Example Example_R23 : not (R2 6 [3;2;1;0]).
Proof.
set (xs := [2; 1; 0]).
change 6 with (5 + 1).
set (x := 3).
generalize 1 as k.
intros k no.
dependent induction no generalizing k.
eapply IHno.
- apply plus_n_Sm.
- reflexivity.
Defined.
另一种清理形式是将广义证明提取到引理中:
Lemma R2_head x k xs : ~R2 (S (S x) + k) (x :: xs).
Proof.
intros no.
dependent induction no generalizing k.
- clear no IHno. (* Another "infinite chain" contradiction *)
rename x into prf_x, x0 into x.
induction x as [ | x rec_x].
+ discriminate.
+ injection prf_x.
apply rec_x.
- eapply IHno.
+ apply plus_n_Sm.
+ reflexivity.
Defined.
Example Example_R232 : not (R2 6 [3;2;1;0]) := R2_head 3 _ _.
关于coq - IndProp : prove that Prop is not provable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63177515/
考虑以下片段: import Data.List %default total x : Elem 1 [1, 2] x = Here type : Type type = Elem 1 [1, 2]
我有以下目标: ∀x ∈ {0,1,2,3,4,5}. P x 我想将这个目标分解为六个子目标 P 0、P 1、P 2、P 3、P 4 和 P 5。这可以通过 apply auto 轻松完成。但是 a
我有以下目标: ∀x ∈ {0,1,2,3,4,5}. P x 我想将这个目标分解为六个子目标 P 0、P 1、P 2、P 3、P 4 和 P 5。这可以通过 apply auto 轻松完成。但是 a
我是一个绝对的初学者,不是程序员,正在尝试使用 Logic and Proof 学习形式验证.我无法在精益中导入任何东西。 我将二进制文件的 tar 文件提取到 /tmp 然后执行 /tmp/lean
如果我理解正确(主要来自 applyTactic 函数的存在),则可以为 Idris 中的定理证明器编写自定义策略。我可以用什么(或哪里)的例子来学习如何做到这一点? 最佳答案 在 Idris 中有两
我正在尝试使用 Kowalski 图算法来求解定理证明。算法的描述位于 http://www.doc.ic.ac.uk/~rak/对于如何处理大事件却保持沉默它生成的重复子句的数量。我想知道是否有处理
Z3有一个prove()方法,可以证明两个公式的等价性。 但是,我找不到此prove() 方法的技术文档。 prove() 在幕后使用的“等价”的定义是什么?那是“部分等价”(在“回归验证”论文中提出
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
任务。 假设我们给 Coq 如下定义: Inductive R2 : nat -> list nat -> Prop := | c1 : R2 0 [] | c2 : forall n l, R2 n
我(错误地)学习了关于验证并发程序的类(class),到目前为止我们已经介绍了这种称为“Owicki-Gries 方法”的方法。显然,可以通过将断言与每个语句相关联来证明有关程序的各种结果,并表明这些
我有 2 个公式 F1 和 F2。这两个公式共享大多数变量,除了一些具有不同名称的“临时”(或我称它们为“免费”)变量,这是出于某些原因。 现在我想证明 F1 == F2,但是 Z3 的 prove(
在 3D 渲染(或几何图形)中,在光栅化算法中,当您将三角形的顶点投影到屏幕上,然后查找像素是否与 2D 三角形重叠时,您通常需要查找深度或像素重叠的三角形的 z 坐标。一般来说,该方法包括计算三角形
我有 2 个公式 F1 和 F2。这两个公式共享大多数变量,除了一些具有不同名称的“临时”(或我称它们为“免费”)变量,这是出于某些原因。 现在我想证明 F1 == F2,但是 Z3 的 prove(
我有一个Map可能有相同类型的嵌套映射。每个嵌套映射都有一个指向外部映射的引用。 我定义了 findValue方法查看当前映射,如果没有找到任何内容,则转到其父级,依此类推,直到到达 null这是最外
我正在试验 CoNat 的定义取自 this paper作者:Jesper Cockx 和 Andreas Abel: open import Data.Bool open import Relati
我们的客户要求我们针对我们的 Web 应用程序(ASP.NET 4.5.2、Webforms)运行 OWASP ZAP 工具,我们不能在报告中有任何高优先级的发现。 我们已经完成分析,OWASP ZA
我有几个 .t文件夹中的文件。每个测试脚本都会启动自己的 Selenium 实例,因此会打开自己的浏览器。然后它们将它们的指令传递给单独模块中的页面对象。唉,页面对象是大多数测试断言发生的地方。 我使
我的部分测试套件依赖于 API URL。有时我想使用另一个 URL 运行我的测试。有没有办法将此参数传递给 prove,或者我是否需要编辑定义 API URL 的文件? 最佳答案 可以在测试程序中设置
如何证明 Cubical Agda 中的两件事不相等? (v2.6.1, Cubical repo 版本 acabbd9 ) 具体来说,这里是作为更高归纳类型的整数: {-# OPTIONS --sa
我正在尝试证明在Agda中的简单引理,我认为这是对的。 If a vector has more than two elements, taking its head following taking
我是一名优秀的程序员,十分优秀!