| 1 |
From Corelib.ssr Require Import ssreflect ssrfun ssrbool. |
| 2 |
|
| 3 |
Set Implicit Arguments. |
| 4 |
Unset Strict Implicit. |
| 5 |
Unset Printing Implicit Defensive. |
| 6 |
|
| 7 |
Module isSub. |
| 8 |
(* val_subdef being a primitive projections is what makes it fail *) |
| 9 |
#[projections(primitive)] |
| 10 |
Record axioms_ T (P : pred T) sub_sort : Type := |
| 11 |
Axioms_ { val_subdef : sub_sort -> T }. |
| 12 |
Definition phant_Build T (P : pred T) sub_sort (val_subdef : sub_sort -> T) := |
| 13 |
@isSub.Axioms_ T P sub_sort val_subdef. |
| 14 |
End isSub. |
| 15 |
|
| 16 |
Module SubType. |
| 17 |
Record axioms_ T (P : pred T) S : Type := Class |
| 18 |
{ ssralg_isSub_mixin : isSub.axioms_ P S }. |
| 19 |
Record type T (P : pred T) : Type := |
| 20 |
Pack { sort : Type; class : @SubType.axioms_ T P sort }. |
| 21 |
Definition phant_on_ T (P : pred T) (S : type P) (_ : phant (sort S)) := |
| 22 |
class S. |
| 23 |
Notation on elpi_ctx_entry_1_was_T_ := |
| 24 |
(phant_on_ (Phant _) : axioms_ _ elpi_ctx_entry_1_was_T_). |
| 25 |
Module Exports. |
| 26 |
Coercion sort : type >-> Sortclass. |
| 27 |
Coercion ssralg_isSub_mixin : axioms_ >-> isSub.axioms_. |
| 28 |
Definition val_subdef T (P : pred T) (s : type P) := |
| 29 |
isSub.val_subdef (SubType.ssralg_isSub_mixin (class s)). |
| 30 |
End Exports. |
| 31 |
End SubType. |
| 32 |
Export SubType.Exports. |
| 33 |
|
| 34 |
(* We need a canonical projection so that rewrite can do keyd matching modulo CS inference *) |
| 35 |
Notation val := ((SubType.on _).(isSub.val_subdef)). |
| 36 |
Notation "\val" := ((SubType.on _).(isSub.val_subdef)) (only parsing). |
| 37 |
Notation "\val" := ((_).(isSub.val_subdef)) (only printing). |
| 38 |
|
| 39 |
Module isNmodule. |
| 40 |
Record axioms_ V : Type := Axioms_ { add : V -> V -> V }. |
| 41 |
Definition phant_Build V (add : V -> V -> V) := Axioms_ add. |
| 42 |
End isNmodule. |
| 43 |
|
| 44 |
Module Nmodule. |
| 45 |
Record axioms_ (V : Type) : Type := Class |
| 46 |
{ ssralg_isNmodule_mixin : isNmodule.axioms_ V } as record. |
| 47 |
Record type : Type := |
| 48 |
Pack { sort : Type; class : Nmodule.axioms_ sort }. |
| 49 |
Module Exports. |
| 50 |
Notation nmodType := Nmodule.type. |
| 51 |
Coercion sort : type >-> Sortclass. |
| 52 |
Definition add (s : Nmodule.type) := |
| 53 |
isNmodule.add (Nmodule.ssralg_isNmodule_mixin (Nmodule.class s)). |
| 54 |
End Exports. |
| 55 |
End Nmodule. |
| 56 |
Export Nmodule.Exports. |
| 57 |
|
| 58 |
Module isSemiAdditive. |
| 59 |
Variant axioms_ (U V : Nmodule.type) |
| 60 |
(apply : forall _ : Nmodule.sort U, Nmodule.sort V) : Type := Axioms_. |
| 61 |
Definition phant_Build |
| 62 |
(U V : Nmodule.type) (apply : forall _ : Nmodule.sort U, Nmodule.sort V) := |
| 63 |
@isSemiAdditive.Axioms_ U V apply. |
| 64 |
End isSemiAdditive. |
| 65 |
|
| 66 |
Module Additive. |
| 67 |
Record axioms_ (U V : nmodType) (f : U -> V) : Type := Class |
| 68 |
{ ssralg_isSemiAdditive_mixin : isSemiAdditive.axioms_ f } as record. |
| 69 |
Record type (U V : nmodType) : Type := Pack |
| 70 |
{ sort : U -> V; class : Additive.axioms_ sort }. |
| 71 |
Module Exports. |
| 72 |
Coercion sort : type >-> Funclass. |
| 73 |
End Exports. |
| 74 |
End Additive. |
| 75 |
Export Additive.Exports. |
| 76 |
|
| 77 |
Lemma raddfD U V (f : Additive.type U V) : {morph f : x y / add x y}. |
| 78 |
Admitted. |
| 79 |
|
| 80 |
Module isAddClosed. |
| 81 |
Variant axioms_ (V : Nmodule.type) |
| 82 |
(S : @pred_sort (Nmodule.sort V) (predPredType (Nmodule.sort V))) : Type := |
| 83 |
Axioms_. |
| 84 |
Definition phant_Build (V : Nmodule.type) |
| 85 |
(S : pred_sort (predPredType (Nmodule.sort V))) := Axioms_ S. |
| 86 |
End isAddClosed. |
| 87 |
|
| 88 |
Module AddClosed. |
| 89 |
Record axioms_ (V : Nmodule.type) |
| 90 |
(S : pred_sort (predPredType (Nmodule.sort V))) : Type := |
| 91 |
Class { ssralg_isAddClosed_mixin : isAddClosed.axioms_ S }. |
| 92 |
Record type (V : Nmodule.type) : Type := Pack |
| 93 |
{ sort : pred_sort (predPredType (Nmodule.sort V)); |
| 94 |
_ : AddClosed.axioms_ sort }. |
| 95 |
End AddClosed. |
| 96 |
|
| 97 |
Module isSubNmodule. |
| 98 |
Definition isSubNmodule_U__canonical__ssralg_SubType (V : nmodType) (S : pred V) |
| 99 |
(U : Type) (local_mixin_ssralg_isSub : isSub.axioms_ S U) := |
| 100 |
{| |
| 101 |
SubType.sort := U; |
| 102 |
SubType.class := {| SubType.ssralg_isSub_mixin := local_mixin_ssralg_isSub |} |
| 103 |
|}. |
| 104 |
Definition isSubNmodule_U__canonical__ssralg_Nmodule (U : Type) |
| 105 |
(local_mixin_ssralg_isNmodule : isNmodule.axioms_ U) := |
| 106 |
{| |
| 107 |
Nmodule.sort := U; |
| 108 |
Nmodule.class := {| Nmodule.ssralg_isNmodule_mixin := local_mixin_ssralg_isNmodule |} |
| 109 |
|}. |
| 110 |
Record axioms_ (V : nmodType) (S : pred V) (U : Type) |
| 111 |
(local_mixin_ssralg_isSub : isSub.axioms_ S U) |
| 112 |
(local_mixin_ssralg_isNmodule : isNmodule.axioms_ U) : Type := |
| 113 |
Axioms_ { }. |
| 114 |
Definition phant_Build (V : nmodType) (S : pred V) (U : Type) |
| 115 |
(m : isSub.axioms_ S U) (m0 : isNmodule.axioms_ U) |
| 116 |
:= Axioms_ m m0. |
| 117 |
End isSubNmodule. |
| 118 |
|
| 119 |
Module SubNmodule. |
| 120 |
Record axioms_ (V : nmodType) (S : pred V) (U : Type) : Type := Class |
| 121 |
{ ssralg_isSub_mixin :> isSub.axioms_ S U; |
| 122 |
ssralg_isNmodule_mixin :> isNmodule.axioms_ U; |
| 123 |
ssralg_isSubNmodule_mixin :> isSubNmodule.axioms_ ssralg_isSub_mixin |
| 124 |
ssralg_isNmodule_mixin }. |
| 125 |
Record type (V : nmodType) (S : pred V) : Type := Pack |
| 126 |
{ sort :> Type; class : SubNmodule.axioms_ S sort }. |
| 127 |
Module Exports. |
| 128 |
Coercion ssralg_SubNmodule_class__to__ssralg_Nmodule_class |
| 129 |
(V : nmodType) (S : pred V) (U : Type) (c : SubNmodule.axioms_ S U) := |
| 130 |
{| Nmodule.ssralg_isNmodule_mixin := c |}. |
| 131 |
Coercion ssralg_SubNmodule__to__ssralg_Nmodule |
| 132 |
(V : nmodType) (S : pred V) (s : SubNmodule.type S) := |
| 133 |
{| Nmodule.sort := s; Nmodule.class := SubNmodule.class s |}. |
| 134 |
Coercion ssralg_SubNmodule_class__to__ssralg_SubType_class |
| 135 |
(V : nmodType) (S : pred V) (U : Type) (c : SubNmodule.axioms_ S U) := |
| 136 |
{| SubType.ssralg_isSub_mixin := c |}. |
| 137 |
Coercion ssralg_SubNmodule__to__ssralg_SubType |
| 138 |
(V : nmodType) (S : pred V) (s : SubNmodule.type S) := |
| 139 |
{| SubType.sort := s; SubType.class := SubNmodule.class s |}. |
| 140 |
Canonical join_ssralg_SubNmodule_between_ssralg_Nmodule_and_ssralg_SubType |
| 141 |
(V : nmodType) (S : pred V) (U : SubNmodule.type S) := |
| 142 |
{| SubType.sort := U; SubType.class := SubType.class U |}. |
| 143 |
End Exports. |
| 144 |
End SubNmodule. |
| 145 |
Export SubNmodule.Exports. |
| 146 |
|
| 147 |
Definition HB_unnamed_factory_0 (V : Nmodule.type) (S : pred (Nmodule.sort V)) |
| 148 |
(U : @SubNmodule.type V S) := |
| 149 |
@isSemiAdditive.Axioms_ U V |
| 150 |
(@isSub.val_subdef _ _ _ |
| 151 |
(SubType.ssralg_isSub_mixin (SubType.phant_on_ (Phant _)))). |
| 152 |
|
| 153 |
Canonical isSub_val_subdef__canonical__ssralg_Additive |
| 154 |
(V : Nmodule.type) (S : pred (Nmodule.sort V)) (U : @SubNmodule.type V S) := |
| 155 |
@Additive.Pack (@ssralg_SubNmodule__to__ssralg_Nmodule V S U) V |
| 156 |
(isSub.val_subdef _) (Additive.Class (HB_unnamed_factory_0 U)). |
| 157 |
|
| 158 |
Parameter V : Nmodule.type. |
| 159 |
Parameter S : pred (Nmodule.sort V). |
| 160 |
Parameter U : Type. |
| 161 |
Parameter local_mixin_ssralg_isSub : isSub.axioms_ S U. |
| 162 |
|
| 163 |
Canonical Builders_18_U__canonical__ssralg_SubType := |
| 164 |
@SubType.Pack (Nmodule.sort V) S U |
| 165 |
(@SubType.Class (Nmodule.sort V) S U local_mixin_ssralg_isSub). |
| 166 |
|
| 167 |
Definition HB_unnamed_factory_1 := @isAddClosed.phant_Build V S. |
| 168 |
|
| 169 |
Canonical Builders_4_S__canonical__ssralg_AddClosed := |
| 170 |
@AddClosed.Pack V S (AddClosed.Class HB_unnamed_factory_1). |
| 171 |
|
| 172 |
Parameter addU : U -> U -> U. |
| 173 |
|
| 174 |
Definition HB_unnamed_factory_2 := @isNmodule.phant_Build U addU. |
| 175 |
|
| 176 |
Canonical Builders_4_U__canonical__ssralg_Nmodule := |
| 177 |
@Nmodule.Pack U (Nmodule.Class HB_unnamed_factory_2). |
| 178 |
|
| 179 |
Definition HB_unnamed_factory_3 := |
| 180 |
@isSubNmodule.phant_Build V S U local_mixin_ssralg_isSub HB_unnamed_factory_2. |
| 181 |
|
| 182 |
Canonical Builders_4_U__canonical__ssralg_SubNmodule := |
| 183 |
@SubNmodule.Pack V S U (SubNmodule.Class HB_unnamed_factory_3). |
| 184 |
|
| 185 |
Lemma mulrDl (x y : U) : \val (add x y) = \val (add y x). |
| 186 |
Proof. |
| 187 |
rewrite raddfD. (* but "rewrite [LHS]raddfD." works *) |
| 188 |
Abort. |