はLTACのビットで誘導コンストラクタへf_equal
を専門とする方法です:
Ltac f_equal_ind :=
match goal with
| [ |- ?G ] =>
tryif
(tryif assert (~ G); [ injection |]
then fail else idtac)
then
fail "Not an inductive constructor"
else
f_equal
end.
Require Import List.
Import ListNotations.
Goal forall (a a' : nat) s, a :: s = a' :: s.
intros.
f_equal_ind.
Abort.
Require Import Arith.
Goal 4 mod 2 = 2 mod 2.
Fail f_equal_ind.
(* The command has indeed failed with message:
In nested Ltac calls to "f_equal_ind" and "f_equal_ind", last call failed.
Tactic failure: Not an inductive constructor. *)
私は結果は特に関与していると簡単な方法があった場合、私は驚かないだろうと言わなければなりません。私の考えは、否定された原始的な平等を期待するinjection
を使用して、原始的な平等に取り組んでいるかどうかをテストすることです。入れ子になったtryif
は、assert (~ G); [ injection |]
の部分がテストのためのものであるため、これが作成したサブゴールを保持したくないためです。
これはすばらしいハックです。私は間違いなくこれをより洗練された方法で使用します。 –