Skip to content

Commit 1577d5c

Browse files
committed
[WIP] replace the infrastructure of mpoly with monalg
1 parent 3a08297 commit 1577d5c

File tree

2 files changed

+661
-1211
lines changed

2 files changed

+661
-1211
lines changed

src/monalg.v

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Reserved Notation "<< k >>" (format "<< k >>").
4444
Reserved Notation "g @_ k"
4545
(at level 3, k at level 2, left associativity, format "g @_ k").
4646
Reserved Notation "c %:MP" (format "c %:MP").
47-
Reserved Notation "''X_{1..' n '}'".
47+
Reserved Notation "''X_{1..' n '}'" (n at level 2).
4848
Reserved Notation "'U_(' n )" (format "'U_(' n )").
4949
Reserved Notation "x ^[ f , g ]" (at level 1, format "x ^[ f , g ]").
5050

@@ -244,12 +244,13 @@ Definition mcoeff (x : K) (g : {malg G[K]}) : G := malg_val g x.
244244
#[deprecated(since="multinomials 2.5.0", note="Use Malg instead")]
245245
Definition mkmalg : {fsfun K -> G with 0} -> {malg G[K]} := @Malg K G.
246246

247-
Definition mkmalgU (k : K) (x : G) := [malg y in [fset k] => x].
248-
249247
Definition msupp (g : {malg G[K]}) : {fset K} := finsupp (malg_val g).
250248

251249
End MalgBaseOp.
252250

251+
HB.lock Definition mkmalgU (K : choiceType) (G : nmodType) (k : K) (x : G) :=
252+
[malg y in [fset k] => x].
253+
253254
Arguments mcoeff {K G} x%_monom_scope g%_ring_scope.
254255
#[warning="-deprecated-reference"]
255256
Arguments mkmalg {K G} _.
@@ -350,7 +351,7 @@ Lemma mcoeffD k : {morph mcoeff k: x y / x + y}. Proof. exact: raddfD. Qed.
350351
Lemma mcoeffMn k n : {morph mcoeff k: x / x *+ n} . Proof. exact: raddfMn. Qed.
351352

