Skip to content

Commit 66c719a

Browse files
FissoreDgares
authored andcommitted
[TC] premise not run if rigid solution
1 parent ff14ff5 commit 66c719a

File tree

2 files changed

+79
-13
lines changed

2 files changed

+79
-13
lines changed

apps/tc/elpi/tc_aux.elpi

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,24 @@ namespace tc {
111111
get-mode ClassGR M :- tc.class ClassGR _ _ M, !.
112112
get-mode ClassGR _ :- coq.error "[TC]" ClassGR "is an unknown class".
113113

114-
pred make-tc.aux i:bool, i:prop, i:list prop, o:prop.
115-
make-tc.aux _ Head [] Head.
116-
make-tc.aux tt Head Body (Head :- Body).
117-
make-tc.aux ff Head Body (Body => Head).
114+
pred make-tc.aux i:bool, i:term, i:prop, i:list prop, o:prop.
115+
make-tc.aux tt _ Head [] Head :- !.
116+
make-tc.aux ff Sol Head [] P :- !, P = if (var Sol) Head true.
117+
make-tc.aux tt _ Head Body (Head :- Body) :- !.
118+
make-tc.aux ff Sol Head Body P :- !, P = if (var Sol) (Body => Head) true.
118119

119120
pred make-tc i:term, i:term, i:list prop, i:bool, o:prop.
120-
make-tc Ty Inst Body IsPositive Clause :-
121-
coq.safe-dest-app Ty HD TL,
122-
get-TC-of-inst-type HD ClassGR,
121+
make-tc Goal Sol RuleBody IsPositive Rule :-
122+
coq.safe-dest-app Goal Class Args,
123+
get-TC-of-inst-type Class ClassGR,
123124
gref->pred-name ClassGR ClassStr,
124-
std.append TL [Inst] Args,
125-
coq.elpi.predicate ClassStr Args Head,
126-
make-tc.aux IsPositive Head Body Clause.
125+
std.append Args [Sol] ArgsSol,
126+
coq.elpi.predicate ClassStr ArgsSol RuleHead,
127+
make-tc.aux IsPositive Sol RuleHead RuleBody Rule.
127128

128-
pred unwrap-prio i:tc-priority, o:int.
129-
unwrap-prio (tc-priority-given Prio) Prio.
130-
unwrap-prio (tc-priority-computed Prio) Prio.
129+
pred unwrap-prio i:tc-priority, o:int.
130+
unwrap-prio (tc-priority-given Prio) Prio.
131+
unwrap-prio (tc-priority-computed Prio) Prio.
131132

132133
% returns the priority of an instance from the gref of an instance
133134
pred get-inst-prio i:gref, o:int.

apps/tc/tests/hyp_in_conl.v

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
Elpi Accumulate TC.Solver lp:{{
53+
:after "0"
54+
tc-elpi.apps.tc.tests.hyp_in_conl.M3.tc-A _ :- !, coq.error "Should not check for tc-A".
55+
tc-elpi.apps.tc.tests.hyp_in_conl.M3.tc-B _ _ :- !, coq.error "Should not check for tc-B".
56+
}}.
57+
Elpi Typecheck TC.Solver.
58+
59+
Section s.
60+
Context (A : A) (B : B A).
61+
62+
Definition d : C A B := _.
63+
End s.
64+
65+
End M3.

0 commit comments

Comments
 (0)