src/HOL/Algebra/UnivPoly.thy
changeset 14651 02b8f3bcf7fe
parent 14590 276ef51cedbf
child 14666 65f8680c3f16
equal deleted inserted replaced
14650:0390abdd1e62 14651:02b8f3bcf7fe
    56 
    56 
    57 record ('a, 'p) up_ring = "('a, 'p) module" +
    57 record ('a, 'p) up_ring = "('a, 'p) module" +
    58   monom :: "['a, nat] => 'p"
    58   monom :: "['a, nat] => 'p"
    59   coeff :: "['p, nat] => 'a"
    59   coeff :: "['p, nat] => 'a"
    60 
    60 
    61 constdefs
    61 constdefs (structure R)
    62   up :: "('a, 'm) ring_scheme => (nat => 'a) set"
    62   up :: "_ => (nat => 'a) set"
    63   "up R == {f. f \<in> UNIV -> carrier R & (EX n. bound (zero R) n f)}"
    63   "up R == {f. f \<in> UNIV -> carrier R & (EX n. bound \<zero> n f)}"
    64   UP :: "('a, 'm) ring_scheme => ('a, nat => 'a) up_ring"
    64   UP :: "_ => ('a, nat => 'a) up_ring"
    65   "UP R == (|
    65   "UP R == (|
    66     carrier = up R,
    66     carrier = up R,
    67     mult = (%p:up R. %q:up R. %n. finsum R (%i. mult R (p i) (q (n-i))) {..n}),
    67     mult = (%p:up R. %q:up R. %n. \<Oplus>i \<in> {..n}. p i \<otimes> q (n-i)),
    68     one = (%i. if i=0 then one R else zero R),
    68     one = (%i. if i=0 then \<one> else \<zero>),
    69     zero = (%i. zero R),
    69     zero = (%i. \<zero>),
    70     add = (%p:up R. %q:up R. %i. add R (p i) (q i)),
    70     add = (%p:up R. %q:up R. %i. p i \<oplus> q i),
    71     smult = (%a:carrier R. %p:up R. %i. mult R a (p i)),
    71     smult = (%a:carrier R. %p:up R. %i. a \<otimes> p i),
    72     monom = (%a:carrier R. %n i. if i=n then a else zero R),
    72     monom = (%a:carrier R. %n i. if i=n then a else \<zero>),
    73     coeff = (%p:up R. %n. p n) |)"
    73     coeff = (%p:up R. %n. p n) |)"
    74 
    74 
    75 text {*
    75 text {*
    76   Properties of the set of polynomials @{term up}.
    76   Properties of the set of polynomials @{term up}.
    77 *}
    77 *}
   177 locale UP_cring = UP + cring R
   177 locale UP_cring = UP + cring R
   178 
   178 
   179 locale UP_domain = UP_cring + "domain" R
   179 locale UP_domain = UP_cring + "domain" R
   180 
   180 
   181 text {*
   181 text {*
   182   Temporarily declare UP.P\_def as simp rule.
   182   Temporarily declare @{text UP.P_def} as simp rule.
   183 *}
   183 *}  (* TODO: use antiquotation once text (in locale) is supported. *)
   184 (* TODO: use antiquotation once text (in locale) is supported. *)
       
   185 
   184 
   186 declare (in UP) P_def [simp]
   185 declare (in UP) P_def [simp]
   187 
   186 
   188 lemma (in UP_cring) coeff_monom [simp]:
   187 lemma (in UP_cring) coeff_monom [simp]:
   189   "a \<in> carrier R ==>
   188   "a \<in> carrier R ==>
   783   with R show "x = y" by simp
   782   with R show "x = y" by simp
   784 qed
   783 qed
   785 
   784 
   786 subsection {* The degree function *}
   785 subsection {* The degree function *}
   787 
   786 
   788 constdefs
   787 constdefs (structure R)
   789   deg :: "[('a, 'm) ring_scheme, nat => 'a] => nat"
   788   deg :: "[_, nat => 'a] => nat"
   790   "deg R p == LEAST n. bound (zero R) n (coeff (UP R) p)"
   789   "deg R p == LEAST n. bound \<zero> n (coeff (UP R) p)"
   791 
   790 
   792 lemma (in UP_cring) deg_aboveI:
   791 lemma (in UP_cring) deg_aboveI:
   793   "[| (!!m. n < m ==> coeff P p m = \<zero>); p \<in> carrier P |] ==> deg R p <= n" 
   792   "[| (!!m. n < m ==> coeff P p m = \<zero>); p \<in> carrier P |] ==> deg R p <= n" 
   794   by (unfold deg_def P_def) (fast intro: Least_le)
   793   by (unfold deg_def P_def) (fast intro: Least_le)
   795 (*
   794 (*
  1246 
  1245 
  1247 lemma (in UP_cring) const_ring_hom:
  1246 lemma (in UP_cring) const_ring_hom:
  1248   "(%a. monom P a 0) \<in> ring_hom R P"
  1247   "(%a. monom P a 0) \<in> ring_hom R P"
  1249   by (auto intro!: ring_hom_memI intro: up_eqI simp: monom_mult_is_smult)
  1248   by (auto intro!: ring_hom_memI intro: up_eqI simp: monom_mult_is_smult)
  1250 
  1249 
  1251 constdefs
  1250 constdefs (structure S)
  1252   eval :: "[('a, 'm) ring_scheme, ('b, 'n) ring_scheme,
  1251   eval :: "[_, _, 'a => 'b, 'b, nat => 'a] => 'b"
  1253           'a => 'b, 'b, nat => 'a] => 'b"
  1252   "eval R S phi s == \<lambda>p \<in> carrier (UP R).
  1254   "eval R S phi s == (\<lambda>p \<in> carrier (UP R).
  1253     \<Oplus>i \<in> {..deg R p}. phi (coeff (UP R) p i) \<otimes> pow S s i"
  1255     finsum S (%i. mult S (phi (coeff (UP R) p i)) (pow S s i)) {..deg R p})"
       
  1256 (*
  1254 (*
  1257   "eval R S phi s p == if p \<in> carrier (UP R)
  1255   "eval R S phi s p == if p \<in> carrier (UP R)
  1258   then finsum S (%i. mult S (phi (coeff (UP R) p i)) (pow S s i)) {..deg R p}
  1256   then finsum S (%i. mult S (phi (coeff (UP R) p i)) (pow S s i)) {..deg R p}
  1259   else arbitrary"
  1257   else arbitrary"
  1260 *)
  1258 *)
  1564 lemma "eval INTEG INTEG id 10 (monom (UP INTEG) 5 2) = 500"
  1562 lemma "eval INTEG INTEG id 10 (monom (UP INTEG) 5 2) = 500"
  1565   by (simp add: ring_hom_UP_cring.eval_monom [OF INTEG_id])
  1563   by (simp add: ring_hom_UP_cring.eval_monom [OF INTEG_id])
  1566 
  1564 
  1567 -- {* Calculates @{term "x = 500"} *}
  1565 -- {* Calculates @{term "x = 500"} *}
  1568 
  1566 
  1569 
       
  1570 end
  1567 end