Debian Codegraph @

apps/tc/tests/patternFragment.v

raw
1 From elpi.apps Require Import tc.
2 Elpi TC Solver Override TC.Solver All.
3 Set TC NameShortPath.
4 Set TC CompilerWithPatternFragment.
5
6 Class Y (A: Type).
7 Class Z (A: Type).
8 Class Ex (P : Type -> Type) (A: Type).
9
10 Module M4.
11 Local Instance Inst2 A F: (forall (a : Type) (b c : nat), Y (F a b) -> Y (F a c)) -> Z A. Qed.
12 Goal Z bool.
13 Elpi TC Solver Override TC.Solver None.
14 Fail apply _.
15 Elpi TC Solver Override TC.Solver All.
16 apply _.
17 Unshelve.
18 assumption. (* we keep a, the first arg of F *)
19 Qed.
20
21 Local Instance Inst1: Y (bool * bool). Qed.
22
23 Goal Z bool.
24 Elpi TC Solver Override TC.Solver None.
25 Succeed apply _.
26 Elpi TC Solver Override TC.Solver All.
27 apply _.
28 Unshelve.
29 assumption.
30 Qed.
31 End M4.
32
33 (* Module M10.
34 Class Y (I: nat).
35 Goal exists F, forall a b c : Type, Y (F a b) -> Y (F c b).
36 eexists.
37 Elpi Trace Browser.
38 apply _. *)
39
40 Module M5.
41 Local Instance Inst1: Y (bool * bool). Qed.
42 Local Instance Inst2 A F (R: Type -> Type -> Type): forall x,
43 (forall (a : Type), Y (F a)) -> Ex (R x) A. Qed.
44 Goal forall (A:Type) x (R: Type -> Type -> Type ->Type), Ex (R x x) A. apply _.
45 Qed.
46 End M5.
47
48 Module M1.
49 Local Instance Inst1: Y (bool * bool). Qed.
50 Local Instance Inst2 A F: (forall (a : Type), Y (F a)) -> Z A. Qed.
51
52 Goal forall (A:Type), Z A. apply _. Qed.
53 End M1.
54
55 Module M2.
56 Local Instance Inst1: Y (bool * bool). Qed.
57 Local Instance Inst2 A F: (forall (a: Type), Y (F a)) -> Z A. Qed.
58 Goal Z bool. apply _. Qed.
59 End M2.
60
61 Module M3.
62 Local Instance Inst1: Y (bool * bool). Qed.
63 Local Instance Inst2 A F: (forall (a b c d: Type), Y (F b c d)) -> Z A. Qed.
64 Goal Z bool. apply _. Qed.
65 End M3.
66
67 (* Module withAnd.
68 Elpi Accumulate TC.Solver lp:{{
69 :before "solve-aux-conclusion"
70 solve-aux (goal _ _ TyRaw _ _ as G) GL :- not (var TyRaw),
71 if (TyRaw = app [global C|_], coq.TC.class? C) fail (GL = [seal G]).
72 }}.
73
74 Module M6.
75 Class and (a : Prop) (b : Prop).
76 Instance andI {a b : Prop} : a -> b -> and a b. Qed.
77 Local Instance Inst2 A F: and (F = fun _ _ => nat)
78 (forall (a b c: Type), Y (F a b) -> Y (F b c)) -> Z A. Qed.
79 Goal Z bool.
80
81 Elpi Bound Steps 1000.
82 Elpi Accumulate TC.Solver lp:{{
83 print-solution.
84 }}.
85 apply _.
86 Unshelve.
87 reflexivity.
88 Qed.
89 End M6.
90
91 (* Module M10.
92 Class and (a : Prop) (b : Prop).
93 Instance andI {a b : Prop} : a -> b -> and a b. Qed.
94 Elpi Accumulate TC.Solver lp:{{
95 :before "solve-aux-conclusion"
96 solve-aux (goal _ _ TyRaw _ _ as G) GL :- not (var TyRaw),
97 if (TyRaw = app [global C|_], coq.TC.class? C) fail (GL = [seal G]).
98 }}.
99
100 Local Instance Inst2 A F: (and (F = fun _ _ => nat)
101 (forall (a b c: Type), Y (F a b) -> Y (F c b))) -> Z A. Qed.
102 Goal Z bool.
103 eapply Inst2.
104 apply andI.
105 (* reflexivity. *)
106 2: {
107 Set Printing Existential Instances.
108 apply _. intros.
109 apply _.
110 Qed.
111 End M10. *)
112 End withAnd. *)
113
114 Module M7.
115 Local Instance Inst2 A F: (forall (a b c: Type), Y (F a b) -> Y nat) -> Z A. Qed.
116 Goal Z bool. apply _. Qed.
117 End M7.
118
119 Module M8.
120 Local Instance Inst2 A F: (forall (a b c: Type), Y nat -> Y (F a b)) -> Z A. Qed.
121 Goal Z bool. apply _. Qed.
122 End M8.
123
124 Module M9.
125 Local Instance Inst2 A F: (forall (a b c: Type), Y (F a b) -> Y (F b c)) -> Z A. Qed.
126 Goal Z bool.
127 eapply _.
128 Unshelve.
129 apply nat.
130 Qed.
131 End M9.
132
133 Module M1b.
134 Local Instance Inst2 A F: (forall (a : Type), Y (F a)) -> Ex F A. Qed.
135
136 Definition goal := forall (A:Type) (f : Type -> Type), (forall x, Y (f x)) ->
137 exists g, Ex g A /\ g nat = g bool.
138
139 Section coq.
140 Elpi TC Solver Override TC.Solver None.
141 Goal goal.
142 Proof.
143 intros ???.
144 (* eexists (fun _ => nat). *)
145 eexists; constructor.
146 apply _.
147 Show Proof.
148 Abort.
149 Elpi TC Solver Override TC.Solver All.
150 End coq.
151
152 Section elpi.
153 Goal goal.
154 Proof.
155 intros ???.
156 eexists; constructor.
157 Show.
158 apply _.
159 Show.
160 reflexivity.
161 Unshelve.
162 apply nat.
163 Qed.
164 End elpi.
165 End M1b.
166