coq - “econstructor”的相反(?)命令是什么
问题描述
例如,
Lemma ex_1:
exists n, n=1.
Proof.
显示一个子目标:
exists n : nat, n = 1
econstructor 命令将目标更改为
?n = 1
可以得到什么命令
exists n : nat, n = 1
再次从“?n = 1”?
或者,假设我们为此证明了一些带有 (exists n, ~) 形式的 sublemma。我们如何“应用”这个sublemma?
解决方案
Théo Winterhalter 给出了一些在这种情况下有效的策略,但总的来说,在某些意义上econstructor
是不可逆的。
econstructor
可以将两种不同的证明状态带到相同的最终状态。
也就是说,econstructor
在证明状态上不是单射的。例如,考虑这种(相当愚蠢的)情况。
Inductive exists': Prop :=
| intro (n: nat): n = 1 -> exists'.
Goal exists'.
Proof.
econstructor.
我们最终得到完全相同的结束状态,即使起始目标(之前econstructor
)不同。
econstructor
一般会丢失信息。
即使我们知道原始状态是什么,也可能无法回到原来的状态。对于这个例子,我们将使用inhabited
标准库,但它同样适用于exists
,因为inhabited A
它等价于exists a: A, True
.
Goal forall A: Type, inhabited A -> inhabited A.
Proof.
intros A H.
econstructor.
现在证明状态是
1 subgoal
A : Type
H : inhabited A
______________________________________(1/1)
A
我们想用它H
来解决目标。但这(通常)是不可能的。我们不能仅仅从 type 元素A
存在的陈述开始并生成 type 的实际术语A
。问题是因为H
是 a Prop
,如果目标也是 a ,我们可以破坏它(或匹配它)Prop
。使用之后econstructor
,情况就不再如此了,所以我们必须有一个明确的类型见证A
。在您的示例中,它有效,因为我们确切知道nat
满足的哪个元素n = 1
,但一般来说,我们不知道
证明助手Lean 使用一般语句forall A, nonempty A -> A
(nonempty
与 Coq 相同inhabited
)为其经典逻辑库提供支持。Coq 中的排中证明同样适用(假设功能外延和命题外延)。所以,如果我们有forall A: Type, inhabited A -> A
,那么排中律,甚至选择公理的一些强版本,都是可证明的(加上一些外延公理)。
另请注意,当您使用 时econstructor
,任何存在变量最终都必须使用当前上下文中存在的值进行实例化。如果你有H: exists n: nat, n = 1
,你必须在使用H
前econstructor
破坏。
Hypothesis H: exists n: nat, n = 1.
Goal exists n: nat, n = 1.
Proof.
destruct H as [x H].
econstructor.
exact H.
Defined.
Goal exists n: nat, n = 1.
Proof.
econstructor.
destruct H as [x H].
Fail exact H.
Abort.
推荐阅读
- networking - Juniper SRX 210 vlan 接口配置
- powerbi - 将 DAX 度量保存到表中(ABC /帕累托分析)
- python - OSError:使用 ytree 的文件不存在
- laravel - 如何通过一个 foreach 循环完成三个 foreach 循环的工作?
- java - 如何点击 SearchView 中的建议?
- google-chrome-devtools - canvas渲染性能分析
- binding - SwiftUI - 关闭 NavigationLink 目标视图并更新主 NavigationView - EXC_BAD_ACCESS(代码=2
- powerapps - 用户需要什么权限才能创建和使用 powerapp?
- c++ - 获取资源管理器的项目视图标题的高度
- reactjs - 如何根据反应中的下拉值过滤引导表