Debian Codegraph @

test-suite/success/primproj_tactic_unif.v

raw
1 Module S.
2 #[local] Set Printing Unfolded Projection As Match.
3 #[projections(primitive=yes)]
4 Record state (u : unit) :=
5 { p : nat -> nat }.
6
7 Parameter (u : unit).
8 Parameter (s1 s2 : state u).
9
10 (* Unifying the compatibility constant with the primitive projection *)
11 Goal exists n, ltac:(exact (p u)) s1 n = p _ s1 1.
12 Proof.
13 eexists _.
14 (* Testing both orientations of the unification problem *)
15 lazymatch goal with |- ?a = ?b => unify a b end.
16 lazymatch goal with |- ?a = ?b => unify b a end.
17 Succeed apply eq_refl.
18 symmetry.
19 apply eq_refl.
20 Qed.
21
22 (* Unifying primitive projections with [?h ?a1 .. ?aN] when [N] is bigger than
23 the number of parameters plus 1. This must fail. *)
24 Axiom H : forall (B : Type) (f : forall (_ : nat) (_ : nat) (_ : nat), B) (x1 y1 x2 y2 x3 y3 : nat),
25 @eq B (f x1 x2 x3) (f y1 y2 y3).
26 Goal p _ s1 = p _ s2.
27 Proof.
28 (* [apply H] never succeeds. The test below only makes sure that it does not
29 loop endlessly or overflow the stack. *)
30 Timeout 1 (first [apply H | idtac]).
31 Abort.
32
33 (* Unifying primitive projections with [?h ?a1 .. ?aN] when [N] is exactly the
34 number of parameters plus 1. This must succeed. *)
35 Goal exists (a : forall u, state u -> nat -> nat) (b : unit) c, a b c = p u s1.
36 Proof.
37 eexists _, _, _.
38 (* Testing both orientations of the unification problem *)
39 Succeed apply eq_refl.
40 symmetry.
41 apply eq_refl.
42 Qed.
43
44 (* Unifying primitive projections with [?h ?a1 .. ?aN] when [N] is exactly the
45 number of parameters plus 1 plus the number of proper arguments to the
46 projection. This must succeed. *)
47 Goal exists (a : forall u, state u -> nat -> nat) (b : unit) c d, a b c d = p u s1 0.
48 Proof.
49 eexists _, _, _, _.
50 (* Testing both orientations of the unification problem *)
51 Succeed apply eq_refl.
52 symmetry.
53 apply eq_refl.
54 Qed.
55
56 (* Unifying primitive projections with [?h ?a1 .. ?aN] when [N] is less than
57 the number of parameters plus 1 plus the number of proper arguments to the
58 projection. The head evar [?h] is unified with a partial application of the
59 projection. This must succeed. *)
60 Goal exists (a : state u -> nat -> nat) (b : state u), a b = p u s1.
61 Proof.
62 eexists _, _.
63 (* Testing both orientations of the unification problem *)
64 Succeed apply eq_refl.
65 symmetry.
66 apply eq_refl.
67 Qed.
68
69 End S.
70
71 Module I.
72 #[local] Set Printing Unfolded Projection As Match.
73 Record cmra := Cmra { cmra_car : Type }.
74 Record ucmra := { ucmra_car : Type }.
75
76 #[projections(primitive=yes)]
77 Record ofe (n : nat) := Ofe { ofe_car : Type }.
78
79 Axiom n : nat.
80
81 Definition ucmra_ofeO := fun A : ucmra => @Ofe n (ucmra_car A).
82
83 (* Canonical Structure cmra_ofeO := fun A : cmra => @Ofe n (cmra_car A). *)
84
85 Canonical Structure ucmra_cmraR :=
86 fun A : ucmra =>
87 Cmra (ucmra_car A).
88
89 Axiom A : ucmra.
90 Axiom bla : forall (A : cmra), cmra_car A.
91 Goal ofe_car n (ucmra_ofeO A).
92 Proof.
93 apply @bla.
94 Qed.
95 End I.