Debian Codegraph @

src/Util/Tactics/HeadUnderBinders.v

raw
1 Require Export Crypto.Util.FixCoqMistakes.
2
3 (** find the head of the given expression, underneath [fun] and [forall] *)
4 Ltac head_under_binders_gen redtac expr :=
5 let expr := redtac expr in
6 match expr with
7 | ?f _ => head_under_binders_gen redtac f
8 | fun x : ?T => @?f x
9 => lazymatch constr:(fun x : T
10 => ltac:(let f' := (eval cbv beta in (f x)) in
11 let h := head_under_binders_gen redtac f' in
12 exact h)) with
13 | fun _ => ?f => f
14 | ?f => f
15 end
16 | forall x, @?f x
17 => head_under_binders_gen redtac f
18 | ?expr => expr
19 end.
20
21 Ltac head_under_binders expr := head_under_binders_gen ltac:(fun e => e) expr.
22 Ltac head_hnf_under_binders expr := head_under_binders_gen ltac:(fun e => eval hnf in e) expr.