【问题标题】:Logic: All_In can't expand nested forall逻辑:All_In 无法展开嵌套的 forall
【发布时间】:2019-04-25 19:33:28
【问题描述】:

我面临一个非常奇怪的问题:coq 不想将 forall 变量移动到上下文中。

在过去是这样的:

Example and_exercise :
  forall n m : nat, n + m = 0 -> n = 0 /\ m = 0.
Proof.
  intros n m.

它生成:

n, m : nat
============================
n + m = 0 -> n = 0 /\ m = 0

但是当我们在 forall 里面有 forall 时,它就不起作用了:

(* Auxilliary definition *)
Fixpoint All {T : Type} (P : T -> Prop) (l : list T) : Prop :=
  (* ... *)

Lemma All_In :
  forall T (P : T -> Prop) (l : list T),
    (forall x, In x l -> P x) <->
    All P l.
Proof.
  intros T P l. split.
  - intros H.

之后我们得到:

T : Type
P : T -> Prop
l : list T
H : forall x : T, In x l -> P x
============================
All P l

但是如何将 x 移出 H 并将其分解成更小的部分?我试过了:

destruct H as [x H1].

但它给出了一个错误:

Error: Unable to find an instance for the variable x.

这是什么?如何解决?

【问题讨论】:

  • 我已经编辑了这个问题,因为它包含软件基础练习的部分答案。

标签: coq logical-foundations


【解决方案1】:

问题在于forall 嵌套在蕴涵的左侧而不是右侧。从forall x, P x 形式的假设 中引入x 是没有意义的,就像将plus_comm : forall n m, n + m = m + n 中的n 引入另一个上下文一样没有意义证明。相反,您需要通过在正确的位置应用来使用H 假设。我不能给你这个问题的答案,但你可能想参考同一章中的dist_not_exists练习。

【讨论】:

  • 感谢您提供有用的提示,但没有给出答案 :) 对谷歌搜索感到内疚,但非常卡住。现在我可以继续以良好的意识解决问题
猜你喜欢
  • 1970-01-01
  • 2016-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-29
相关资源
最近更新 更多