Debian Codegraph @

apps/tc/tests/hyp_in_conl.v

raw
1 From elpi.apps Require Import tc.
2
3 (*
4 Here we want to test that if the solution of a premise is rigid
5 then the premise is not run
6 *)
7
8 Module M1.
9 Structure ofe := Ofe { ofe_car : Type; }.
10
11 Class D (I : ofe).
12
13 Class C (X : ofe) (I : D X).
14
15 Definition ofe_nat : ofe := Ofe nat.
16
17 Instance c : forall (H : D (Ofe nat)), C ofe_nat H := {}.
18
19 Goal forall (H : D (Ofe nat)), True -> exists H, C (ofe_nat) H.
20 intros.
21 notypeclasses refine (ex_intro _ _ _ ).
22 apply _.
23 Qed.
24 End M1.
25
26 Module M2.
27
28 Class A.
29 Class B (I : A).
30 Class C (A : A) (I : B A).
31
32 Instance c : forall (A : A) (B : B A), C A B := {}.
33
34 Goal forall (A : A) (B : B A), exists A B, C A B.
35 intros.
36 do 2 notypeclasses refine (ex_intro _ _ _ ).
37 apply _.
38 Qed.
39
40 End M2.
41
42 Module M3.
43
44 Class A.
45 Class B (I : A).
46 Class C (A : A) (I : B A).
47
48 Instance c : forall (A : A) (B : B A), C A B := {}.
49
50 Set Warnings "+elpi".
51
52 Section s.
53 Elpi Accumulate TC.Solver lp:{{
54 :before "0" tc-elpi.apps.tc.tests.hyp_in_conl.M3.tc-A _ :- coq.say "In tc-A", fail.
55 :before "0" tc-elpi.apps.tc.tests.hyp_in_conl.M3.tc-B _ _ :- coq.say "In tc-B", fail.
56 }}.
57
58 Local Instance AX : A := {}.
59 Local Instance BX : A -> (B AX) := {}.
60
61 Definition d : C AX (BX _) := _.
62 Definition d' : C _ (BX _) := _.
63 Definition d'' : C AX _ := _.
64
65 Check (c _ _) : C AX _.
66
67 (*
68 Here we give the solver a partial solution with a hole in it. This hole
69 correspond to the premise of the typeclass B (an instance of A). Due to
70 the var condition on the resolution of rule's premises, the premise of
71 `C`, that is, `B X` is not solved since we have the partial solution `BX
72 _`. (see: [here](https://github.com/LPCIC/coq-elpi/blob/889bd3fc16c31f35c850edf5a0df2f70ea9c655a/apps/tc/elpi/tc_aux.elpi#L124))
73 *)
74 Elpi Query TC.Solver lp:{{
75 S = {{c AX (BX _)}},
76 tc.solve-aux1 [] {{C _ _}} S.
77 }}.
78
79 End s.
80
81 End M3.