@@ -111,23 +111,34 @@ 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+ /*
115+ [make-tc.aux B Sol Head Body Rule] builds the rule with the given Head and body
116+ paying attention to the positivity of the
117+ clause
118+ Note: if the Rule being constructed is negative (B = ff), then Rules returns a
119+ solution Sol used inside the proof. If the solution is already given, we
120+ do not run the premise. This would ask Sol to be ground (ground_term S).
121+ Here, for performance issues, we simply check that the solution is not a
122+ flexible term
123+ */
124+ pred make-tc.aux i:bool, i:term, i:prop, i:list prop, o:prop.
125+ make-tc.aux tt _ Head [] Head :- !.
126+ make-tc.aux ff Sol Head [] P :- !, P = if (var Sol) Head true.
127+ make-tc.aux tt _ Head Body (Head :- Body) :- !.
128+ make-tc.aux ff Sol Head Body P :- !, P = if (var Sol) (Body => Head) true.
118129
119130 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,
131+ make-tc Goal Sol RuleBody IsPositive Rule :-
132+ coq.safe-dest-app Goal Class Args ,
133+ get-TC-of-inst-type Class ClassGR,
123134 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 .
135+ std.append Args [Sol] ArgsSol ,
136+ coq.elpi.predicate ClassStr ArgsSol RuleHead ,
137+ make-tc.aux IsPositive Sol RuleHead RuleBody Rule .
127138
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.
139+ pred unwrap-prio i:tc-priority, o:int.
140+ unwrap-prio (tc-priority-given Prio) Prio.
141+ unwrap-prio (tc-priority-computed Prio) Prio.
131142
132143 % returns the priority of an instance from the gref of an instance
133144 pred get-inst-prio i:gref, o:int.
0 commit comments