Skip to content

Commit e94f2cb

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

File tree

2 files changed

+624
-1154
lines changed

2 files changed

+624
-1154
lines changed

src/monalg.v

Lines changed: 24 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,8 @@ Canonical cmonom_unlockable k := [unlockable fun cmonom_of_fsfun k].
13951399

13961400
End CmonomDef.
13971401

1402+
Bind Scope monom_scope with cmonom.
1403+
13981404
Notation "{ 'cmonom' I }" := (cmonom I) : type_scope.
13991405
Notation "''X_{1..' n '}'" := (cmonom 'I_n) : type_scope.
14001406
Notation "{ 'mpoly' R [ n ] }" := {malg R['X_{1..n}]} : type_scope.
@@ -1412,8 +1418,8 @@ Section CmonomCanonicals.
14121418

14131419
Context (I : choiceType).
14141420

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

14181424
(* -------------------------------------------------------------------- *)
14191425
Implicit Types (m : cmonom I).
@@ -1426,7 +1432,7 @@ Proof.
14261432
by rewrite [mkcmonom]unlock.
14271433
Qed.
14281434

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

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

1481+
#[hnf]
14751482
HB.instance Definition _ := Choice_isMonomialDef.Build (cmonom I)
14761483
mulcmA mul0cm mulcm0 mulcm_eq0.
1484+
#[hnf]
14771485
HB.instance Definition _ := MonomialDef_isConomialDef.Build (cmonom I) mulcmC.
14781486

14791487
End CmonomCanonicals.
14801488

1489+
HB.instance Definition _ (I : countType) := [Countable of cmonom I by <:].
1490+
14811491
(* -------------------------------------------------------------------- *)
14821492
Definition mdeg {I : choiceType} (m : cmonom I) :=
14831493
(\sum_(k <- finsupp m) m k)%N.
@@ -1672,6 +1682,8 @@ Canonical fmonom_unlockable k := [unlockable fun fmonom_of_seq k].
16721682

16731683
End FmonomDef.
16741684

1685+
Bind Scope monom_scope with fmonom.
1686+
16751687
Notation "{ 'fmonom' I }" := (fmonom I) : type_scope.
16761688

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

17291741
End FmonomCanonicals.
17301742

1743+
HB.instance Definition _ (I : countType) := [Countable of fmonom I by <:].
1744+
17311745
(* -------------------------------------------------------------------- *)
17321746
Definition fdeg (I : choiceType) (m : fmonom I) := size m.
17331747

0 commit comments

Comments
 (0)