@@ -61,8 +61,10 @@ declare Module B :- std.do! [
6161 if-verbose (coq.say "HB: start module Exports"),
6262
6363 log.coq.env.begin-module "Exports",
64- if-arg-sort (private.declare-sort-coercion Structure (global (const ArgSortCst))),
65- private.declare-sort-coercion Structure SortProjection,
64+
65+ private.infer-coercion-tgt MLwP CoeClass,
66+ if-arg-sort (private.declare-sort-coercion CoeClass Structure (global (const ArgSortCst))),
67+ private.declare-sort-coercion CoeClass Structure SortProjection,
6668
6769 if-verbose (coq.say "HB: exporting unification hints"),
6870 ClassAlias => Factories => GRDepsClauses =>
@@ -92,7 +94,7 @@ declare Module B :- std.do! [
9294
9395 if-verbose (coq.say "HB: declaring on_ abbreviation"),
9496
95- private.mk-infer-key ClassProjection NilwP (global Structure) PhClass,
97+ private.mk-infer-key CoeClass ClassProjection NilwP (global Structure) PhClass,
9698
9799 phant.add-abbreviation "on_" PhClass _ ClassOfAbbrev,
98100 (pi c\ coq.notation.abbreviation ClassOfAbbrev [c] (ClassOfAbbrev_ c)),
@@ -101,13 +103,12 @@ declare Module B :- std.do! [
101103
102104 coq.mk-app (global ClassName) {params->holes NilwP} AppClassHoles,
103105 @global! => log.coq.notation.add-abbreviation "Build" 2
104- {{fun T C => (lp:(ClassOfAbbrev_ C) : (lp:AppClassHoles T))}} tt ClassForAbbrev ,
106+ {{fun T C => (lp:(ClassOfAbbrev_ C) : (lp:AppClassHoles T)) }} tt _ ,
105107
106108 if-verbose (coq.say "HB: declaring on abbreviation"),
107109
108- (pi t\ coq.notation.abbreviation ClassForAbbrev [t, t] (ClassForAbbrevDiag t)),
109110 @global! => log.coq.notation.add-abbreviation "on" 1
110- {{fun T => lp:(ClassForAbbrevDiag T)}} tt _,
111+ {{fun T => ( lp:{{ ClassOfAbbrev_ {{_}} }} : (lp:AppClassHoles T)) }} tt _,
111112
112113 log.coq.env.end-module-name Module ModulePath,
113114
@@ -146,6 +147,14 @@ namespace private {
146147
147148shorten coq.{ term->gref, subst-fun, safe-dest-app, mk-app, mk-eta, subst-prod }.
148149
150+
151+ pred infer-coercion-tgt i:list-w-params mixinname, o:class.
152+ infer-coercion-tgt (w-params.cons ID Ty F) CoeClass :-
153+ @pi-parameter ID Ty x\ infer-coercion-tgt (F x) CoeClass.
154+ infer-coercion-tgt (w-params.nil _ {{ Type }} _) sortclass.
155+ infer-coercion-tgt (w-params.nil _ {{ _ -> _ }} _) funclass.
156+ infer-coercion-tgt (w-params.nil _ _ _) _ :- coq.error "TODO1".
157+
149158% const Po : forall p1 .. pm T m1 .. mn, Extra (Eg Extra = forall x y, x + y = y + z)
150159% const C : forall p1 .. pm s, Extra
151160% Po P1 .. PM T M1 .. MN PoArgs -> C P1 .. PM S PoArgs
@@ -166,7 +175,7 @@ clean-op-ty [exported-op _ Po C|Ops] S T1 T2 :-
166175
167176pred operation-body-and-ty i:list prop, i:constant, i:structure, i:term, i:term,
168177 i:list term, i:term, i:w-args A, o:pair term term.
169- operation-body-and-ty EXI Poperation Struct Psort Pclass Params _T (triple _ Params _) (pr Bo Ty) :- std.do! [
178+ operation-body-and-ty EXI Poperation Struct Psort Pclass Params _T (triple _ ParamsOp _) (pr Bo Ty) :- std.do! [
170179 mk-app (global Struct) Params StructType,
171180 mk-app Psort Params PsortP,
172181 mk-app Pclass Params PclassP,
@@ -177,7 +186,7 @@ operation-body-and-ty EXI Poperation Struct Psort Pclass Params _T (triple _ Par
177186 mk-app PclassP [s] Class,
178187 synthesis.under-mixin-src-from-factory.do! Carrier Class [
179188 % just in case..
180- synthesis.infer-all-mixin-args Params Carrier (const Poperation) (Body s),
189+ synthesis.infer-all-mixin-args ParamsOp Carrier (const Poperation) (Body s),
181190 std.assert-ok! (coq.typecheck (Body s) (DirtyTy s)) "export-1-operation: Body illtyped",
182191 clean-op-ty EXI s (DirtyTy s) (BodyTy s),
183192 ],
@@ -272,7 +281,7 @@ mk-coe-structure-body StructureF StructureT TC Coercion SortProjection ClassProj
272281 {coq.mk-n-holes {factory-nparams TC}} PackPH,
273282
274283 SCoeBody = {{ fun s : lp:StructureP =>
275- let T : Type : = lp:SortP s in
284+ let T := lp:SortP s in
276285 lp:PackPH T (lp:CoercionP T (lp:ClassP s)) }},
277286].
278287
@@ -461,13 +470,13 @@ declare-class+structure MLwP (indt ClassInd) (indt StructureInd) SortProjection
461470 global (const ClassP) = ClassProjection,
462471].
463472
464- % Declares "sort" as a coercion Structurename >-> Sortclass
465- pred declare-sort-coercion i:structure, i:term.
466- declare-sort-coercion StructureName (global Proj) :-
473+ % Declares "sort" as a Coercion Proj : Structurename >-> CoeClass.
474+ pred declare-sort-coercion i:class, i: structure, i:term.
475+ declare-sort-coercion CoeClass StructureName (global Proj) :-
467476
468477 if-verbose (coq.say "HB: declare sort coercion"),
469478
470- log.coq.coercion.declare (coercion Proj 0 StructureName sortclass ).
479+ log.coq.coercion.declare (coercion Proj 0 StructureName CoeClass ).
471480
472481pred if-class-already-exists-error i:id, i:list class, i:list mixinname.
473482if-class-already-exists-error _ [] _.
@@ -566,19 +575,22 @@ pred mk-infer i:term, i:list-w-params mixinname, o:phant-term.
566575mk-infer T (w-params.nil _ _ _) PH :- phant.init T PH.
567576mk-infer T (w-params.cons ID Ty W) R :- (get-option ID "Type" ; get-option ID ""), !,
568577 @pi-parameter ID Ty t\ mk-infer {mk-app T [t]} (W t) (PhT t),
569- phant.fun-infer-type {coq.id->name ID} Ty PhT R.
578+ phant.fun-infer-type sortclass {coq.id->name ID} Ty PhT R.
579+ mk-infer T (w-params.cons ID Ty W) R :- (get-option ID "_ -> _"), !,
580+ @pi-parameter ID Ty t\ mk-infer {mk-app T [t]} (W t) (PhT t),
581+ phant.fun-infer-type funclass {coq.id->name ID} Ty PhT R.
570582mk-infer T (w-params.cons ID Ty W) R :- not (get-option ID _), !,
571583 @pi-parameter ID Ty t\ mk-infer {mk-app T [t]} (W t) (PhT t),
572584 phant.fun-real {coq.id->name ID} Ty PhT R.
573585mk-infer _ (w-params.cons ID _ _) _ :- get-option ID Infer,
574586 coq.error "Automatic inference of paramter" ID "from" Infer "not supported".
575587
576- pred mk-infer-key i:term, i:list-w-params mixinname, i:term, o:phant-term.
577- mk-infer-key K (w-params.nil ID _ _) St PhK :-
588+ pred mk-infer-key i:class, i: term, i:list-w-params mixinname, i:term, o:phant-term.
589+ mk-infer-key CoeClass K (w-params.nil ID _ _) St PhK :-
578590 @pi-parameter ID St t\ phant.init {mk-app K [t]} (PhKBo t),
579- phant.fun-infer-type {coq.id->name ID} St PhKBo PhK.
580- mk-infer-key K (w-params.cons ID Ty W) St R :-
581- @pi-parameter ID Ty t\ mk-infer-key {mk-app K [t]} (W t) {mk-app St [t]} (PhT t),
591+ phant.fun-infer-type CoeClass {coq.id->name ID} St PhKBo PhK.
592+ mk-infer-key CoeClass K (w-params.cons ID Ty W) St R :-
593+ @pi-parameter ID Ty t\ mk-infer-key CoeClass {mk-app K [t]} (W t) {mk-app St [t]} (PhT t),
582594 phant.fun-implicit {coq.id->name ID} Ty PhT R.
583595
584596pred if-coverage-not-good-error i:list mixinname.
0 commit comments