@@ -371,6 +371,10 @@ namespace tc {
371371 pi x y\ name-pair P x (s N) => is-uvar x => add-link-eta-dedup F (r-ar M N) P PTy [pr x y|Acc] PremR (Clause x y).
372372 add-link-eta-dedup _ Ar P PTy _ _ _ :- coq.error "[TC] add-link-eta-dedup error" Ar P PTy.
373373
374+ pred deterministic-prem i:gref, i:prop, o:prop.
375+ deterministic-prem TC P (do-once P) :- tc.class TC _ tc.deterministic _, !.
376+ deterministic-prem _ P P.
377+
374378 pred compile-premise
375379 i:list term,
376380 o:list term,
@@ -382,16 +386,14 @@ namespace tc {
382386 i:list term,
383387 i:list prop,
384388 o:prop.
385- compile-premise L L2 P PTy ProofHd IsPositive ITy ProofTlR PremR Clause :-
389+ compile-premise L L2 P PTy ProofHd IsPositive ITy ProofArgsR PremR Clause :-
386390 (pi a b c\ tc.get-TC-of-inst-type (tc.prod-range a c) b :- tc.get-TC-of-inst-type a b) =>
387391 tc.get-TC-of-inst-type PTy TC, !,
388392 compile-ty L L1 P {neg IsPositive} PTy [] [] NewPrem,
389- if (tc.class TC _ tc.deterministic _)
390- (NewPrem' = do-once NewPrem)
391- (NewPrem' = NewPrem),
392- compile-ty L1 L2 ProofHd IsPositive ITy ProofTlR [NewPrem' | PremR] Clause.
393- compile-premise L L1 _ _ ProofHd IsPositive ITy ProofTlR PremR Clause :-
394- compile-ty L L1 ProofHd IsPositive ITy ProofTlR PremR Clause.
393+ deterministic-prem TC NewPrem NewPrem',
394+ compile-ty L1 L2 ProofHd IsPositive ITy ProofArgsR [NewPrem' | PremR] Clause.
395+ compile-premise L L1 _ _ ProofHd IsPositive ITy ProofArgsR PremR Clause :-
396+ compile-ty L L1 ProofHd IsPositive ITy ProofArgsR PremR Clause.
395397
396398 pred compile-ty
397399 i:list term,
@@ -402,39 +404,38 @@ namespace tc {
402404 i:list term,
403405 i:list prop,
404406 o:prop.
405- compile-ty L L1 ProofHd IsPositive (tc.prod-range (prod N Ty Bo) Arity) ProofTlR PremR Clause :- !,
407+ compile-ty L L1 ProofHd IsPositive (tc.prod-range (prod N Ty Bo) Arity) ProofArgsR PremR Clause :- !,
406408 std.do![
407409 if (IsPositive = tt)
408410 (Clause = (pi x\ C x), E = is-uvar)
409411 (clean-term Ty Ty', Clause = (pi x\ decl x N Ty' => C x), E = is-name),
410412 pi p\ sigma F\
411- F = compile-premise L L1 p Ty ProofHd IsPositive (Bo p) [p|ProofTlR ],
413+ F = compile-premise L L1 p Ty ProofHd IsPositive (Bo p) [p|ProofArgsR ],
412414 decl p N Ty' =>
413415 name-pair p p z => E p => add-link-eta-dedup F Arity p Ty [] PremR (C p)
414416 ].
415- compile-ty L L2 ProofHd IsPositive Goal ProofTlR PremR Clause :-
417+ compile-ty L L2 ProofHd IsPositive Goal ProofArgsR PremR Clause :-
416418 std.do![
417- coq.mk-app ProofHd {std.rev ProofTlR} Proof,
418- decompile.decompile-term L L1 Proof Proof' Prem1,
419- decompile.decompile-term L1 L2 Goal Goal' Prem2,
420- compile-conclusion IsPositive Goal' Proof' Prem2 Prem1 {std.rev PremR} Clause
419+ coq.mk-app ProofHd {std.rev ProofArgsR} Proof,
420+ decompile.decompile-term L L1 Proof Proof' EmptyLinks,
421+ std.assert! (EmptyLinks = []) "[TC] should be empty",
422+ decompile.decompile-term L1 L2 Goal Goal' Links,
423+ compile-conclusion IsPositive Goal' Proof' Links {std.rev PremR} Clause
421424 ].
422425
423426 pred compile-conclusion
424427 i:bool, % tt if the term is in positive position
425428 i:term, % the goal (invariant: it is a constant or a application)
426429 i:term, % the proof
427- i:list prop, % the list of HOPremises in input mode
428- i:list prop, % the list of HOPremises in output mode
430+ i:list prop, % the list of links
429431 i:list prop, % the premises
430432 o:prop. % the compiled clause for the instance
431433
432- compile-conclusion tt Goal Proof HOPremisesIn HOPremisesOut Premises Clause :-
433- std.append {std.append HOPremisesIn Premises} HOPremisesOut AllPremises,
434+ compile-conclusion tt Goal Proof Links Premises Clause :-
435+ std.append Links Premises AllPremises,
434436 tc.make-tc Goal Proof AllPremises tt Clause.
435- compile-conclusion ff Goal Proof HOPremisesIn HOPremisesOut Premises Clause :-
436- tc.make-tc Goal Proof Premises ff Clause1,
437- Clause = (do HOPremisesIn, Clause1, do HOPremisesOut).
437+ compile-conclusion ff Goal Proof Links Premises (do Links, Clause) :-
438+ tc.make-tc Goal Proof Premises ff Clause.
438439
439440 pred context i:goal-ctx, o:list prop.
440441 context [] [].
@@ -465,9 +466,9 @@ namespace tc {
465466 % If the instance is polymorphic, we wrap its gref into the pglobal constructor
466467 instance-gr InstGR (pi x\ Clause x) :- coq.env.univpoly? InstGR _, !,
467468 coq.env.typeof InstGR Ty,
468- pi x\ tc.compile. instance Ty (pglobal InstGR x) (Clause x).
469+ pi x\ instance Ty (pglobal InstGR x) (Clause x).
469470 instance-gr InstGR Clause :-
470471 coq.env.typeof InstGR Ty,
471- tc.compile. instance Ty (global InstGR) Clause.
472+ instance Ty (global InstGR) Clause.
472473 }
473474}
0 commit comments