@@ -160,37 +160,14 @@ declare Module BSkel Sort :- std.do! [
160160
161161 @global! => log.coq.notation.add-abbreviation "on" 1
162162 {{fun T => (lp:{{ ClassOfAbbrev_ {{_}} }} : (lp:AppClassHoles T)) }} tt
163- OnAbbrev,
164-
165- log.coq.env.begin-module "EtaAndMixinExports" none,
166-
167- if (get-option "primitive" tt) true (
168- if-verbose (coq.say {header} "eta expanded instances"),
169- NewClauses => std.do! [
170- w-params.fold MLwP mk-fun
171- (private.mk-hb-eta.on Structure SortProjection OnAbbrev) EtaInstanceBody,
172- w-params.fold MLwP (mk-parameter explicit)
173- (private.mk-hb-eta.arity Structure ClassName SortProjection)
174- EtaInstanceArity,
175- instance.declare-const "_" EtaInstanceBody EtaInstanceArity _
176- ]
177- ),
178-
179- % std.flatten {std.map NewMixins mixin->factories} NewFactories,
180- % NewClauses => std.forall NewFactories instance.declare-factory-sort-factory,
181-
182- log.coq.env.end-module-name "EtaAndMixinExports" EtaExports,
163+ _OnAbbrev,
183164
184165 log.coq.env.end-module-name Module ModulePath,
185166
186167 if-verbose (coq.say {header} "end modules; export" Exports),
187168
188169 export.module {calc (Module ^ ".Exports")} Exports,
189170
190- if-verbose (coq.say {header} "export" EtaExports),
191-
192- export.module {calc (Module ^ ".EtaAndMixinExports")} EtaExports,
193-
194171 if-verbose (coq.say {header} "exporting operations"),
195172 ClassAlias => Factories => GRDepsClauses =>
196173 private.export-operations Structure SortProjection ClassProjection MLwP [] EX MLToExport,
@@ -360,8 +337,6 @@ pred declare-coercion i:term, i:term, i:class, i:class.
360337declare-coercion SortProjection ClassProjection
361338 (class FC StructureF FMLwP) (class TC StructureT TMLwP) :- std.do! [
362339
363- acc-clause current (sub-class FC TC),
364-
365340 gref->modname StructureF 2 "_" ModNameF,
366341 gref->modname StructureT 2 "_" ModNameT,
367342 CName is ModNameF ^ "_class__to__" ^ ModNameT ^ "_class",
@@ -393,41 +368,10 @@ declare-coercion SortProjection ClassProjection
393368
394369 log.coq.CS.declare-instance SC,
395370
396- if-verbose (coq.say {header} "declare coercion path compression rules"),
397-
398- findall-classes All,
399- CurrentTgtClass = (class TC StructureT TMLwP),
400- std.filter All (sub-class? CurrentTgtClass) AllTgtSuper,
401- std.map AllTgtSuper class_structure AllTgtSuperStructures,
402-
403- mk-compression-clauses StructureF StructureT AllTgtSuperStructures AllCompressionClauses,
404- std.forall AllCompressionClauses (c\ log.coq.env.accumulate current "hb.db" (clause _ _ c)),
371+ w-params.nparams FMLwP NparamsSC,
372+ acc-clause current (sub-class FC TC SC NparamsSC)
405373].
406374
407-
408- pred mk-compression-clauses i:gref, i:gref, i:list gref, o:list prop.
409- mk-compression-clauses _ _ [] [].
410- mk-compression-clauses StructureF StructureT [StructureE|Rest] Res :- std.do! [
411- std.assert! (coq.coercion.db-for (grefclass StructureF) (grefclass StructureT) [pr C1 Nparams1]) "wrong number of coercions",
412- std.assert! (coq.coercion.db-for (grefclass StructureT) (grefclass StructureE) [pr C2 Nparams2]) "wrong number of coercions",
413- std.assert! (coq.coercion.db-for (grefclass StructureF) (grefclass StructureE) [pr C3 Nparams3]) "wrong number of coercions",
414- coq.mk-app (global C1) {coq.mk-n-holes Nparams1} F,
415- coq.mk-app (global C2) {coq.mk-n-holes Nparams2} G,
416- coq.mk-app (global C3) {coq.mk-n-holes Nparams3} H,
417- RuleSkel = {{ fun x => lp:G (lp:F x) = lp:H x}},
418- std.assert-ok! (coq.elaborate-skeleton RuleSkel _ Rule) "coercion composition fails",
419- (((pi X L\ coq.fold-map X L X [X|L] :- var X, not(std.exists L (same_var X))) => coq.fold-map Rule [] Rule Holes,
420- mk-compression-clause Holes Rule Clause,
421- mk-compression-clauses StructureF StructureT Rest Clauses,
422- Res = [Clause|Clauses]) ; (Res = [])),
423- ].
424-
425- pred mk-compression-clause i:list term, i:term, o:prop.
426- mk-compression-clause [] (fun _ _ x\ app[_,_,LHS x,RHS x]) (pi x\ C x) :-
427- pi x\ copy (LHS x) (L x), copy (RHS x) (R x), C x = (pi tmp\ compress (L x) (R x)).
428- mk-compression-clause [UV|Rest] T (pi v\ R v) :-
429- pi v\ (pi U\ copy U v :- same_var U UV, !) => mk-compression-clause Rest T (R v).
430-
431375pred join-body i:int, i:int, i:structure, i:term, i:term, i:term, i:term, i:term,
432376 i:list term, i:name, i:term, i:(term -> A), o:term.
433377join-body N1 N2 S3 S2_Pack S1_sort S3_to_S1 S2_class S3_to_S2
@@ -714,32 +658,4 @@ sigT->list-w-params {{ lib:@hb.sigT _ lp:{{ fun N Ty B }} }} L C :-
714658 @pi-decl N Ty t\
715659 product->triples (B t) (Rest t) C.
716660
717- pred mk-hb-eta.on i:structure, i:term, i:abbreviation,
718- i:list term, i:name, i:term, i:A, o:term.
719- mk-hb-eta.on Structure SortProjection OnAbbrev
720- Params NT _T _ (fun NT Ty Body) :- !, std.do! [
721- coq.mk-app (global Structure) Params Ty,
722- @pi-decl NT Ty s\ sigma Tm\ std.do! [
723- coq.mk-app {{lib:@hb.eta}}
724- [_, {coq.mk-app SortProjection {std.append Params [s]}}]
725- Tm,
726- std.assert-ok! (coq.typecheck Tm _) "HB: eta illtyped",
727- coq.notation.abbreviation OnAbbrev [Tm] (Body s)
728- ]
729- ].
730-
731- pred mk-hb-eta.arity i:structure, i:classname, i:term, i:list term,
732- i:name, i:term, i:A, o:arity.
733- mk-hb-eta.arity Structure ClassName SortProjection
734- Params NT _T _ Out :- !, std.do! [
735- coq.mk-app (global Structure) Params Ty,
736- (@pi-decl NT Ty s\ sigma Tm\ std.do! [
737- coq.mk-app {{lib:@hb.eta}}
738- [_, {coq.mk-app SortProjection {std.append Params [s]}}] Tm,
739- std.assert-ok! (coq.typecheck Tm _) "HB: eta illtyped",
740- coq.mk-app (global ClassName) {std.append Params [Tm]} (Concl s)
741- ]),
742- Out = parameter {coq.name->id NT} explicit Ty s\ arity (Concl s)
743- ].
744-
745661}}
0 commit comments