Created
June 4, 2020 02:15
-
-
Save liesnikov/fb13653fa80ba4dcd69262867df75ea5 to your computer and use it in GitHub Desktop.
Tactic to do case-analysis on function return values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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