1
Inductive Foo : nat -> Type :=
  | a : Foo 1.

(* ... *)

Goal forall m, Foo m -> m = 1.
Proof.
  auto.
Fail Qed.

Is there a straightforward approach to do this?

Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
  • 2
    `auto` is not really geared towards this, unless you want to provide a theory for `Foo` that can solve goals in a "logic programming sytle". I'd suggest defining you own tactic to destruct terms. – ejgallego Jan 07 '18 at 16:18
  • 1
    A. Chlipala's `crush` tactic can handle this. – Anton Trunov Jan 07 '18 at 17:31

2 Answers2

2

You can use Hint Extern together with a tactic script that executes the case analysis. For example, this one will use destruct if the argument is a variable, and use inversion_clear otherwise:

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.
Jason Gross
  • 5,928
  • 1
  • 26
  • 53
1

Via Programming Language Foundations, chapter 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.

So there is really no way to do this; this goal should be solved manually, and then added to the hint database (Hint blah.).

Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46