11From Coq Require Import ZArith.
22
3+ From HB Require Import structures.
34From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path.
45From mathcomp Require Import div choice fintype tuple finfun bigop finset prime.
56From mathcomp Require Import order binomial ssralg countalg ssrnum ssrint.
@@ -41,19 +42,19 @@ Implicit Types (m n : Z).
4142Fact eqZP : Equality.axiom Z.eqb.
4243Proof . by move=> x y; apply: (iffP idP); lia. Qed .
4344
44- Canonical Z_eqType := EqType Z (EqMixin eqZP).
45- Canonical Z_choiceType := ChoiceType Z (CanChoiceMixin int_of_ZK).
46- Canonical Z_countType := CountType Z (CanCountMixin int_of_ZK).
45+ #[export]
46+ HB.instance Definition _ := hasDecEq.Build Z eqZP.
4747
48- Definition Z_zmodMixin :=
49- ZmodMixin Zplus_assoc Zplus_comm Zplus_0_l Zplus_opp_l.
50- Canonical Z_zmodType := ZmodType Z Z_zmodMixin.
48+ #[export]
49+ HB.instance Definition _ := Countable.copy Z (can_type int_of_ZK).
5150
52- Definition Z_ringMixin :=
53- RingMixin
54- Zmult_assoc Zmult_1_l Zmult_1_r Zmult_plus_distr_l Zmult_plus_distr_r isT.
55- Canonical Z_ringType := RingType Z Z_ringMixin.
56- Canonical Z_comRingType := ComRingType Z Zmult_comm.
51+ #[export]
52+ HB.instance Definition _ := GRing.isZmodule.Build Z
53+ Zplus_assoc Zplus_comm Zplus_0_l Zplus_opp_l.
54+
55+ #[export]
56+ HB.instance Definition _ := GRing.Zmodule_isComRing.Build Z
57+ Zmult_assoc Zmult_comm Zmult_1_l Zmult_plus_distr_l isT.
5758
5859Definition unitZ := [qualify a n : Z | (n == Z.pos xH) || (n == Z.neg xH)].
5960Definition invZ n := n.
@@ -67,20 +68,15 @@ Proof. case: m n => [|[m|m|]|[m|m|]] [|n|n] //= []; lia. Qed.
6768Fact invZ_out : {in [predC unitZ], invZ =1 id}.
6869Proof . exact. Qed .
6970
71+ #[export]
72+ HB.instance Definition _ := GRing.ComRing_hasMulInverse.Build Z
73+ mulVZ unitZPl invZ_out.
74+
7075Fact idomain_axiomZ m n : (m * n = 0)%R -> (m == 0%R) || (n == 0%R).
7176Proof . by case: m n => [|m|m] []. Qed .
7277
73- Canonical Z_unitRingType :=
74- UnitRingType Z (ComUnitRingMixin mulVZ unitZPl invZ_out).
75- Canonical Z_comUnitRing := [comUnitRingType of Z].
76- Canonical Z_idomainType := IdomainType Z idomain_axiomZ.
77-
78- Canonical Z_countZmodType := [countZmodType of Z].
79- Canonical Z_countRingType := [countRingType of Z].
80- Canonical Z_countComRingType := [countComRingType of Z].
81- Canonical Z_countUnitRingType := [countUnitRingType of Z].
82- Canonical Z_countComUnitRingType := [countComUnitRingType of Z].
83- Canonical Z_countIdomainType := [countIdomainType of Z].
78+ #[export]
79+ HB.instance Definition _ := GRing.ComUnitRing_isIntegral.Build Z idomain_axiomZ.
8480
8581Fact leZ_add m n : Z.leb 0 m -> Z.leb 0 n -> Z.leb 0 (m + n). Proof . lia. Qed .
8682Fact leZ_mul m n : Z.leb 0 m -> Z.leb 0 n -> Z.leb 0 (m * n). Proof . lia. Qed .
@@ -98,17 +94,9 @@ Fact geZ0_norm m : Z.leb 0 m -> Z.abs m = m. Proof. lia. Qed.
9894Fact ltZ_def m n : (Z.ltb m n) = (n != m) && (Z.leb m n).
9995Proof . by rewrite eqE /=; lia. Qed .
10096
101- Definition Mixin : realLeMixin [idomainType of Z] :=
102- RealLeMixin
103- leZ_add leZ_mul leZ_anti subZ_ge0 (leZ_total 0) normZN geZ0_norm ltZ_def.
104-
105- Canonical Z_porderType := POrderType ring_display Z Mixin.
106- Canonical Z_latticeType := LatticeType Z Mixin.
107- Canonical Z_distrLatticeType := DistrLatticeType Z Mixin.
108- Canonical Z_orderType := OrderType Z leZ_total.
109- Canonical Z_numDomainType := NumDomainType Z Mixin.
110- Canonical Z_normedZmodType := NormedZmodType Z Z Mixin.
111- Canonical Z_realDomainType := [realDomainType of Z].
97+ #[export]
98+ HB.instance Definition _ := Num.IntegralDomain_isLeReal.Build Z
99+ leZ_add leZ_mul leZ_anti subZ_ge0 (leZ_total 0) normZN geZ0_norm ltZ_def.
112100
113101Fact Z_of_intE (n : int) : Z_of_int n = (n%:~R)%R.
114102Proof .
@@ -121,48 +109,33 @@ Qed.
121109Fact Z_of_int_is_additive : additive Z_of_int.
122110Proof . by move=> m n; rewrite !Z_of_intE raddfB. Qed .
123111
124- Canonical Z_of_int_additive := Additive Z_of_int_is_additive.
112+ #[export]
113+ HB.instance Definition _ := GRing.isAdditive.Build int Z Z_of_int
114+ Z_of_int_is_additive.
125115
126116Fact int_of_Z_is_additive : additive int_of_Z.
127117Proof . exact: can2_additive Z_of_intK int_of_ZK. Qed .
128118
129- Canonical int_of_Z_additive := Additive int_of_Z_is_additive.
119+ #[export]
120+ HB.instance Definition _ := GRing.isAdditive.Build Z int int_of_Z
121+ int_of_Z_is_additive.
130122
131123Fact Z_of_int_is_multiplicative : multiplicative Z_of_int.
132124Proof . by split => // n m; rewrite !Z_of_intE rmorphM. Qed .
133125
134- Canonical Z_of_int_rmorphism := AddRMorphism Z_of_int_is_multiplicative.
126+ #[export]
127+ HB.instance Definition _ := GRing.isMultiplicative.Build int Z Z_of_int
128+ Z_of_int_is_multiplicative.
135129
136130Fact int_of_Z_is_multiplicative : multiplicative int_of_Z.
137131Proof . exact: can2_rmorphism Z_of_intK int_of_ZK. Qed .
138132
139- Canonical int_of_Z_rmorphism := AddRMorphism int_of_Z_is_multiplicative.
133+ #[export]
134+ HB.instance Definition _ := GRing.isMultiplicative.Build Z int int_of_Z
135+ int_of_Z_is_multiplicative.
136+
137+ Module Exports. HB.reexport. End Exports.
140138
141139End ZInstances.
142140
143- Canonical ZInstances.Z_eqType.
144- Canonical ZInstances.Z_choiceType.
145- Canonical ZInstances.Z_countType.
146- Canonical ZInstances.Z_zmodType.
147- Canonical ZInstances.Z_ringType.
148- Canonical ZInstances.Z_comRingType.
149- Canonical ZInstances.Z_unitRingType.
150- Canonical ZInstances.Z_comUnitRing.
151- Canonical ZInstances.Z_idomainType.
152- Canonical ZInstances.Z_countZmodType.
153- Canonical ZInstances.Z_countRingType.
154- Canonical ZInstances.Z_countComRingType.
155- Canonical ZInstances.Z_countUnitRingType.
156- Canonical ZInstances.Z_countComUnitRingType.
157- Canonical ZInstances.Z_countIdomainType.
158- Canonical ZInstances.Z_porderType.
159- Canonical ZInstances.Z_latticeType.
160- Canonical ZInstances.Z_distrLatticeType.
161- Canonical ZInstances.Z_orderType.
162- Canonical ZInstances.Z_numDomainType.
163- Canonical ZInstances.Z_normedZmodType.
164- Canonical ZInstances.Z_realDomainType.
165- Canonical ZInstances.Z_of_int_additive.
166- Canonical ZInstances.int_of_Z_additive.
167- Canonical ZInstances.Z_of_int_rmorphism.
168- Canonical ZInstances.int_of_Z_rmorphism.
141+ Export ZInstances.Exports.
0 commit comments