352353
Lemma mcoeffU k x k' : << x *g k >>@_k' = x *+ (k == k').
353-
Proof. by rewrite [LHS]fsfunE inE mulrb eq_sym. Qed.
354+
Proof. by rewrite unlock [LHS]fsfunE inE mulrb eq_sym. Qed.
354355

355356
Lemma mcoeffUU k x : << x *g k >>@_k = x.
356357
Proof. by rewrite mcoeffU eqxx. Qed.
@@ -986,6 +987,9 @@ HB.instance Definition _ :=
986987
HB.instance Definition _ :=
987988
GRing.LSemiModule_isLSemiAlgebra.Build R {malg R[K]} (@fgscaleAl K R).
988989

990+
(* FIXME: HB.saturate *)
991+
HB.instance Definition _ := GRing.RMorphism.on (mcoeff 1 : {malg R[K]} -> R).
992+
989993
End MalgNzSemiRingTheory.
990994

991995
(* -------------------------------------------------------------------- *)
@@ -1294,7 +1298,7 @@ Arguments monalgOver_pred _ _ _ _ /.
12941298

12951299
(* -------------------------------------------------------------------- *)
12961300
HB.mixin Record isMeasure (M : monomType) (mf : M -> nat) := {
1297-
mf0 : mf 1%M = 0%N;
1301+
mf1 : mf 1%M = 0%N;
12981302
mfM : {morph mf : m1 m2 / (m1 * m2)%M >-> (m1 + m2)%N};
12991303
mf_eq0I : forall m, mf m = 0%N -> m = 1%M
13001304
}.
@@ -1314,7 +1318,7 @@ Context (M : monomType) (G : nmodType) (mf : measure M).
13141318
Implicit Types (g : {malg G[M]}).
13151319

13161320
Lemma mf_eq0 m : (mf m == 0%N) = (m == 1%M).
1317-
Proof. by apply/eqP/eqP=> [|->]; rewrite ?mf0 // => /mf_eq0I. Qed.
1321+
Proof. by apply/eqP/eqP=> [|->]; rewrite ?mf1 // => /mf_eq0I. Qed.
13181322

13191323
Definition mmeasure g := (\max_(m <- msupp g) (mf m).+1)%N.
13201324

@@ -1336,7 +1340,7 @@ Proof. by apply/contraTN=> /mmeasure_mnm_lt; rewrite leqNgt ltnS. Qed.
13361340
Lemma mmeasureC c : mmeasure c%:MP = (c != 0%R) :> nat.
13371341
Proof.
13381342
rewrite mmeasureE msuppC; case: (_ == 0)=> /=.
1339-
by rewrite big_nil. by rewrite big_seq_fset1 mf0.
1343+
by rewrite big_nil. by rewrite big_seq_fset1 mf1.
13401344
Qed.
13411345

13421346
Lemma mmeasureD_le g1 g2 :
@@ -1395,6 +1399,9 @@ Canonical cmonom_unlockable k := [unlockable fun cmonom_of_fsfun k].
13951399

13961400
End CmonomDef.
13971401

1402+
Arguments cmonom_val : simpl never.
1403+
Bind Scope monom_scope with cmonom.
1404+
13981405
Notation "{ 'cmonom' I }" := (cmonom I) : type_scope.
13991406
Notation "''X_{1..' n '}'" := (cmonom 'I_n) : type_scope.
14001407
Notation "{ 'mpoly' R [ n ] }" := {malg R['X_{1..n}]} : type_scope.
@@ -1412,8 +1419,8 @@ Section CmonomCanonicals.
14121419

14131420
Context (I : choiceType).
14141421

1415-
HB.instance Definition _ := [isNew for @cmonom_val I].
1416-
HB.instance Definition _ := [Choice of cmonom I by <:].
1422+
#[hnf] HB.instance Definition _ := [isNew for @cmonom_val I].
1423+
#[hnf] HB.instance Definition _ := [Choice of cmonom I by <:].
14171424

14181425
(* -------------------------------------------------------------------- *)
14191426
Implicit Types (m : cmonom I).
@@ -1426,7 +1433,7 @@ Proof.
14261433
by rewrite [mkcmonom]unlock.
14271434
Qed.
14281435

1429-
Lemma cmP m1 m2 : reflect (forall i, m1 i = m2 i) (m1 == m2).
1436+
Lemma cmP m1 m2 : reflect (m1 =1 m2) (m1 == m2).
14301437
Proof. by apply: (iffP eqP) => [->//|eq]; apply/val_inj/fsfunP. Qed.
14311438

14321439
Definition onecm : cmonom I := CMonom [fsfun of _ => 0%N].
@@ -1472,12 +1479,16 @@ move: m1 m2; have gen m1 m2 : mulcm m1 m2 = onecm -> m1 = onecm.
14721479
by move=> m1 m2 h; split; move: h; last rewrite mulcmC; apply/gen.
14731480
Qed.
14741481

1482+
#[hnf]
14751483
HB.instance Definition _ := Choice_isMonomialDef.Build (cmonom I)
14761484
mulcmA mul0cm mulcm0 mulcm_eq0.
1485+
#[hnf]
14771486
HB.instance Definition _ := MonomialDef_isConomialDef.Build (cmonom I) mulcmC.
14781487

14791488
End CmonomCanonicals.
14801489

1490+
HB.instance Definition _ (I : countType) := [Countable of cmonom I by <:].
1491+
14811492
(* -------------------------------------------------------------------- *)
14821493
Definition mdeg {I : choiceType} (m : cmonom I) :=
14831494
(\sum_(k <- finsupp m) m k)%N.
@@ -1672,6 +1683,8 @@ Canonical fmonom_unlockable k := [unlockable fun fmonom_of_seq k].
16721683

16731684
End FmonomDef.
16741685

1686+
Bind Scope monom_scope with fmonom.
1687+
16751688
Notation "{ 'fmonom' I }" := (fmonom I) : type_scope.
16761689

16771690
Local Notation mkfmonom s := (fmonom_of_seq fmonom_key s).
@@ -1728,6 +1741,8 @@ HB.instance Definition _ := Choice_isMonomialDef.Build (fmonom I)
17281741

17291742
End FmonomCanonicals.
17301743

1744+
HB.instance Definition _ (I : countType) := [Countable of fmonom I by <:].
1745+
17311746
(* -------------------------------------------------------------------- *)
17321747
Definition fdeg (I : choiceType) (m : fmonom I) := size m.
17331748

0 commit comments

Comments
 (0)