Skip to content

Commit

Permalink
Some basic facts on polynomials + fix theory cloning for Poly
Browse files Browse the repository at this point in the history
  • Loading branch information
strub committed Jan 10, 2025
1 parent 13acf05 commit 2c4a5e1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions theories/algebra/Poly.ec
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ proof. by apply/poly_eqP=> i ge0_i; rewrite !coeffpE mul0r. qed.
lemma scalep0 c : c ** poly0 = poly0.
proof. by apply/poly_eqP=> i ge0_i; rewrite !coeffpE mulr0. qed.

(* -------------------------------------------------------------------- *)
lemma scale1p p : oner ** p = p.
proof. by apply/poly_eqP=> i ge0_i; rewrite !coeffpE mul1r. qed.

(* -------------------------------------------------------------------- *)
lemma scalep1 c : c ** poly1 = polyC c.
proof.
apply/poly_eqP=> i ge0_i; rewrite !coeffpE !polyCE.
by case: (i = 0) => _; [rewrite mulr1|rewrite mulr0].
qed.

(* -------------------------------------------------------------------- *)
lemma scaleNp (c : coeff) p : (-c) ** p = - (c ** p).
proof. by apply/poly_eqP=> i ge0_i; rewrite !coeffpE mulNr. qed.
Expand Down Expand Up @@ -849,9 +860,11 @@ type coeff.
clone import IDomain as IDCoeff with type t <= coeff.

clone include PolyComRing with
type coeff <- coeff,
theory Coeff <- IDCoeff.

type coeff <- coeff,
theory Coeff <- IDCoeff,
op PolyComRing.invr (p : poly) =
(if deg p = 1 then polyC (IDCoeff.invr p.[0]) else p).

clear [PolyComRing.* PolyComRing.AddMonoid.* PolyComRing.MulMonoid.*].

import BigCf.
Expand All @@ -868,6 +881,7 @@ qed.
pred unitp (p : poly) =
deg p = 1 /\ IDCoeff.unit p.[0].

(* -------------------------------------------------------------------- *)
op polyV (p : poly) =
if deg p = 1 then polyC (IDCoeff.invr p.[0]) else p.

Expand All @@ -880,6 +894,7 @@ clone import Ring.IDomain as IDPoly with
op [ - ] <- polyN,
op ( * ) <- polyM,
op invr <- polyV,
op exp <- PolyComRing.exp,
pred unit <- unitp

proof *
Expand Down

0 comments on commit 2c4a5e1

Please sign in to comment.