@@ -104,8 +104,6 @@ if-MC-compat P :- get-option "mathcomp.axiom" S, !,
104104 P (some GR).
105105if-MC-compat _.
106106
107-
108-
109107% TODO: Should this only be used for gref that are factories? (and check in the first/second branch so?)
110108% Should we make this an HO predicate, eg "located->gref S L is-factory? GR"
111109pred located->gref i:string, i:list located, o:gref.
@@ -696,7 +694,7 @@ phant-fun-struct T Name S Params PF Out :- std.do! [
696694 mk-app (global S) Params SParams,
697695 mk-app SortProj Params SortProjParams,
698696 % Msg = {{lib:hb.nomsg}},
699- Msg = {{lib:hb.some (lib:hb.pair "is not canonically a"%string lp:SParams)}},
697+ Msg = {{lib:hb.some (lib:hb.pair lib:hb.not_a_msg lp:SParams)}},
700698 (@pi-decl Name SParams s\ phant-fun-unify Msg T {mk-app SortProjParams [s]} (PF s) (UnifSI s)),
701699 phant-fun-implicit Name SParams UnifSI Out
702700].
@@ -1853,31 +1851,39 @@ declare-old-constant (some C) :-
18531851 std.forall {coq.locate-all Id} (declare-old-located Id).
18541852declare-old-constant _ :- true.
18551853
1856- pred context->factory i:context-decl, o:factoryname.
1857- context->factory (context-item IDT _ TTySkel none t\ context-item _ _ (TF t) none _\ context-end) GRF :- !,
1858- coq.id->name IDT NameT,
1859- std.assert-ok! (coq.elaborate-ty-skeleton TTySkel _ TTy) "context entry illtyped",
1860- @pi-decl NameT TTy t\
1861- std.assert! (factory? (TF t) (triple GRF _Params t))
1862- "the last argument must be a factory applied to the type variable".
1863- context->factory (context-item ID _ TSkel none Factories) GRF :- !,
1864- coq.id->name ID Name,
1865- std.assert-ok! (coq.elaborate-ty-skeleton TSkel _ T) "context entry illtyped",
1866- @pi-decl Name T x\ context->factory (Factories x) GRF.
1867- context->factory (context-item ID _ _ (some _) _) _ :-
1854+ pred elaborate-context-skel->factory i:context-decl, o:context-decl, o:factoryname, o:diagnostic.
1855+ elaborate-context-skel->factory
1856+ (context-item IDT IT TTySkel none t\ context-item IDF IF (TFSkel t) none _\ context-end)
1857+ (context-item IDT IT TTy none t\ context-item IDF IF (TFSkel t) none _\ context-end) GRF Diag
1858+ :- !, std.do-ok! Diag [
1859+ coq.elaborate-ty-skeleton TTySkel _ TTy,
1860+ (d\ coq.id->name IDT NameT),
1861+ (d\ @pi-decl NameT TTy t\ purge-id (TFSkel t) (TFSkel1 t), coq.elaborate-ty-skeleton (TFSkel1 t) _ (TF1 t) d),
1862+ (d\ @pi-decl NameT TTy t\ std.assert! (factory? (TF1 t) (triple GRF _Params t)) "the last argument must be a factory applied to the type variable"),
1863+ ].
1864+ elaborate-context-skel->factory (context-item ID I TSkel none C) (context-item ID I T none C1) GRF Diag :- !, std.do-ok! Diag [
1865+ coq.elaborate-ty-skeleton TSkel _ T,
1866+ (d\ coq.id->name ID Name),
1867+ (d\ @pi-decl Name T x\ elaborate-context-skel->factory (C x) (C1 x) GRF d),
1868+ ].
1869+ elaborate-context-skel->factory (context-item ID _ _ (some _) _) _ _ _ :-
18681870 coq.error "context item cannot be given a body:" ID.
18691871
1872+ pred purge-id i:term, o:term.
1873+ purge-id T T1 :-
1874+ (pi fresh t v\ copy {{lib:@hb.id lp:t lp:v}} fresh :- !) => copy T T1.
1875+
18701876pred main-begin-declare-builders i:context-decl.
18711877main-begin-declare-builders CtxSkel :- std.do! [
18721878 Name is "Builders_" ^ {term_to_string {new_int}}, % TODO?
1873- context->factory CtxSkel GRF,
1879+ std.assert-ok! (elaborate- context-skel- >factory CtxSkel Ctx GRF) "Context illtyped" ,
18741880 coq.env.begin-module Name none,
18751881 if (GRF = indt FRecord) (std.do! [
18761882 coq.env.begin-module "Super" none,
18771883 std.forall {coq.CS.canonical-projections FRecord} declare-old-constant,
18781884 coq.env.end-module _]) (true),
18791885 coq.env.begin-section Name,
1880- builders-postulate-factories CtxSkel ,
1886+ builders-postulate-factories Ctx ,
18811887].
18821888
18831889pred postulate-factory-abbrev i:term, i:list term, i:id, i:factoryname, o:term.
@@ -1936,7 +1942,7 @@ builders-postulate-factories (context-item IDT _ TySkel none t\ context-item IDF
19361942
19371943builders-postulate-factories (context-item ID _ TSkel none Factories) :- std.do! [
19381944 if-verbose (coq.say "HB: postulating" ID),
1939- std.assert-ok! (coq.elaborate-ty-skeleton TSkel _ T) "builders-postulate-factorie : illtyped context",
1945+ std.assert-ok! (coq.elaborate-ty-skeleton TSkel _ T) "builders-postulate-factories : illtyped context",
19401946 if (var T) (coq.fresh-type T) true,
19411947 @local! => hb-add-const ID _ T @opaque! P, % no body, local -> a variable
19421948 TheParam = global (const P),
0 commit comments