Skip to content

Instantly share code, notes, and snippets.

@liesnikov
Created June 4, 2020 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liesnikov/fb13653fa80ba4dcd69262867df75ea5 to your computer and use it in GitHub Desktop.
Save liesnikov/fb13653fa80ba4dcd69262867df75ea5 to your computer and use it in GitHub Desktop.
Tactic to do case-analysis on function return values
Ltac destruct_fun_explicit T t f :=
match goal with
| |- ?G => let Fn := fresh in
let Hn := fresh in
let En := fresh in
enough (forall x : T, G) as Hn;
[ apply Hn; exact t
| intros Fn; pose (ap := f Fn);
destruct Fn; destruct ap eqn: En; subst ap
]
| _ => idtac
end.
Ltac destruct_fun f :=
match type of f with
| forall _ : ?T, _ =>
let Xn := fresh in
assert (Xn : T);
[ econstructor
| destruct_fun_explicit T Xn f]
| _ => idtac
end.
Goal forall f, f true = 1.
Proof.
intros f.
destruct_fun f.
Admitted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment