如何return一个(intro'd)假设回到目标公式?

How to return a (intro'd) hypothesis back to the goal formula?

证明:

Parameter A B : Prop.
Goal A->B.
intro A.

我得到:

 1 subgoals
A : A
______________________________________(1/1)
B

如何return然后A回到目标部分?至 return 至:

1 subgoals
______________________________________(1/1)
A -> B

使用revert战术:

revert A.

正好是intro的倒数,cf. the reference manual.

你可以使用revert策略。

考虑到 Coq 的大量策略,每种策略都有不同的极端情况和不同质量的文档,您不知道使用哪种策略是很常见的。

在这种情况下,我发现将您的证明视为一个程序(请参阅 Curry-Howard 同构)并问问自己必须编写什么术语才能解决您的目标很有用。这种方法的优点是 Coq 的术语语言更容易学习(因为没有那么多不同种类的术语)并且表现力足以解决所有可以用策略解决的目标(尽管有时证明更冗长)。

您可以使用 refine 策略以术语语言编写您的证明。 refine 的参数是一个有漏洞的术语 _refine 使用该术语排出当前目标,并为该术语中的每个洞生成一个子目标。一旦您了解了 refine 的工作原理,您所要做的就是想出一个可以满足您要求的术语。例如:

  • refine (_ h) 还原假设 h
  • 引入假设 hrefine (fun h => _)
  • refine ((fun h' => _) h) 复制假设 h

请注意,Coq 的策略往往会在幕后施展魔法。例如,revert 策略在处理因变量时比上面的 refine "smarter":

Goal forall n:nat, n >= 0.
  intro n; revert n.      (* forall n : nat, n >= 0 *)
Restart.
  intro n; refine (_ n).  (* nat -> n >= 0 *)
Restart.
  intro n'; refine ((_ : forall n, n >= 0) n').   (* forall n : nat, n >= 0 *)
Abort.