让“自动”执行案例分析的惯用方法是什么?
What is the idiomatic way to get `auto` to perform case analysis?
Inductive Foo : nat -> Type :=
| a : Foo 1.
(* ... *)
Goal forall m, Foo m -> m = 1.
Proof.
auto.
Fail Qed.
有没有直接的方法来做到这一点?
通过编程语言基础,章节Theory and Practice of Automation in Coq Proofs:
Note that proof search tactics never perform any rewriting step (tactics rewrite
, subst
), nor any case analysis on an arbitrary data structure or property (tactics destruct
and inversion
), nor any proof by induction (tactic induction
). So, proof search is really intended to automate the final steps from the various branches of a proof. It is not able to discover the overall structure of a proof.
所以真的没有办法做到这一点;这个目标应该手动解决,然后添加到提示数据库 (Hint blah.
)。
您可以将 Hint Extern
与执行案例分析的战术脚本一起使用。例如,如果参数是一个变量,这个将使用 destruct
,否则使用 inversion_clear
:
Inductive Foo : nat -> Type :=
| a : Foo 1.
Hint Extern 1 => match goal with
| [ H : Foo ?m |- _ ]
=> first [ is_var m; destruct H | inversion_clear H ]
end.
Goal forall m, Foo m -> m = 1.
Proof.
auto.
Qed.
Inductive Foo : nat -> Type :=
| a : Foo 1.
(* ... *)
Goal forall m, Foo m -> m = 1.
Proof.
auto.
Fail Qed.
有没有直接的方法来做到这一点?
通过编程语言基础,章节Theory and Practice of Automation in Coq Proofs:
Note that proof search tactics never perform any rewriting step (tactics
rewrite
,subst
), nor any case analysis on an arbitrary data structure or property (tacticsdestruct
andinversion
), nor any proof by induction (tacticinduction
). So, proof search is really intended to automate the final steps from the various branches of a proof. It is not able to discover the overall structure of a proof.
所以真的没有办法做到这一点;这个目标应该手动解决,然后添加到提示数据库 (Hint blah.
)。
您可以将 Hint Extern
与执行案例分析的战术脚本一起使用。例如,如果参数是一个变量,这个将使用 destruct
,否则使用 inversion_clear
:
Inductive Foo : nat -> Type :=
| a : Foo 1.
Hint Extern 1 => match goal with
| [ H : Foo ?m |- _ ]
=> first [ is_var m; destruct H | inversion_clear H ]
end.
Goal forall m, Foo m -> m = 1.
Proof.
auto.
Qed.