Debian Codegraph @

test-suite/ltac2/example1.v

raw
1 Require Import Ltac2.Ltac2.
2
3 Import Ltac2.Control.
4
5 (** Alternative implementation of the hyp primitive *)
6 Ltac2 get_hyp_by_name x :=
7 let h := hyps () in
8 let rec find x l := match l with
9 | [] => zero Not_found
10 | p :: l =>
11 match p with
12 | (id, _, t) =>
13 match Ident.equal x id with
14 | true => t
15 | false => find x l
16 end
17 end
18 end in
19 find x h.
20
21 Print Ltac2 get_hyp_by_name.
22
23 Goal forall n m, n + m = 0 -> n = 0.
24 Proof.
25 refine (fun () => '(fun n m H => _)).
26 let t := get_hyp_by_name @H in Message.print (Message.of_constr t).
27 let t := get_hyp_by_name @H in Message.print (Message.of_lconstr t).
28 Abort.