Theories now take advantage of recent syntax improvements with (structure).
authorballarin
Mon Aug 02 09:44:46 2004 +0200 (2004-08-02)
changeset 1509563f5f4c265dd
parent 15094 a7d1a3fdc30d
child 15096 be1d3b8cfbd5
Theories now take advantage of recent syntax improvements with (structure).
src/HOL/Algebra/CRing.thy
src/HOL/Algebra/FiniteProduct.thy
src/HOL/Algebra/Module.thy
src/HOL/Algebra/UnivPoly.thy
     1.1 --- a/src/HOL/Algebra/CRing.thy	Sat Jul 31 20:54:23 2004 +0200
     1.2 +++ b/src/HOL/Algebra/CRing.thy	Mon Aug 02 09:44:46 2004 +0200
     1.3 @@ -17,7 +17,7 @@
     1.4  text {* Derived operations. *}
     1.5  
     1.6  constdefs (structure R)
     1.7 -  a_inv :: "[_, 'a ] => 'a" ("\<ominus>\<index> _" [81] 80)
     1.8 +  a_inv :: "[('a, 'm) ring_scheme, 'a ] => 'a" ("\<ominus>\<index> _" [81] 80)
     1.9    "a_inv R == m_inv (| carrier = carrier R, mult = add R, one = zero R |)"
    1.10  
    1.11    minus :: "[('a, 'm) ring_scheme, 'a, 'a] => 'a" (infixl "\<ominus>\<index>" 65)
    1.12 @@ -40,29 +40,31 @@
    1.13  subsection {* Basic Properties *}
    1.14  
    1.15  lemma abelian_monoidI:
    1.16 +  includes struct R
    1.17    assumes a_closed:
    1.18 -      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> add R x y \<in> carrier R"
    1.19 -    and zero_closed: "zero R \<in> carrier R"
    1.20 +      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y \<in> carrier R"
    1.21 +    and zero_closed: "\<zero> \<in> carrier R"
    1.22      and a_assoc:
    1.23        "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |] ==>
    1.24 -      add R (add R x y) z = add R x (add R y z)"
    1.25 -    and l_zero: "!!x. x \<in> carrier R ==> add R (zero R) x = x"
    1.26 +      (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
    1.27 +    and l_zero: "!!x. x \<in> carrier R ==> \<zero> \<oplus> x = x"
    1.28      and a_comm:
    1.29 -      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> add R x y = add R y x"
    1.30 +      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y = y \<oplus> x"
    1.31    shows "abelian_monoid R"
    1.32    by (auto intro!: abelian_monoid.intro comm_monoidI intro: prems)
    1.33  
    1.34  lemma abelian_groupI:
    1.35 +  includes struct R
    1.36    assumes a_closed:
    1.37 -      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> add R x y \<in> carrier R"
    1.38 +      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y \<in> carrier R"
    1.39      and zero_closed: "zero R \<in> carrier R"
    1.40      and a_assoc:
    1.41        "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |] ==>
    1.42 -      add R (add R x y) z = add R x (add R y z)"
    1.43 +      (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
    1.44      and a_comm:
    1.45 -      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> add R x y = add R y x"
    1.46 -    and l_zero: "!!x. x \<in> carrier R ==> add R (zero R) x = x"
    1.47 -    and l_inv_ex: "!!x. x \<in> carrier R ==> EX y : carrier R. add R y x = zero R"
    1.48 +      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y = y \<oplus> x"
    1.49 +    and l_zero: "!!x. x \<in> carrier R ==> \<zero> \<oplus> x = x"
    1.50 +    and l_inv_ex: "!!x. x \<in> carrier R ==> EX y : carrier R. y \<oplus> x = \<zero>"
    1.51    shows "abelian_group R"
    1.52    by (auto intro!: abelian_group.intro abelian_monoidI
    1.53        abelian_group_axioms.intro comm_monoidI comm_groupI
    1.54 @@ -169,7 +171,7 @@
    1.55  *}
    1.56  
    1.57  constdefs
    1.58 -  finsum :: "[_, 'a => 'b, 'a set] => 'b"
    1.59 +  finsum :: "[('b, 'm) ring_scheme, 'a => 'b, 'a set] => 'b"
    1.60    "finsum G f A == finprod (| carrier = carrier G,
    1.61       mult = add G, one = zero G |) f A"
    1.62  
    1.63 @@ -183,7 +185,8 @@
    1.64    "_finsum" :: "index => idt => 'a set => 'b => 'b"
    1.65        ("(3\<Oplus>__\<in>_. _)" [1000, 0, 51, 10] 10)
    1.66  translations
    1.67 -  "\<Oplus>\<index>i:A. b" == "finsum \<struct>\<index> (%i. b) A"  -- {* Beware of argument permutation! *}
    1.68 +  "\<Oplus>\<index>i:A. b" == "finsum \<struct>\<index> (%i. b) A"
    1.69 +  -- {* Beware of argument permutation! *}
    1.70  
    1.71  (*
    1.72    lemmas (in abelian_monoid) finsum_empty [simp] =
    1.73 @@ -194,10 +197,10 @@
    1.74    lemmas (in abelian_monoid) finsum_empty [simp] =
    1.75      abelian_monoid.finprod_empty [OF a_abelian_monoid, folded finsum_def,
    1.76        simplified monoid_record_simps]
    1.77 -makes the locale slow, because proofs are repeated for every
    1.78 -"lemma (in abelian_monoid)" command.
    1.79 -When lemma is used time in UnivPoly.thy from beginning to UP_cring goes down
    1.80 -from 110 secs to 60 secs.
    1.81 +  makes the locale slow, because proofs are repeated for every
    1.82 +  "lemma (in abelian_monoid)" command.
    1.83 +  When lemma is used time in UnivPoly.thy from beginning to UP_cring goes down
    1.84 +  from 110 secs to 60 secs.
    1.85  *)
    1.86  
    1.87  lemma (in abelian_monoid) finsum_empty [simp]:
    1.88 @@ -212,7 +215,7 @@
    1.89      folded finsum_def, simplified monoid_record_simps])
    1.90  
    1.91  lemma (in abelian_monoid) finsum_zero [simp]:
    1.92 -  "finite A ==> (\<Oplus>i: A. \<zero>) = \<zero>"
    1.93 +  "finite A ==> (\<Oplus>i\<in>A. \<zero>) = \<zero>"
    1.94    by (rule comm_monoid.finprod_one [OF a_comm_monoid, folded finsum_def,
    1.95      simplified monoid_record_simps])
    1.96  
    1.97 @@ -310,7 +313,7 @@
    1.98    assumes abelian_group: "abelian_group R"
    1.99      and monoid: "monoid R"
   1.100      and l_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
   1.101 -      ==> mult R (add R x y) z = add R (mult R x z) (mult R y z)"
   1.102 +      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
   1.103      and r_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
   1.104        ==> z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y"
   1.105    shows "ring R"
   1.106 @@ -330,7 +333,7 @@
   1.107    assumes abelian_group: "abelian_group R"
   1.108      and comm_monoid: "comm_monoid R"
   1.109      and l_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
   1.110 -      ==> mult R (add R x y) z = add R (mult R x z) (mult R y z)"
   1.111 +      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
   1.112    shows "cring R"
   1.113    proof (rule cring.intro)
   1.114      show "ring_axioms R"
   1.115 @@ -457,7 +460,7 @@
   1.116  lemma
   1.117    includes ring R + cring S
   1.118    shows "[| a \<in> carrier R; b \<in> carrier R; c \<in> carrier S; d \<in> carrier S |] ==> 
   1.119 -  a \<oplus> \<ominus> (a \<oplus> \<ominus> b) = b & c \<otimes>\<^sub>2 d = d \<otimes>\<^sub>2 c"
   1.120 +  a \<oplus> \<ominus> (a \<oplus> \<ominus> b) = b & c \<otimes>\<^bsub>S\<^esub> d = d \<otimes>\<^bsub>S\<^esub> c"
   1.121    by algebra
   1.122  
   1.123  lemma
   1.124 @@ -528,21 +531,21 @@
   1.125  
   1.126  subsection {* Morphisms *}
   1.127  
   1.128 -constdefs
   1.129 +constdefs (structure R S)
   1.130    ring_hom :: "[('a, 'm) ring_scheme, ('b, 'n) ring_scheme] => ('a => 'b) set"
   1.131    "ring_hom R S == {h. h \<in> carrier R -> carrier S &
   1.132        (ALL x y. x \<in> carrier R & y \<in> carrier R -->
   1.133 -        h (mult R x y) = mult S (h x) (h y) &
   1.134 -        h (add R x y) = add S (h x) (h y)) &
   1.135 -      h (one R) = one S}"
   1.136 +        h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y & h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y) &
   1.137 +      h \<one> = \<one>\<^bsub>S\<^esub>}"
   1.138  
   1.139  lemma ring_hom_memI:
   1.140 +  includes struct R + struct S
   1.141    assumes hom_closed: "!!x. x \<in> carrier R ==> h x \<in> carrier S"
   1.142      and hom_mult: "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==>
   1.143 -      h (mult R x y) = mult S (h x) (h y)"
   1.144 +      h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y"
   1.145      and hom_add: "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==>
   1.146 -      h (add R x y) = add S (h x) (h y)"
   1.147 -    and hom_one: "h (one R) = one S"
   1.148 +      h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y"
   1.149 +    and hom_one: "h \<one> = \<one>\<^bsub>S\<^esub>"
   1.150    shows "h \<in> ring_hom R S"
   1.151    by (auto simp add: ring_hom_def prems Pi_def)
   1.152  
   1.153 @@ -551,17 +554,22 @@
   1.154    by (auto simp add: ring_hom_def funcset_mem)
   1.155  
   1.156  lemma ring_hom_mult:
   1.157 -  "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
   1.158 -  h (mult R x y) = mult S (h x) (h y)"
   1.159 -  by (simp add: ring_hom_def)
   1.160 +  includes struct R + struct S
   1.161 +  shows
   1.162 +    "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
   1.163 +    h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y"
   1.164 +    by (simp add: ring_hom_def)
   1.165  
   1.166  lemma ring_hom_add:
   1.167 -  "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
   1.168 -  h (add R x y) = add S (h x) (h y)"
   1.169 -  by (simp add: ring_hom_def)
   1.170 +  includes struct R + struct S
   1.171 +  shows
   1.172 +    "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
   1.173 +    h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y"
   1.174 +    by (simp add: ring_hom_def)
   1.175  
   1.176  lemma ring_hom_one:
   1.177 -  "h \<in> ring_hom R S ==> h (one R) = one S"
   1.178 +  includes struct R + struct S
   1.179 +  shows "h \<in> ring_hom R S ==> h \<one> = \<one>\<^bsub>S\<^esub>"
   1.180    by (simp add: ring_hom_def)
   1.181  
   1.182  locale ring_hom_cring = cring R + cring S + var h +
   1.183 @@ -572,18 +580,18 @@
   1.184      and hom_one [simp] = ring_hom_one [OF homh]
   1.185  
   1.186  lemma (in ring_hom_cring) hom_zero [simp]:
   1.187 -  "h \<zero> = \<zero>\<^sub>2"
   1.188 +  "h \<zero> = \<zero>\<^bsub>S\<^esub>"
   1.189  proof -
   1.190 -  have "h \<zero> \<oplus>\<^sub>2 h \<zero> = h \<zero> \<oplus>\<^sub>2 \<zero>\<^sub>2"
   1.191 +  have "h \<zero> \<oplus>\<^bsub>S\<^esub> h \<zero> = h \<zero> \<oplus>\<^bsub>S\<^esub> \<zero>\<^bsub>S\<^esub>"
   1.192      by (simp add: hom_add [symmetric] del: hom_add)
   1.193    then show ?thesis by (simp del: S.r_zero)
   1.194  qed
   1.195  
   1.196  lemma (in ring_hom_cring) hom_a_inv [simp]:
   1.197 -  "x \<in> carrier R ==> h (\<ominus> x) = \<ominus>\<^sub>2 h x"
   1.198 +  "x \<in> carrier R ==> h (\<ominus> x) = \<ominus>\<^bsub>S\<^esub> h x"
   1.199  proof -
   1.200    assume R: "x \<in> carrier R"
   1.201 -  then have "h x \<oplus>\<^sub>2 h (\<ominus> x) = h x \<oplus>\<^sub>2 (\<ominus>\<^sub>2 h x)"
   1.202 +  then have "h x \<oplus>\<^bsub>S\<^esub> h (\<ominus> x) = h x \<oplus>\<^bsub>S\<^esub> (\<ominus>\<^bsub>S\<^esub> h x)"
   1.203      by (simp add: hom_add [symmetric] R.r_neg S.r_neg del: hom_add)
   1.204    with R show ?thesis by simp
   1.205  qed
     2.1 --- a/src/HOL/Algebra/FiniteProduct.thy	Sat Jul 31 20:54:23 2004 +0200
     2.2 +++ b/src/HOL/Algebra/FiniteProduct.thy	Mon Aug 02 09:44:46 2004 +0200
     2.3 @@ -283,7 +283,7 @@
     2.4  subsection {* Products over Finite Sets *}
     2.5  
     2.6  constdefs (structure G)
     2.7 -  finprod :: "[_, 'a => 'b, 'a set] => 'b"
     2.8 +  finprod :: "[('b, 'm) monoid_scheme, 'a => 'b, 'a set] => 'b"
     2.9    "finprod G f A == if finite A
    2.10        then foldD (carrier G) (mult G o f) \<one> A
    2.11        else arbitrary"
    2.12 @@ -298,7 +298,8 @@
    2.13    "_finprod" :: "index => idt => 'a set => 'b => 'b"
    2.14        ("(3\<Otimes>__\<in>_. _)" [1000, 0, 51, 10] 10)
    2.15  translations
    2.16 -  "\<Otimes>\<index>i:A. b" == "finprod \<struct>\<index> (%i. b) A"  -- {* Beware of argument permutation! *}
    2.17 +  "\<Otimes>\<index>i:A. b" == "finprod \<struct>\<index> (%i. b) A"
    2.18 +  -- {* Beware of argument permutation! *}
    2.19  
    2.20  ML_setup {* 
    2.21    simpset_ref() := simpset() setsubgoaler asm_full_simp_tac;
    2.22 @@ -402,9 +403,8 @@
    2.23    from insert have ga: "g a \<in> carrier G" by fast
    2.24    from insert have fgA: "(%x. f x \<otimes> g x) \<in> A -> carrier G"
    2.25      by (simp add: Pi_def)
    2.26 -  show ?case  (* check if all simps are really necessary *)
    2.27 -    by (simp add: insert fA fa gA ga fgA m_ac Int_insert_left insert_absorb
    2.28 -      Int_mono2 Un_subset_iff)
    2.29 +  show ?case
    2.30 +    by (simp add: insert fA fa gA ga fgA m_ac)
    2.31  qed
    2.32  
    2.33  lemma (in comm_monoid) finprod_cong':
     3.1 --- a/src/HOL/Algebra/Module.thy	Sat Jul 31 20:54:23 2004 +0200
     3.2 +++ b/src/HOL/Algebra/Module.thy	Mon Aug 02 09:44:46 2004 +0200
     3.3 @@ -13,41 +13,41 @@
     3.4  
     3.5  locale module = cring R + abelian_group M +
     3.6    assumes smult_closed [simp, intro]:
     3.7 -      "[| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^sub>2 x \<in> carrier M"
     3.8 +      "[| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^bsub>M\<^esub> x \<in> carrier M"
     3.9      and smult_l_distr:
    3.10        "[| a \<in> carrier R; b \<in> carrier R; x \<in> carrier M |] ==>
    3.11 -      (a \<oplus> b) \<odot>\<^sub>2 x = a \<odot>\<^sub>2 x \<oplus>\<^sub>2 b \<odot>\<^sub>2 x"
    3.12 +      (a \<oplus> b) \<odot>\<^bsub>M\<^esub> x = a \<odot>\<^bsub>M\<^esub> x \<oplus>\<^bsub>M\<^esub> b \<odot>\<^bsub>M\<^esub> x"
    3.13      and smult_r_distr:
    3.14        "[| a \<in> carrier R; x \<in> carrier M; y \<in> carrier M |] ==>
    3.15 -      a \<odot>\<^sub>2 (x \<oplus>\<^sub>2 y) = a \<odot>\<^sub>2 x \<oplus>\<^sub>2 a \<odot>\<^sub>2 y"
    3.16 +      a \<odot>\<^bsub>M\<^esub> (x \<oplus>\<^bsub>M\<^esub> y) = a \<odot>\<^bsub>M\<^esub> x \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> y"
    3.17      and smult_assoc1:
    3.18        "[| a \<in> carrier R; b \<in> carrier R; x \<in> carrier M |] ==>
    3.19 -      (a \<otimes> b) \<odot>\<^sub>2 x = a \<odot>\<^sub>2 (b \<odot>\<^sub>2 x)"
    3.20 +      (a \<otimes> b) \<odot>\<^bsub>M\<^esub> x = a \<odot>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> x)"
    3.21      and smult_one [simp]:
    3.22 -      "x \<in> carrier M ==> \<one> \<odot>\<^sub>2 x = x"
    3.23 +      "x \<in> carrier M ==> \<one> \<odot>\<^bsub>M\<^esub> x = x"
    3.24  
    3.25  locale algebra = module R M + cring M +
    3.26    assumes smult_assoc2:
    3.27        "[| a \<in> carrier R; x \<in> carrier M; y \<in> carrier M |] ==>
    3.28 -      (a \<odot>\<^sub>2 x) \<otimes>\<^sub>2 y = a \<odot>\<^sub>2 (x \<otimes>\<^sub>2 y)"
    3.29 +      (a \<odot>\<^bsub>M\<^esub> x) \<otimes>\<^bsub>M\<^esub> y = a \<odot>\<^bsub>M\<^esub> (x \<otimes>\<^bsub>M\<^esub> y)"
    3.30  
    3.31  lemma moduleI:
    3.32    includes struct R + struct M
    3.33    assumes cring: "cring R"
    3.34      and abelian_group: "abelian_group M"
    3.35      and smult_closed:
    3.36 -      "!!a x. [| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^sub>2 x \<in> carrier M"
    3.37 +      "!!a x. [| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^bsub>M\<^esub> x \<in> carrier M"
    3.38      and smult_l_distr:
    3.39        "!!a b x. [| a \<in> carrier R; b \<in> carrier R; x \<in> carrier M |] ==>
    3.40 -      (a \<oplus> b) \<odot>\<^sub>2 x = (a \<odot>\<^sub>2 x) \<oplus>\<^sub>2 (b \<odot>\<^sub>2 x)"
    3.41 +      (a \<oplus> b) \<odot>\<^bsub>M\<^esub> x = (a \<odot>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> x)"
    3.42      and smult_r_distr:
    3.43        "!!a x y. [| a \<in> carrier R; x \<in> carrier M; y \<in> carrier M |] ==>
    3.44 -      a \<odot>\<^sub>2 (x \<oplus>\<^sub>2 y) = (a \<odot>\<^sub>2 x) \<oplus>\<^sub>2 (a \<odot>\<^sub>2 y)"
    3.45 +      a \<odot>\<^bsub>M\<^esub> (x \<oplus>\<^bsub>M\<^esub> y) = (a \<odot>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> (a \<odot>\<^bsub>M\<^esub> y)"
    3.46      and smult_assoc1:
    3.47        "!!a b x. [| a \<in> carrier R; b \<in> carrier R; x \<in> carrier M |] ==>
    3.48 -      (a \<otimes> b) \<odot>\<^sub>2 x = a \<odot>\<^sub>2 (b \<odot>\<^sub>2 x)"
    3.49 +      (a \<otimes> b) \<odot>\<^bsub>M\<^esub> x = a \<odot>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> x)"
    3.50      and smult_one:
    3.51 -      "!!x. x \<in> carrier M ==> \<one> \<odot>\<^sub>2 x = x"
    3.52 +      "!!x. x \<in> carrier M ==> \<one> \<odot>\<^bsub>M\<^esub> x = x"
    3.53    shows "module R M"
    3.54    by (auto intro: module.intro cring.axioms abelian_group.axioms
    3.55      module_axioms.intro prems)
    3.56 @@ -57,21 +57,21 @@
    3.57    assumes R_cring: "cring R"
    3.58      and M_cring: "cring M"
    3.59      and smult_closed:
    3.60 -      "!!a x. [| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^sub>2 x \<in> carrier M"
    3.61 +      "!!a x. [| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^bsub>M\<^esub> x \<in> carrier M"
    3.62      and smult_l_distr:
    3.63        "!!a b x. [| a \<in> carrier R; b \<in> carrier R; x \<in> carrier M |] ==>
    3.64 -      (a \<oplus> b) \<odot>\<^sub>2 x = (a \<odot>\<^sub>2 x) \<oplus>\<^sub>2 (b \<odot>\<^sub>2 x)"
    3.65 +      (a \<oplus> b) \<odot>\<^bsub>M\<^esub> x = (a \<odot>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> x)"
    3.66      and smult_r_distr:
    3.67        "!!a x y. [| a \<in> carrier R; x \<in> carrier M; y \<in> carrier M |] ==>
    3.68 -      a \<odot>\<^sub>2 (x \<oplus>\<^sub>2 y) = (a \<odot>\<^sub>2 x) \<oplus>\<^sub>2 (a \<odot>\<^sub>2 y)"
    3.69 +      a \<odot>\<^bsub>M\<^esub> (x \<oplus>\<^bsub>M\<^esub> y) = (a \<odot>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> (a \<odot>\<^bsub>M\<^esub> y)"
    3.70      and smult_assoc1:
    3.71        "!!a b x. [| a \<in> carrier R; b \<in> carrier R; x \<in> carrier M |] ==>
    3.72 -      (a \<otimes> b) \<odot>\<^sub>2 x = a \<odot>\<^sub>2 (b \<odot>\<^sub>2 x)"
    3.73 +      (a \<otimes> b) \<odot>\<^bsub>M\<^esub> x = a \<odot>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> x)"
    3.74      and smult_one:
    3.75 -      "!!x. x \<in> carrier M ==> (one R) \<odot>\<^sub>2 x = x"
    3.76 +      "!!x. x \<in> carrier M ==> (one R) \<odot>\<^bsub>M\<^esub> x = x"
    3.77      and smult_assoc2:
    3.78        "!!a x y. [| a \<in> carrier R; x \<in> carrier M; y \<in> carrier M |] ==>
    3.79 -      (a \<odot>\<^sub>2 x) \<otimes>\<^sub>2 y = a \<odot>\<^sub>2 (x \<otimes>\<^sub>2 y)"
    3.80 +      (a \<odot>\<^bsub>M\<^esub> x) \<otimes>\<^bsub>M\<^esub> y = a \<odot>\<^bsub>M\<^esub> (x \<otimes>\<^bsub>M\<^esub> y)"
    3.81    shows "algebra R M"
    3.82    by (auto intro!: algebra.intro algebra_axioms.intro cring.axioms 
    3.83      module_axioms.intro prems)
    3.84 @@ -93,52 +93,53 @@
    3.85  subsection {* Basic Properties of Algebras *}
    3.86  
    3.87  lemma (in algebra) smult_l_null [simp]:
    3.88 -  "x \<in> carrier M ==> \<zero> \<odot>\<^sub>2 x = \<zero>\<^sub>2"
    3.89 +  "x \<in> carrier M ==> \<zero> \<odot>\<^bsub>M\<^esub> x = \<zero>\<^bsub>M\<^esub>"
    3.90  proof -
    3.91    assume M: "x \<in> carrier M"
    3.92    note facts = M smult_closed
    3.93 -  from facts have "\<zero> \<odot>\<^sub>2 x = (\<zero> \<odot>\<^sub>2 x \<oplus>\<^sub>2 \<zero> \<odot>\<^sub>2 x) \<oplus>\<^sub>2 \<ominus>\<^sub>2 (\<zero> \<odot>\<^sub>2 x)" by algebra
    3.94 -  also from M have "... = (\<zero> \<oplus> \<zero>) \<odot>\<^sub>2 x \<oplus>\<^sub>2 \<ominus>\<^sub>2 (\<zero> \<odot>\<^sub>2 x)"
    3.95 +  from facts have "\<zero> \<odot>\<^bsub>M\<^esub> x = (\<zero> \<odot>\<^bsub>M\<^esub> x \<oplus>\<^bsub>M\<^esub> \<zero> \<odot>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub> (\<zero> \<odot>\<^bsub>M\<^esub> x)" by algebra
    3.96 +  also from M have "... = (\<zero> \<oplus> \<zero>) \<odot>\<^bsub>M\<^esub> x \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub> (\<zero> \<odot>\<^bsub>M\<^esub> x)"
    3.97      by (simp add: smult_l_distr del: R.l_zero R.r_zero)
    3.98 -  also from facts have "... = \<zero>\<^sub>2" by algebra
    3.99 +  also from facts have "... = \<zero>\<^bsub>M\<^esub>" by algebra
   3.100    finally show ?thesis .
   3.101  qed
   3.102  
   3.103  lemma (in algebra) smult_r_null [simp]:
   3.104 -  "a \<in> carrier R ==> a \<odot>\<^sub>2 \<zero>\<^sub>2 = \<zero>\<^sub>2";
   3.105 +  "a \<in> carrier R ==> a \<odot>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> = \<zero>\<^bsub>M\<^esub>";
   3.106  proof -
   3.107    assume R: "a \<in> carrier R"
   3.108    note facts = R smult_closed
   3.109 -  from facts have "a \<odot>\<^sub>2 \<zero>\<^sub>2 = (a \<odot>\<^sub>2 \<zero>\<^sub>2 \<oplus>\<^sub>2 a \<odot>\<^sub>2 \<zero>\<^sub>2) \<oplus>\<^sub>2 \<ominus>\<^sub>2 (a \<odot>\<^sub>2 \<zero>\<^sub>2)"
   3.110 +  from facts have "a \<odot>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> = (a \<odot>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub>) \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub> (a \<odot>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub>)"
   3.111      by algebra
   3.112 -  also from R have "... = a \<odot>\<^sub>2 (\<zero>\<^sub>2 \<oplus>\<^sub>2 \<zero>\<^sub>2) \<oplus>\<^sub>2 \<ominus>\<^sub>2 (a \<odot>\<^sub>2 \<zero>\<^sub>2)"
   3.113 +  also from R have "... = a \<odot>\<^bsub>M\<^esub> (\<zero>\<^bsub>M\<^esub> \<oplus>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub>) \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub> (a \<odot>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub>)"
   3.114      by (simp add: smult_r_distr del: M.l_zero M.r_zero)
   3.115 -  also from facts have "... = \<zero>\<^sub>2" by algebra
   3.116 +  also from facts have "... = \<zero>\<^bsub>M\<^esub>" by algebra
   3.117    finally show ?thesis .
   3.118  qed
   3.119  
   3.120  lemma (in algebra) smult_l_minus:
   3.121 -  "[| a \<in> carrier R; x \<in> carrier M |] ==> (\<ominus>a) \<odot>\<^sub>2 x = \<ominus>\<^sub>2 (a \<odot>\<^sub>2 x)"
   3.122 +  "[| a \<in> carrier R; x \<in> carrier M |] ==> (\<ominus>a) \<odot>\<^bsub>M\<^esub> x = \<ominus>\<^bsub>M\<^esub> (a \<odot>\<^bsub>M\<^esub> x)"
   3.123  proof -
   3.124    assume RM: "a \<in> carrier R" "x \<in> carrier M"
   3.125    note facts = RM smult_closed
   3.126 -  from facts have "(\<ominus>a) \<odot>\<^sub>2 x = (\<ominus>a \<odot>\<^sub>2 x \<oplus>\<^sub>2 a \<odot>\<^sub>2 x) \<oplus>\<^sub>2 \<ominus>\<^sub>2(a \<odot>\<^sub>2 x)" by algebra
   3.127 -  also from RM have "... = (\<ominus>a \<oplus> a) \<odot>\<^sub>2 x \<oplus>\<^sub>2 \<ominus>\<^sub>2(a \<odot>\<^sub>2 x)"
   3.128 +  from facts have "(\<ominus>a) \<odot>\<^bsub>M\<^esub> x = (\<ominus>a \<odot>\<^bsub>M\<^esub> x \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub>(a \<odot>\<^bsub>M\<^esub> x)"
   3.129 +    by algebra
   3.130 +  also from RM have "... = (\<ominus>a \<oplus> a) \<odot>\<^bsub>M\<^esub> x \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub>(a \<odot>\<^bsub>M\<^esub> x)"
   3.131      by (simp add: smult_l_distr)
   3.132 -  also from facts smult_l_null have "... = \<ominus>\<^sub>2(a \<odot>\<^sub>2 x)" by algebra
   3.133 +  also from facts smult_l_null have "... = \<ominus>\<^bsub>M\<^esub>(a \<odot>\<^bsub>M\<^esub> x)" by algebra
   3.134    finally show ?thesis .
   3.135  qed
   3.136  
   3.137  lemma (in algebra) smult_r_minus:
   3.138 -  "[| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^sub>2 (\<ominus>\<^sub>2x) = \<ominus>\<^sub>2 (a \<odot>\<^sub>2 x)"
   3.139 +  "[| a \<in> carrier R; x \<in> carrier M |] ==> a \<odot>\<^bsub>M\<^esub> (\<ominus>\<^bsub>M\<^esub>x) = \<ominus>\<^bsub>M\<^esub> (a \<odot>\<^bsub>M\<^esub> x)"
   3.140  proof -
   3.141    assume RM: "a \<in> carrier R" "x \<in> carrier M"
   3.142    note facts = RM smult_closed
   3.143 -  from facts have "a \<odot>\<^sub>2 (\<ominus>\<^sub>2x) = (a \<odot>\<^sub>2 \<ominus>\<^sub>2x \<oplus>\<^sub>2 a \<odot>\<^sub>2 x) \<oplus>\<^sub>2 \<ominus>\<^sub>2(a \<odot>\<^sub>2 x)"
   3.144 +  from facts have "a \<odot>\<^bsub>M\<^esub> (\<ominus>\<^bsub>M\<^esub>x) = (a \<odot>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub>x \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub>(a \<odot>\<^bsub>M\<^esub> x)"
   3.145      by algebra
   3.146 -  also from RM have "... = a \<odot>\<^sub>2 (\<ominus>\<^sub>2x \<oplus>\<^sub>2 x) \<oplus>\<^sub>2 \<ominus>\<^sub>2(a \<odot>\<^sub>2 x)"
   3.147 +  also from RM have "... = a \<odot>\<^bsub>M\<^esub> (\<ominus>\<^bsub>M\<^esub>x \<oplus>\<^bsub>M\<^esub> x) \<oplus>\<^bsub>M\<^esub> \<ominus>\<^bsub>M\<^esub>(a \<odot>\<^bsub>M\<^esub> x)"
   3.148      by (simp add: smult_r_distr)
   3.149 -  also from facts smult_r_null have "... = \<ominus>\<^sub>2(a \<odot>\<^sub>2 x)" by algebra
   3.150 +  also from facts smult_r_null have "... = \<ominus>\<^bsub>M\<^esub>(a \<odot>\<^bsub>M\<^esub> x)" by algebra
   3.151    finally show ?thesis .
   3.152  qed
   3.153  
     4.1 --- a/src/HOL/Algebra/UnivPoly.thy	Sat Jul 31 20:54:23 2004 +0200
     4.2 +++ b/src/HOL/Algebra/UnivPoly.thy	Mon Aug 02 09:44:46 2004 +0200
     4.3 @@ -24,6 +24,10 @@
     4.4  
     4.5  subsection {* The Constructor for Univariate Polynomials *}
     4.6  
     4.7 +text {*
     4.8 +  Functions with finite support.
     4.9 +*}
    4.10 +
    4.11  locale bound =
    4.12    fixes z :: 'a
    4.13      and n :: nat
    4.14 @@ -47,9 +51,9 @@
    4.15    coeff :: "['p, nat] => 'a"
    4.16  
    4.17  constdefs (structure R)
    4.18 -  up :: "_ => (nat => 'a) set"
    4.19 +  up :: "('a, 'm) ring_scheme => (nat => 'a) set"
    4.20    "up R == {f. f \<in> UNIV -> carrier R & (EX n. bound \<zero> n f)}"
    4.21 -  UP :: "_ => ('a, nat => 'a) up_ring"
    4.22 +  UP :: "('a, 'm) ring_scheme => ('a, nat => 'a) up_ring"
    4.23    "UP R == (|
    4.24      carrier = up R,
    4.25      mult = (%p:up R. %q:up R. %n. \<Oplus>i \<in> {..n}. p i \<otimes> q (n-i)),
    4.26 @@ -167,8 +171,8 @@
    4.27  locale UP_domain = UP_cring + "domain" R
    4.28  
    4.29  text {*
    4.30 -  Temporarily declare @{text UP.P_def} as simp rule.
    4.31 -*}  (* TODO: use antiquotation once text (in locale) is supported. *)
    4.32 +  Temporarily declare @{thm [locale=UP] P_def} as simp rule.
    4.33 +*}
    4.34  
    4.35  declare (in UP) P_def [simp]
    4.36  
    4.37 @@ -183,26 +187,26 @@
    4.38  qed
    4.39  
    4.40  lemma (in UP_cring) coeff_zero [simp]:
    4.41 -  "coeff P \<zero>\<^sub>2 n = \<zero>"
    4.42 +  "coeff P \<zero>\<^bsub>P\<^esub> n = \<zero>"
    4.43    by (auto simp add: UP_def)
    4.44  
    4.45  lemma (in UP_cring) coeff_one [simp]:
    4.46 -  "coeff P \<one>\<^sub>2 n = (if n=0 then \<one> else \<zero>)"
    4.47 +  "coeff P \<one>\<^bsub>P\<^esub> n = (if n=0 then \<one> else \<zero>)"
    4.48    using up_one_closed by (simp add: UP_def)
    4.49  
    4.50  lemma (in UP_cring) coeff_smult [simp]:
    4.51    "[| a \<in> carrier R; p \<in> carrier P |] ==>
    4.52 -  coeff P (a \<odot>\<^sub>2 p) n = a \<otimes> coeff P p n"
    4.53 +  coeff P (a \<odot>\<^bsub>P\<^esub> p) n = a \<otimes> coeff P p n"
    4.54    by (simp add: UP_def up_smult_closed)
    4.55  
    4.56  lemma (in UP_cring) coeff_add [simp]:
    4.57    "[| p \<in> carrier P; q \<in> carrier P |] ==>
    4.58 -  coeff P (p \<oplus>\<^sub>2 q) n = coeff P p n \<oplus> coeff P q n"
    4.59 +  coeff P (p \<oplus>\<^bsub>P\<^esub> q) n = coeff P p n \<oplus> coeff P q n"
    4.60    by (simp add: UP_def up_add_closed)
    4.61  
    4.62  lemma (in UP_cring) coeff_mult [simp]:
    4.63    "[| p \<in> carrier P; q \<in> carrier P |] ==>
    4.64 -  coeff P (p \<otimes>\<^sub>2 q) n = (\<Oplus>i \<in> {..n}. coeff P p i \<otimes> coeff P q (n-i))"
    4.65 +  coeff P (p \<otimes>\<^bsub>P\<^esub> q) n = (\<Oplus>i \<in> {..n}. coeff P p i \<otimes> coeff P q (n-i))"
    4.66    by (simp add: UP_def up_mult_closed)
    4.67  
    4.68  lemma (in UP) up_eqI:
    4.69 @@ -219,19 +223,19 @@
    4.70  text {* Operations are closed over @{term P}. *}
    4.71  
    4.72  lemma (in UP_cring) UP_mult_closed [simp]:
    4.73 -  "[| p \<in> carrier P; q \<in> carrier P |] ==> p \<otimes>\<^sub>2 q \<in> carrier P"
    4.74 +  "[| p \<in> carrier P; q \<in> carrier P |] ==> p \<otimes>\<^bsub>P\<^esub> q \<in> carrier P"
    4.75    by (simp add: UP_def up_mult_closed)
    4.76  
    4.77  lemma (in UP_cring) UP_one_closed [simp]:
    4.78 -  "\<one>\<^sub>2 \<in> carrier P"
    4.79 +  "\<one>\<^bsub>P\<^esub> \<in> carrier P"
    4.80    by (simp add: UP_def up_one_closed)
    4.81  
    4.82  lemma (in UP_cring) UP_zero_closed [intro, simp]:
    4.83 -  "\<zero>\<^sub>2 \<in> carrier P"
    4.84 +  "\<zero>\<^bsub>P\<^esub> \<in> carrier P"
    4.85    by (auto simp add: UP_def)
    4.86  
    4.87  lemma (in UP_cring) UP_a_closed [intro, simp]:
    4.88 -  "[| p \<in> carrier P; q \<in> carrier P |] ==> p \<oplus>\<^sub>2 q \<in> carrier P"
    4.89 +  "[| p \<in> carrier P; q \<in> carrier P |] ==> p \<oplus>\<^bsub>P\<^esub> q \<in> carrier P"
    4.90    by (simp add: UP_def up_add_closed)
    4.91  
    4.92  lemma (in UP_cring) monom_closed [simp]:
    4.93 @@ -239,7 +243,7 @@
    4.94    by (auto simp add: UP_def up_def Pi_def)
    4.95  
    4.96  lemma (in UP_cring) UP_smult_closed [simp]:
    4.97 -  "[| a \<in> carrier R; p \<in> carrier P |] ==> a \<odot>\<^sub>2 p \<in> carrier P"
    4.98 +  "[| a \<in> carrier R; p \<in> carrier P |] ==> a \<odot>\<^bsub>P\<^esub> p \<in> carrier P"
    4.99    by (simp add: UP_def up_smult_closed)
   4.100  
   4.101  lemma (in UP) coeff_closed [simp]:
   4.102 @@ -252,17 +256,17 @@
   4.103  
   4.104  lemma (in UP_cring) UP_a_assoc:
   4.105    assumes R: "p \<in> carrier P" "q \<in> carrier P" "r \<in> carrier P"
   4.106 -  shows "(p \<oplus>\<^sub>2 q) \<oplus>\<^sub>2 r = p \<oplus>\<^sub>2 (q \<oplus>\<^sub>2 r)"
   4.107 +  shows "(p \<oplus>\<^bsub>P\<^esub> q) \<oplus>\<^bsub>P\<^esub> r = p \<oplus>\<^bsub>P\<^esub> (q \<oplus>\<^bsub>P\<^esub> r)"
   4.108    by (rule up_eqI, simp add: a_assoc R, simp_all add: R)
   4.109  
   4.110  lemma (in UP_cring) UP_l_zero [simp]:
   4.111    assumes R: "p \<in> carrier P"
   4.112 -  shows "\<zero>\<^sub>2 \<oplus>\<^sub>2 p = p"
   4.113 +  shows "\<zero>\<^bsub>P\<^esub> \<oplus>\<^bsub>P\<^esub> p = p"
   4.114    by (rule up_eqI, simp_all add: R)
   4.115  
   4.116  lemma (in UP_cring) UP_l_neg_ex:
   4.117    assumes R: "p \<in> carrier P"
   4.118 -  shows "EX q : carrier P. q \<oplus>\<^sub>2 p = \<zero>\<^sub>2"
   4.119 +  shows "EX q : carrier P. q \<oplus>\<^bsub>P\<^esub> p = \<zero>\<^bsub>P\<^esub>"
   4.120  proof -
   4.121    let ?q = "%i. \<ominus> (p i)"
   4.122    from R have closed: "?q \<in> carrier P"
   4.123 @@ -271,14 +275,14 @@
   4.124      by (simp add: UP_def P_def up_a_inv_closed)
   4.125    show ?thesis
   4.126    proof
   4.127 -    show "?q \<oplus>\<^sub>2 p = \<zero>\<^sub>2"
   4.128 +    show "?q \<oplus>\<^bsub>P\<^esub> p = \<zero>\<^bsub>P\<^esub>"
   4.129        by (auto intro!: up_eqI simp add: R closed coeff R.l_neg)
   4.130    qed (rule closed)
   4.131  qed
   4.132  
   4.133  lemma (in UP_cring) UP_a_comm:
   4.134    assumes R: "p \<in> carrier P" "q \<in> carrier P"
   4.135 -  shows "p \<oplus>\<^sub>2 q = q \<oplus>\<^sub>2 p"
   4.136 +  shows "p \<oplus>\<^bsub>P\<^esub> q = q \<oplus>\<^bsub>P\<^esub> p"
   4.137    by (rule up_eqI, simp add: a_comm R, simp_all add: R)
   4.138  
   4.139  ML_setup {*
   4.140 @@ -287,7 +291,7 @@
   4.141  
   4.142  lemma (in UP_cring) UP_m_assoc:
   4.143    assumes R: "p \<in> carrier P" "q \<in> carrier P" "r \<in> carrier P"
   4.144 -  shows "(p \<otimes>\<^sub>2 q) \<otimes>\<^sub>2 r = p \<otimes>\<^sub>2 (q \<otimes>\<^sub>2 r)"
   4.145 +  shows "(p \<otimes>\<^bsub>P\<^esub> q) \<otimes>\<^bsub>P\<^esub> r = p \<otimes>\<^bsub>P\<^esub> (q \<otimes>\<^bsub>P\<^esub> r)"
   4.146  proof (rule up_eqI)
   4.147    fix n
   4.148    {
   4.149 @@ -310,7 +314,7 @@
   4.150            (simp cong: finsum_cong add: Pi_def a_ac finsum_ldistr m_assoc)
   4.151      qed
   4.152    }
   4.153 -  with R show "coeff P ((p \<otimes>\<^sub>2 q) \<otimes>\<^sub>2 r) n = coeff P (p \<otimes>\<^sub>2 (q \<otimes>\<^sub>2 r)) n"
   4.154 +  with R show "coeff P ((p \<otimes>\<^bsub>P\<^esub> q) \<otimes>\<^bsub>P\<^esub> r) n = coeff P (p \<otimes>\<^bsub>P\<^esub> (q \<otimes>\<^bsub>P\<^esub> r)) n"
   4.155      by (simp add: Pi_def)
   4.156  qed (simp_all add: R)
   4.157  
   4.158 @@ -320,10 +324,10 @@
   4.159  
   4.160  lemma (in UP_cring) UP_l_one [simp]:
   4.161    assumes R: "p \<in> carrier P"
   4.162 -  shows "\<one>\<^sub>2 \<otimes>\<^sub>2 p = p"
   4.163 +  shows "\<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> p = p"
   4.164  proof (rule up_eqI)
   4.165    fix n
   4.166 -  show "coeff P (\<one>\<^sub>2 \<otimes>\<^sub>2 p) n = coeff P p n"
   4.167 +  show "coeff P (\<one>\<^bsub>P\<^esub> \<otimes>\<^bsub>P\<^esub> p) n = coeff P p n"
   4.168    proof (cases n)
   4.169      case 0 with R show ?thesis by simp
   4.170    next
   4.171 @@ -334,12 +338,12 @@
   4.172  
   4.173  lemma (in UP_cring) UP_l_distr:
   4.174    assumes R: "p \<in> carrier P" "q \<in> carrier P" "r \<in> carrier P"
   4.175 -  shows "(p \<oplus>\<^sub>2 q) \<otimes>\<^sub>2 r = (p \<otimes>\<^sub>2 r) \<oplus>\<^sub>2 (q \<otimes>\<^sub>2 r)"
   4.176 +  shows "(p \<oplus>\<^bsub>P\<^esub> q) \<otimes>\<^bsub>P\<^esub> r = (p \<otimes>\<^bsub>P\<^esub> r) \<oplus>\<^bsub>P\<^esub> (q \<otimes>\<^bsub>P\<^esub> r)"
   4.177    by (rule up_eqI) (simp add: l_distr R Pi_def, simp_all add: R)
   4.178  
   4.179  lemma (in UP_cring) UP_m_comm:
   4.180    assumes R: "p \<in> carrier P" "q \<in> carrier P"
   4.181 -  shows "p \<otimes>\<^sub>2 q = q \<otimes>\<^sub>2 p"
   4.182 +  shows "p \<otimes>\<^bsub>P\<^esub> q = q \<otimes>\<^bsub>P\<^esub> p"
   4.183  proof (rule up_eqI)
   4.184    fix n
   4.185    {
   4.186 @@ -357,7 +361,7 @@
   4.187      qed
   4.188    }
   4.189    note l = this
   4.190 -  from R show "coeff P (p \<otimes>\<^sub>2 q) n =  coeff P (q \<otimes>\<^sub>2 p) n"
   4.191 +  from R show "coeff P (p \<otimes>\<^bsub>P\<^esub> q) n =  coeff P (q \<otimes>\<^bsub>P\<^esub> p) n"
   4.192      apply (simp add: Pi_def)
   4.193      apply (subst l)
   4.194      apply (auto simp add: Pi_def)
   4.195 @@ -375,16 +379,16 @@
   4.196    by (auto intro: ring.intro cring.axioms UP_cring)
   4.197  
   4.198  lemma (in UP_cring) UP_a_inv_closed [intro, simp]:
   4.199 -  "p \<in> carrier P ==> \<ominus>\<^sub>2 p \<in> carrier P"
   4.200 +  "p \<in> carrier P ==> \<ominus>\<^bsub>P\<^esub> p \<in> carrier P"
   4.201    by (rule abelian_group.a_inv_closed
   4.202      [OF ring.is_abelian_group [OF UP_ring]])
   4.203  
   4.204  lemma (in UP_cring) coeff_a_inv [simp]:
   4.205    assumes R: "p \<in> carrier P"
   4.206 -  shows "coeff P (\<ominus>\<^sub>2 p) n = \<ominus> (coeff P p n)"
   4.207 +  shows "coeff P (\<ominus>\<^bsub>P\<^esub> p) n = \<ominus> (coeff P p n)"
   4.208  proof -
   4.209    from R coeff_closed UP_a_inv_closed have
   4.210 -    "coeff P (\<ominus>\<^sub>2 p) n = \<ominus> coeff P p n \<oplus> (coeff P p n \<oplus> coeff P (\<ominus>\<^sub>2 p) n)"
   4.211 +    "coeff P (\<ominus>\<^bsub>P\<^esub> p) n = \<ominus> coeff P p n \<oplus> (coeff P p n \<oplus> coeff P (\<ominus>\<^bsub>P\<^esub> p) n)"
   4.212      by algebra
   4.213    also from R have "... =  \<ominus> (coeff P p n)"
   4.214      by (simp del: coeff_add add: coeff_add [THEN sym]
   4.215 @@ -396,6 +400,8 @@
   4.216    Instantiation of lemmas from @{term cring}.
   4.217  *}
   4.218  
   4.219 +(* TODO: this should be automated with an instantiation command. *)
   4.220 +
   4.221  lemma (in UP_cring) UP_monoid:
   4.222    "monoid P"
   4.223    by (fast intro!: cring.is_comm_monoid comm_monoid.axioms monoid.intro
   4.224 @@ -545,34 +551,35 @@
   4.225  
   4.226  lemma (in UP_cring) UP_smult_l_distr:
   4.227    "[| a \<in> carrier R; b \<in> carrier R; p \<in> carrier P |] ==>
   4.228 -  (a \<oplus> b) \<odot>\<^sub>2 p = a \<odot>\<^sub>2 p \<oplus>\<^sub>2 b \<odot>\<^sub>2 p"
   4.229 +  (a \<oplus> b) \<odot>\<^bsub>P\<^esub> p = a \<odot>\<^bsub>P\<^esub> p \<oplus>\<^bsub>P\<^esub> b \<odot>\<^bsub>P\<^esub> p"
   4.230    by (rule up_eqI) (simp_all add: R.l_distr)
   4.231  
   4.232  lemma (in UP_cring) UP_smult_r_distr:
   4.233    "[| a \<in> carrier R; p \<in> carrier P; q \<in> carrier P |] ==>
   4.234 -  a \<odot>\<^sub>2 (p \<oplus>\<^sub>2 q) = a \<odot>\<^sub>2 p \<oplus>\<^sub>2 a \<odot>\<^sub>2 q"
   4.235 +  a \<odot>\<^bsub>P\<^esub> (p \<oplus>\<^bsub>P\<^esub> q) = a \<odot>\<^bsub>P\<^esub> p \<oplus>\<^bsub>P\<^esub> a \<odot>\<^bsub>P\<^esub> q"
   4.236    by (rule up_eqI) (simp_all add: R.r_distr)
   4.237  
   4.238  lemma (in UP_cring) UP_smult_assoc1:
   4.239        "[| a \<in> carrier R; b \<in> carrier R; p \<in> carrier P |] ==>
   4.240 -      (a \<otimes> b) \<odot>\<^sub>2 p = a \<odot>\<^sub>2 (b \<odot>\<^sub>2 p)"
   4.241 +      (a \<otimes> b) \<odot>\<^bsub>P\<^esub> p = a \<odot>\<^bsub>P\<^esub> (b \<odot>\<^bsub>P\<^esub> p)"
   4.242    by (rule up_eqI) (simp_all add: R.m_assoc)
   4.243  
   4.244  lemma (in UP_cring) UP_smult_one [simp]:
   4.245 -      "p \<in> carrier P ==> \<one> \<odot>\<^sub>2 p = p"
   4.246 +      "p \<in> carrier P ==> \<one> \<odot>\<^bsub>P\<^esub> p = p"
   4.247    by (rule up_eqI) simp_all
   4.248  
   4.249  lemma (in UP_cring) UP_smult_assoc2:
   4.250    "[| a \<in> carrier R; p \<in> carrier P; q \<in> carrier P |] ==>
   4.251 -  (a \<odot>\<^sub>2 p) \<otimes>\<^sub>2 q = a \<odot>\<^sub>2 (p \<otimes>\<^sub>2 q)"
   4.252 +  (a \<odot>\<^bsub>P\<^esub> p) \<otimes>\<^bsub>P\<^esub> q = a \<odot>\<^bsub>P\<^esub> (p \<otimes>\<^bsub>P\<^esub> q)"
   4.253    by (rule up_eqI) (simp_all add: R.finsum_rdistr R.m_assoc Pi_def)
   4.254  
   4.255  text {*
   4.256    Instantiation of lemmas from @{term algebra}.
   4.257  *}
   4.258  
   4.259 +(* TODO: this should be automated with an instantiation command. *)
   4.260 +
   4.261  (* TODO: move to CRing.thy, really a fact missing from the locales package *)
   4.262 -
   4.263  lemma (in cring) cring:
   4.264    "cring R"
   4.265    by (fast intro: cring.intro prems)
   4.266 @@ -597,7 +604,7 @@
   4.267  subsection {* Further lemmas involving monomials *}
   4.268  
   4.269  lemma (in UP_cring) monom_zero [simp]:
   4.270 -  "monom P \<zero> n = \<zero>\<^sub>2"
   4.271 +  "monom P \<zero> n = \<zero>\<^bsub>P\<^esub>"
   4.272    by (simp add: UP_def P_def)
   4.273  
   4.274  ML_setup {*
   4.275 @@ -606,10 +613,10 @@
   4.276  
   4.277  lemma (in UP_cring) monom_mult_is_smult:
   4.278    assumes R: "a \<in> carrier R" "p \<in> carrier P"
   4.279 -  shows "monom P a 0 \<otimes>\<^sub>2 p = a \<odot>\<^sub>2 p"
   4.280 +  shows "monom P a 0 \<otimes>\<^bsub>P\<^esub> p = a \<odot>\<^bsub>P\<^esub> p"
   4.281  proof (rule up_eqI)
   4.282    fix n
   4.283 -  have "coeff P (p \<otimes>\<^sub>2 monom P a 0) n = coeff P (a \<odot>\<^sub>2 p) n"
   4.284 +  have "coeff P (p \<otimes>\<^bsub>P\<^esub> monom P a 0) n = coeff P (a \<odot>\<^bsub>P\<^esub> p) n"
   4.285    proof (cases n)
   4.286      case 0 with R show ?thesis by (simp add: R.m_comm)
   4.287    next
   4.288 @@ -617,7 +624,7 @@
   4.289        by (simp cong: finsum_cong add: R.r_null Pi_def)
   4.290          (simp add: m_comm)
   4.291    qed
   4.292 -  with R show "coeff P (monom P a 0 \<otimes>\<^sub>2 p) n = coeff P (a \<odot>\<^sub>2 p) n"
   4.293 +  with R show "coeff P (monom P a 0 \<otimes>\<^bsub>P\<^esub> p) n = coeff P (a \<odot>\<^bsub>P\<^esub> p) n"
   4.294      by (simp add: UP_m_comm)
   4.295  qed (simp_all add: R)
   4.296  
   4.297 @@ -627,7 +634,7 @@
   4.298  
   4.299  lemma (in UP_cring) monom_add [simp]:
   4.300    "[| a \<in> carrier R; b \<in> carrier R |] ==>
   4.301 -  monom P (a \<oplus> b) n = monom P a n \<oplus>\<^sub>2 monom P b n"
   4.302 +  monom P (a \<oplus> b) n = monom P a n \<oplus>\<^bsub>P\<^esub> monom P b n"
   4.303    by (rule up_eqI) simp_all
   4.304  
   4.305  ML_setup {*
   4.306 @@ -635,10 +642,10 @@
   4.307  *}
   4.308  
   4.309  lemma (in UP_cring) monom_one_Suc:
   4.310 -  "monom P \<one> (Suc n) = monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1"
   4.311 +  "monom P \<one> (Suc n) = monom P \<one> n \<otimes>\<^bsub>P\<^esub> monom P \<one> 1"
   4.312  proof (rule up_eqI)
   4.313    fix k
   4.314 -  show "coeff P (monom P \<one> (Suc n)) k = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k"
   4.315 +  show "coeff P (monom P \<one> (Suc n)) k = coeff P (monom P \<one> n \<otimes>\<^bsub>P\<^esub> monom P \<one> 1) k"
   4.316    proof (cases "k = Suc n")
   4.317      case True show ?thesis
   4.318      proof -
   4.319 @@ -652,11 +659,12 @@
   4.320        also have "... = (\<Oplus>i \<in>  {..n}. coeff P (monom P \<one> n) i \<otimes>
   4.321          coeff P (monom P \<one> 1) (k - i))"
   4.322          by (simp only: ivl_disj_un_singleton)
   4.323 -      also from True have "... = (\<Oplus>i \<in> {..n} \<union> {n<..k}. coeff P (monom P \<one> n) i \<otimes>
   4.324 +      also from True
   4.325 +      have "... = (\<Oplus>i \<in> {..n} \<union> {n<..k}. coeff P (monom P \<one> n) i \<otimes>
   4.326          coeff P (monom P \<one> 1) (k - i))"
   4.327          by (simp cong: finsum_cong add: finsum_Un_disjoint ivl_disj_int_one
   4.328            order_less_imp_not_eq Pi_def)
   4.329 -      also from True have "... = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k"
   4.330 +      also from True have "... = coeff P (monom P \<one> n \<otimes>\<^bsub>P\<^esub> monom P \<one> 1) k"
   4.331          by (simp add: ivl_disj_un_one)
   4.332        finally show ?thesis .
   4.333      qed
   4.334 @@ -668,7 +676,8 @@
   4.335      from neq have "coeff P (monom P \<one> (Suc n)) k = \<zero>" by simp
   4.336      also have "... = (\<Oplus>i \<in> {..k}. ?s i)"
   4.337      proof -
   4.338 -      have f1: "(\<Oplus>i \<in> {..<n}. ?s i) = \<zero>" by (simp cong: finsum_cong add: Pi_def)
   4.339 +      have f1: "(\<Oplus>i \<in> {..<n}. ?s i) = \<zero>"
   4.340 +        by (simp cong: finsum_cong add: Pi_def)
   4.341        from neq have f2: "(\<Oplus>i \<in> {n}. ?s i) = \<zero>"
   4.342          by (simp cong: finsum_cong add: Pi_def) arith
   4.343        have f3: "n < k ==> (\<Oplus>i \<in> {n<..k}. ?s i) = \<zero>"
   4.344 @@ -702,7 +711,7 @@
   4.345          qed
   4.346        qed
   4.347      qed
   4.348 -    also have "... = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k" by simp
   4.349 +    also have "... = coeff P (monom P \<one> n \<otimes>\<^bsub>P\<^esub> monom P \<one> 1) k" by simp
   4.350      finally show ?thesis .
   4.351    qed
   4.352  qed (simp_all)
   4.353 @@ -712,15 +721,15 @@
   4.354  *}
   4.355  
   4.356  lemma (in UP_cring) monom_mult_smult:
   4.357 -  "[| a \<in> carrier R; b \<in> carrier R |] ==> monom P (a \<otimes> b) n = a \<odot>\<^sub>2 monom P b n"
   4.358 +  "[| a \<in> carrier R; b \<in> carrier R |] ==> monom P (a \<otimes> b) n = a \<odot>\<^bsub>P\<^esub> monom P b n"
   4.359    by (rule up_eqI) simp_all
   4.360  
   4.361  lemma (in UP_cring) monom_one [simp]:
   4.362 -  "monom P \<one> 0 = \<one>\<^sub>2"
   4.363 +  "monom P \<one> 0 = \<one>\<^bsub>P\<^esub>"
   4.364    by (rule up_eqI) simp_all
   4.365  
   4.366  lemma (in UP_cring) monom_one_mult:
   4.367 -  "monom P \<one> (n + m) = monom P \<one> n \<otimes>\<^sub>2 monom P \<one> m"
   4.368 +  "monom P \<one> (n + m) = monom P \<one> n \<otimes>\<^bsub>P\<^esub> monom P \<one> m"
   4.369  proof (induct n)
   4.370    case 0 show ?case by simp
   4.371  next
   4.372 @@ -730,31 +739,31 @@
   4.373  
   4.374  lemma (in UP_cring) monom_mult [simp]:
   4.375    assumes R: "a \<in> carrier R" "b \<in> carrier R"
   4.376 -  shows "monom P (a \<otimes> b) (n + m) = monom P a n \<otimes>\<^sub>2 monom P b m"
   4.377 +  shows "monom P (a \<otimes> b) (n + m) = monom P a n \<otimes>\<^bsub>P\<^esub> monom P b m"
   4.378  proof -
   4.379    from R have "monom P (a \<otimes> b) (n + m) = monom P (a \<otimes> b \<otimes> \<one>) (n + m)" by simp
   4.380 -  also from R have "... = a \<otimes> b \<odot>\<^sub>2 monom P \<one> (n + m)"
   4.381 +  also from R have "... = a \<otimes> b \<odot>\<^bsub>P\<^esub> monom P \<one> (n + m)"
   4.382      by (simp add: monom_mult_smult del: r_one)
   4.383 -  also have "... = a \<otimes> b \<odot>\<^sub>2 (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> m)"
   4.384 +  also have "... = a \<otimes> b \<odot>\<^bsub>P\<^esub> (monom P \<one> n \<otimes>\<^bsub>P\<^esub> monom P \<one> m)"
   4.385      by (simp only: monom_one_mult)
   4.386 -  also from R have "... = a \<odot>\<^sub>2 (b \<odot>\<^sub>2 (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> m))"
   4.387 +  also from R have "... = a \<odot>\<^bsub>P\<^esub> (b \<odot>\<^bsub>P\<^esub> (monom P \<one> n \<otimes>\<^bsub>P\<^esub> monom P \<one> m))"
   4.388      by (simp add: UP_smult_assoc1)
   4.389 -  also from R have "... = a \<odot>\<^sub>2 (b \<odot>\<^sub>2 (monom P \<one> m \<otimes>\<^sub>2 monom P \<one> n))"
   4.390 +  also from R have "... = a \<odot>\<^bsub>P\<^esub> (b \<odot>\<^bsub>P\<^esub> (monom P \<one> m \<otimes>\<^bsub>P\<^esub> monom P \<one> n))"
   4.391      by (simp add: UP_m_comm)
   4.392 -  also from R have "... = a \<odot>\<^sub>2 ((b \<odot>\<^sub>2 monom P \<one> m) \<otimes>\<^sub>2 monom P \<one> n)"
   4.393 +  also from R have "... = a \<odot>\<^bsub>P\<^esub> ((b \<odot>\<^bsub>P\<^esub> monom P \<one> m) \<otimes>\<^bsub>P\<^esub> monom P \<one> n)"
   4.394      by (simp add: UP_smult_assoc2)
   4.395 -  also from R have "... = a \<odot>\<^sub>2 (monom P \<one> n \<otimes>\<^sub>2 (b \<odot>\<^sub>2 monom P \<one> m))"
   4.396 +  also from R have "... = a \<odot>\<^bsub>P\<^esub> (monom P \<one> n \<otimes>\<^bsub>P\<^esub> (b \<odot>\<^bsub>P\<^esub> monom P \<one> m))"
   4.397      by (simp add: UP_m_comm)
   4.398 -  also from R have "... = (a \<odot>\<^sub>2 monom P \<one> n) \<otimes>\<^sub>2 (b \<odot>\<^sub>2 monom P \<one> m)"
   4.399 +  also from R have "... = (a \<odot>\<^bsub>P\<^esub> monom P \<one> n) \<otimes>\<^bsub>P\<^esub> (b \<odot>\<^bsub>P\<^esub> monom P \<one> m)"
   4.400      by (simp add: UP_smult_assoc2)
   4.401 -  also from R have "... = monom P (a \<otimes> \<one>) n \<otimes>\<^sub>2 monom P (b \<otimes> \<one>) m"
   4.402 +  also from R have "... = monom P (a \<otimes> \<one>) n \<otimes>\<^bsub>P\<^esub> monom P (b \<otimes> \<one>) m"
   4.403      by (simp add: monom_mult_smult del: r_one)
   4.404 -  also from R have "... = monom P a n \<otimes>\<^sub>2 monom P b m" by simp
   4.405 +  also from R have "... = monom P a n \<otimes>\<^bsub>P\<^esub> monom P b m" by simp
   4.406    finally show ?thesis .
   4.407  qed
   4.408  
   4.409  lemma (in UP_cring) monom_a_inv [simp]:
   4.410 -  "a \<in> carrier R ==> monom P (\<ominus> a) n = \<ominus>\<^sub>2 monom P a n"
   4.411 +  "a \<in> carrier R ==> monom P (\<ominus> a) n = \<ominus>\<^bsub>P\<^esub> monom P a n"
   4.412    by (rule up_eqI) simp_all
   4.413  
   4.414  lemma (in UP_cring) monom_inj:
   4.415 @@ -769,12 +778,13 @@
   4.416  subsection {* The degree function *}
   4.417  
   4.418  constdefs (structure R)
   4.419 -  deg :: "[_, nat => 'a] => nat"
   4.420 +  deg :: "[('a, 'm) ring_scheme, nat => 'a] => nat"
   4.421    "deg R p == LEAST n. bound \<zero> n (coeff (UP R) p)"
   4.422  
   4.423  lemma (in UP_cring) deg_aboveI:
   4.424    "[| (!!m. n < m ==> coeff P p m = \<zero>); p \<in> carrier P |] ==> deg R p <= n"
   4.425    by (unfold deg_def P_def) (fast intro: Least_le)
   4.426 +
   4.427  (*
   4.428  lemma coeff_bound_ex: "EX n. bound n (coeff p)"
   4.429  proof -
   4.430 @@ -791,6 +801,7 @@
   4.431    with prem show P .
   4.432  qed
   4.433  *)
   4.434 +
   4.435  lemma (in UP_cring) deg_aboveD:
   4.436    "[| deg R p < m; p \<in> carrier P |] ==> coeff P p m = \<zero>"
   4.437  proof -
   4.438 @@ -807,7 +818,7 @@
   4.439      and R: "p \<in> carrier P"
   4.440    shows "n <= deg R p"
   4.441  -- {* Logically, this is a slightly stronger version of
   4.442 -  @{thm [source] deg_aboveD} *}
   4.443 +   @{thm [source] deg_aboveD} *}
   4.444  proof (cases "n=0")
   4.445    case True then show ?thesis by simp
   4.446  next
   4.447 @@ -824,7 +835,7 @@
   4.448    proof -
   4.449      have minus: "!!(n::nat) m. n ~= 0 ==> (n - Suc 0 < m) = (n <= m)"
   4.450        by arith
   4.451 -(* TODO: why does proof not work with "1" *)
   4.452 +(* TODO: why does simplification below not work with "1" *)
   4.453      from deg have "deg R p - 1 < (LEAST n. bound \<zero> n (coeff P p))"
   4.454        by (unfold deg_def P_def) arith
   4.455      then have "~ bound \<zero> (deg R p - 1) (coeff P p)" by (rule not_less_Least)
   4.456 @@ -838,13 +849,13 @@
   4.457  qed
   4.458  
   4.459  lemma (in UP_cring) lcoeff_nonzero_nonzero:
   4.460 -  assumes deg: "deg R p = 0" and nonzero: "p ~= \<zero>\<^sub>2" and R: "p \<in> carrier P"
   4.461 +  assumes deg: "deg R p = 0" and nonzero: "p ~= \<zero>\<^bsub>P\<^esub>" and R: "p \<in> carrier P"
   4.462    shows "coeff P p 0 ~= \<zero>"
   4.463  proof -
   4.464    have "EX m. coeff P p m ~= \<zero>"
   4.465    proof (rule classical)
   4.466      assume "~ ?thesis"
   4.467 -    with R have "p = \<zero>\<^sub>2" by (auto intro: up_eqI)
   4.468 +    with R have "p = \<zero>\<^bsub>P\<^esub>" by (auto intro: up_eqI)
   4.469      with nonzero show ?thesis by contradiction
   4.470    qed
   4.471    then obtain m where coeff: "coeff P p m ~= \<zero>" ..
   4.472 @@ -854,7 +865,7 @@
   4.473  qed
   4.474  
   4.475  lemma (in UP_cring) lcoeff_nonzero:
   4.476 -  assumes neq: "p ~= \<zero>\<^sub>2" and R: "p \<in> carrier P"
   4.477 +  assumes neq: "p ~= \<zero>\<^bsub>P\<^esub>" and R: "p \<in> carrier P"
   4.478    shows "coeff P p (deg R p) ~= \<zero>"
   4.479  proof (cases "deg R p = 0")
   4.480    case True with neq R show ?thesis by (simp add: lcoeff_nonzero_nonzero)
   4.481 @@ -871,7 +882,7 @@
   4.482  
   4.483  lemma (in UP_cring) deg_add [simp]:
   4.484    assumes R: "p \<in> carrier P" "q \<in> carrier P"
   4.485 -  shows "deg R (p \<oplus>\<^sub>2 q) <= max (deg R p) (deg R q)"
   4.486 +  shows "deg R (p \<oplus>\<^bsub>P\<^esub> q) <= max (deg R p) (deg R q)"
   4.487  proof (cases "deg R p <= deg R q")
   4.488    case True show ?thesis
   4.489      by (rule deg_aboveI) (simp_all add: True R deg_aboveD)
   4.490 @@ -897,51 +908,51 @@
   4.491  qed
   4.492  
   4.493  lemma (in UP_cring) deg_zero [simp]:
   4.494 -  "deg R \<zero>\<^sub>2 = 0"
   4.495 +  "deg R \<zero>\<^bsub>P\<^esub> = 0"
   4.496  proof (rule le_anti_sym)
   4.497 -  show "deg R \<zero>\<^sub>2 <= 0" by (rule deg_aboveI) simp_all
   4.498 +  show "deg R \<zero>\<^bsub>P\<^esub> <= 0" by (rule deg_aboveI) simp_all
   4.499  next
   4.500 -  show "0 <= deg R \<zero>\<^sub>2" by (rule deg_belowI) simp_all
   4.501 +  show "0 <= deg R \<zero>\<^bsub>P\<^esub>" by (rule deg_belowI) simp_all
   4.502  qed
   4.503  
   4.504  lemma (in UP_cring) deg_one [simp]:
   4.505 -  "deg R \<one>\<^sub>2 = 0"
   4.506 +  "deg R \<one>\<^bsub>P\<^esub> = 0"
   4.507  proof (rule le_anti_sym)
   4.508 -  show "deg R \<one>\<^sub>2 <= 0" by (rule deg_aboveI) simp_all
   4.509 +  show "deg R \<one>\<^bsub>P\<^esub> <= 0" by (rule deg_aboveI) simp_all
   4.510  next
   4.511 -  show "0 <= deg R \<one>\<^sub>2" by (rule deg_belowI) simp_all
   4.512 +  show "0 <= deg R \<one>\<^bsub>P\<^esub>" by (rule deg_belowI) simp_all
   4.513  qed
   4.514  
   4.515  lemma (in UP_cring) deg_uminus [simp]:
   4.516 -  assumes R: "p \<in> carrier P" shows "deg R (\<ominus>\<^sub>2 p) = deg R p"
   4.517 +  assumes R: "p \<in> carrier P" shows "deg R (\<ominus>\<^bsub>P\<^esub> p) = deg R p"
   4.518  proof (rule le_anti_sym)
   4.519 -  show "deg R (\<ominus>\<^sub>2 p) <= deg R p" by (simp add: deg_aboveI deg_aboveD R)
   4.520 +  show "deg R (\<ominus>\<^bsub>P\<^esub> p) <= deg R p" by (simp add: deg_aboveI deg_aboveD R)
   4.521  next
   4.522 -  show "deg R p <= deg R (\<ominus>\<^sub>2 p)"
   4.523 +  show "deg R p <= deg R (\<ominus>\<^bsub>P\<^esub> p)"
   4.524      by (simp add: deg_belowI lcoeff_nonzero_deg
   4.525        inj_on_iff [OF a_inv_inj, of _ "\<zero>", simplified] R)
   4.526  qed
   4.527  
   4.528  lemma (in UP_domain) deg_smult_ring:
   4.529    "[| a \<in> carrier R; p \<in> carrier P |] ==>
   4.530 -  deg R (a \<odot>\<^sub>2 p) <= (if a = \<zero> then 0 else deg R p)"
   4.531 +  deg R (a \<odot>\<^bsub>P\<^esub> p) <= (if a = \<zero> then 0 else deg R p)"
   4.532    by (cases "a = \<zero>") (simp add: deg_aboveI deg_aboveD)+
   4.533  
   4.534  lemma (in UP_domain) deg_smult [simp]:
   4.535    assumes R: "a \<in> carrier R" "p \<in> carrier P"
   4.536 -  shows "deg R (a \<odot>\<^sub>2 p) = (if a = \<zero> then 0 else deg R p)"
   4.537 +  shows "deg R (a \<odot>\<^bsub>P\<^esub> p) = (if a = \<zero> then 0 else deg R p)"
   4.538  proof (rule le_anti_sym)
   4.539 -  show "deg R (a \<odot>\<^sub>2 p) <= (if a = \<zero> then 0 else deg R p)"
   4.540 +  show "deg R (a \<odot>\<^bsub>P\<^esub> p) <= (if a = \<zero> then 0 else deg R p)"
   4.541      by (rule deg_smult_ring)
   4.542  next
   4.543 -  show "(if a = \<zero> then 0 else deg R p) <= deg R (a \<odot>\<^sub>2 p)"
   4.544 +  show "(if a = \<zero> then 0 else deg R p) <= deg R (a \<odot>\<^bsub>P\<^esub> p)"
   4.545    proof (cases "a = \<zero>")
   4.546    qed (simp, simp add: deg_belowI lcoeff_nonzero_deg integral_iff R)
   4.547  qed
   4.548  
   4.549  lemma (in UP_cring) deg_mult_cring:
   4.550    assumes R: "p \<in> carrier P" "q \<in> carrier P"
   4.551 -  shows "deg R (p \<otimes>\<^sub>2 q) <= deg R p + deg R q"
   4.552 +  shows "deg R (p \<otimes>\<^bsub>P\<^esub> q) <= deg R p + deg R q"
   4.553  proof (rule deg_aboveI)
   4.554    fix m
   4.555    assume boundm: "deg R p + deg R q < m"
   4.556 @@ -956,7 +967,7 @@
   4.557        then show ?thesis by (simp add: deg_aboveD R)
   4.558      qed
   4.559    }
   4.560 -  with boundm R show "coeff P (p \<otimes>\<^sub>2 q) m = \<zero>" by simp
   4.561 +  with boundm R show "coeff P (p \<otimes>\<^bsub>P\<^esub> q) m = \<zero>" by simp
   4.562  qed (simp add: R)
   4.563  
   4.564  ML_setup {*
   4.565 @@ -964,31 +975,31 @@
   4.566  *}
   4.567  
   4.568  lemma (in UP_domain) deg_mult [simp]:
   4.569 -  "[| p ~= \<zero>\<^sub>2; q ~= \<zero>\<^sub>2; p \<in> carrier P; q \<in> carrier P |] ==>
   4.570 -  deg R (p \<otimes>\<^sub>2 q) = deg R p + deg R q"
   4.571 +  "[| p ~= \<zero>\<^bsub>P\<^esub>; q ~= \<zero>\<^bsub>P\<^esub>; p \<in> carrier P; q \<in> carrier P |] ==>
   4.572 +  deg R (p \<otimes>\<^bsub>P\<^esub> q) = deg R p + deg R q"
   4.573  proof (rule le_anti_sym)
   4.574    assume "p \<in> carrier P" " q \<in> carrier P"
   4.575 -  show "deg R (p \<otimes>\<^sub>2 q) <= deg R p + deg R q" by (rule deg_mult_cring)
   4.576 +  show "deg R (p \<otimes>\<^bsub>P\<^esub> q) <= deg R p + deg R q" by (rule deg_mult_cring)
   4.577  next
   4.578    let ?s = "(%i. coeff P p i \<otimes> coeff P q (deg R p + deg R q - i))"
   4.579 -  assume R: "p \<in> carrier P" "q \<in> carrier P" and nz: "p ~= \<zero>\<^sub>2" "q ~= \<zero>\<^sub>2"
   4.580 +  assume R: "p \<in> carrier P" "q \<in> carrier P" and nz: "p ~= \<zero>\<^bsub>P\<^esub>" "q ~= \<zero>\<^bsub>P\<^esub>"
   4.581    have less_add_diff: "!!(k::nat) n m. k < n ==> m < n + m - k" by arith
   4.582 -  show "deg R p + deg R q <= deg R (p \<otimes>\<^sub>2 q)"
   4.583 +  show "deg R p + deg R q <= deg R (p \<otimes>\<^bsub>P\<^esub> q)"
   4.584    proof (rule deg_belowI, simp add: R)
   4.585 -    have "finsum R ?s {.. deg R p + deg R q}
   4.586 -      = finsum R ?s ({..< deg R p} Un {deg R p .. deg R p + deg R q})"
   4.587 +    have "(\<Oplus>i \<in> {.. deg R p + deg R q}. ?s i)
   4.588 +      = (\<Oplus>i \<in> {..< deg R p} \<union> {deg R p .. deg R p + deg R q}. ?s i)"
   4.589        by (simp only: ivl_disj_un_one)
   4.590 -    also have "... = finsum R ?s {deg R p .. deg R p + deg R q}"
   4.591 +    also have "... = (\<Oplus>i \<in> {deg R p .. deg R p + deg R q}. ?s i)"
   4.592        by (simp cong: finsum_cong add: finsum_Un_disjoint ivl_disj_int_one
   4.593          deg_aboveD less_add_diff R Pi_def)
   4.594 -    also have "...= finsum R ?s ({deg R p} Un {deg R p <.. deg R p + deg R q})"
   4.595 +    also have "...= (\<Oplus>i \<in> {deg R p} \<union> {deg R p <.. deg R p + deg R q}. ?s i)"
   4.596        by (simp only: ivl_disj_un_singleton)
   4.597      also have "... = coeff P p (deg R p) \<otimes> coeff P q (deg R q)"
   4.598        by (simp cong: finsum_cong add: finsum_Un_disjoint
   4.599          ivl_disj_int_singleton deg_aboveD R Pi_def)
   4.600 -    finally have "finsum R ?s {.. deg R p + deg R q}
   4.601 +    finally have "(\<Oplus>i \<in> {.. deg R p + deg R q}. ?s i)
   4.602        = coeff P p (deg R p) \<otimes> coeff P q (deg R q)" .
   4.603 -    with nz show "finsum R ?s {.. deg R p + deg R q} ~= \<zero>"
   4.604 +    with nz show "(\<Oplus>i \<in> {.. deg R p + deg R q}. ?s i) ~= \<zero>"
   4.605        by (simp add: integral_iff lcoeff_nonzero R)
   4.606      qed (simp add: R)
   4.607    qed
   4.608 @@ -996,7 +1007,7 @@
   4.609  lemma (in UP_cring) coeff_finsum:
   4.610    assumes fin: "finite A"
   4.611    shows "p \<in> A -> carrier P ==>
   4.612 -    coeff P (finsum P p A) k == finsum R (%i. coeff P (p i) k) A"
   4.613 +    coeff P (finsum P p A) k = (\<Oplus>i \<in> A. coeff P (p i) k)"
   4.614    using fin by induct (auto simp: Pi_def)
   4.615  
   4.616  ML_setup {*
   4.617 @@ -1005,24 +1016,24 @@
   4.618  
   4.619  lemma (in UP_cring) up_repr:
   4.620    assumes R: "p \<in> carrier P"
   4.621 -  shows "(\<Oplus>\<^sub>2 i \<in> {..deg R p}. monom P (coeff P p i) i) = p"
   4.622 +  shows "(\<Oplus>\<^bsub>P\<^esub> i \<in> {..deg R p}. monom P (coeff P p i) i) = p"
   4.623  proof (rule up_eqI)
   4.624    let ?s = "(%i. monom P (coeff P p i) i)"
   4.625    fix k
   4.626    from R have RR: "!!i. (if i = k then coeff P p i else \<zero>) \<in> carrier R"
   4.627      by simp
   4.628 -  show "coeff P (finsum P ?s {..deg R p}) k = coeff P p k"
   4.629 +  show "coeff P (\<Oplus>\<^bsub>P\<^esub> i \<in> {..deg R p}. ?s i) k = coeff P p k"
   4.630    proof (cases "k <= deg R p")
   4.631      case True
   4.632 -    hence "coeff P (finsum P ?s {..deg R p}) k =
   4.633 -          coeff P (finsum P ?s ({..k} Un {k<..deg R p})) k"
   4.634 +    hence "coeff P (\<Oplus>\<^bsub>P\<^esub> i \<in> {..deg R p}. ?s i) k =
   4.635 +          coeff P (\<Oplus>\<^bsub>P\<^esub> i \<in> {..k} \<union> {k<..deg R p}. ?s i) k"
   4.636        by (simp only: ivl_disj_un_one)
   4.637      also from True
   4.638 -    have "... = coeff P (finsum P ?s {..k}) k"
   4.639 +    have "... = coeff P (\<Oplus>\<^bsub>P\<^esub> i \<in> {..k}. ?s i) k"
   4.640        by (simp cong: finsum_cong add: finsum_Un_disjoint
   4.641          ivl_disj_int_one order_less_imp_not_eq2 coeff_finsum R RR Pi_def)
   4.642      also
   4.643 -    have "... = coeff P (finsum P ?s ({..<k} Un {k})) k"
   4.644 +    have "... = coeff P (\<Oplus>\<^bsub>P\<^esub> i \<in> {..<k} \<union> {k}. ?s i) k"
   4.645        by (simp only: ivl_disj_un_singleton)
   4.646      also have "... = coeff P p k"
   4.647        by (simp cong: finsum_cong add: setsum_Un_disjoint
   4.648 @@ -1030,8 +1041,8 @@
   4.649      finally show ?thesis .
   4.650    next
   4.651      case False
   4.652 -    hence "coeff P (finsum P ?s {..deg R p}) k =
   4.653 -          coeff P (finsum P ?s ({..<deg R p} Un {deg R p})) k"
   4.654 +    hence "coeff P (\<Oplus>\<^bsub>P\<^esub> i \<in> {..deg R p}. ?s i) k =
   4.655 +          coeff P (\<Oplus>\<^bsub>P\<^esub> i \<in> {..<deg R p} \<union> {deg R p}. ?s i) k"
   4.656        by (simp only: ivl_disj_un_singleton)
   4.657      also from False have "... = coeff P p k"
   4.658        by (simp cong: finsum_cong add: setsum_Un_disjoint ivl_disj_int_singleton
   4.659 @@ -1042,11 +1053,11 @@
   4.660  
   4.661  lemma (in UP_cring) up_repr_le:
   4.662    "[| deg R p <= n; p \<in> carrier P |] ==>
   4.663 -  finsum P (%i. monom P (coeff P p i) i) {..n} = p"
   4.664 +  (\<Oplus>\<^bsub>P\<^esub> i \<in> {..n}. monom P (coeff P p i) i) = p"
   4.665  proof -
   4.666    let ?s = "(%i. monom P (coeff P p i) i)"
   4.667    assume R: "p \<in> carrier P" and "deg R p <= n"
   4.668 -  then have "finsum P ?s {..n} = finsum P ?s ({..deg R p} Un {deg R p<..n})"
   4.669 +  then have "finsum P ?s {..n} = finsum P ?s ({..deg R p} \<union> {deg R p<..n})"
   4.670      by (simp only: ivl_disj_un_one)
   4.671    also have "... = finsum P ?s {..deg R p}"
   4.672      by (simp cong: UP_finsum_cong add: UP_finsum_Un_disjoint ivl_disj_int_one
   4.673 @@ -1071,40 +1082,40 @@
   4.674      del: disjCI)
   4.675  
   4.676  lemma (in UP_domain) UP_one_not_zero:
   4.677 -  "\<one>\<^sub>2 ~= \<zero>\<^sub>2"
   4.678 +  "\<one>\<^bsub>P\<^esub> ~= \<zero>\<^bsub>P\<^esub>"
   4.679  proof
   4.680 -  assume "\<one>\<^sub>2 = \<zero>\<^sub>2"
   4.681 -  hence "coeff P \<one>\<^sub>2 0 = (coeff P \<zero>\<^sub>2 0)" by simp
   4.682 +  assume "\<one>\<^bsub>P\<^esub> = \<zero>\<^bsub>P\<^esub>"
   4.683 +  hence "coeff P \<one>\<^bsub>P\<^esub> 0 = (coeff P \<zero>\<^bsub>P\<^esub> 0)" by simp
   4.684    hence "\<one> = \<zero>" by simp
   4.685    with one_not_zero show "False" by contradiction
   4.686  qed
   4.687  
   4.688  lemma (in UP_domain) UP_integral:
   4.689 -  "[| p \<otimes>\<^sub>2 q = \<zero>\<^sub>2; p \<in> carrier P; q \<in> carrier P |] ==> p = \<zero>\<^sub>2 | q = \<zero>\<^sub>2"
   4.690 +  "[| p \<otimes>\<^bsub>P\<^esub> q = \<zero>\<^bsub>P\<^esub>; p \<in> carrier P; q \<in> carrier P |] ==> p = \<zero>\<^bsub>P\<^esub> | q = \<zero>\<^bsub>P\<^esub>"
   4.691  proof -
   4.692    fix p q
   4.693 -  assume pq: "p \<otimes>\<^sub>2 q = \<zero>\<^sub>2" and R: "p \<in> carrier P" "q \<in> carrier P"
   4.694 -  show "p = \<zero>\<^sub>2 | q = \<zero>\<^sub>2"
   4.695 +  assume pq: "p \<otimes>\<^bsub>P\<^esub> q = \<zero>\<^bsub>P\<^esub>" and R: "p \<in> carrier P" "q \<in> carrier P"
   4.696 +  show "p = \<zero>\<^bsub>P\<^esub> | q = \<zero>\<^bsub>P\<^esub>"
   4.697    proof (rule classical)
   4.698 -    assume c: "~ (p = \<zero>\<^sub>2 | q = \<zero>\<^sub>2)"
   4.699 -    with R have "deg R p + deg R q = deg R (p \<otimes>\<^sub>2 q)" by simp
   4.700 +    assume c: "~ (p = \<zero>\<^bsub>P\<^esub> | q = \<zero>\<^bsub>P\<^esub>)"
   4.701 +    with R have "deg R p + deg R q = deg R (p \<otimes>\<^bsub>P\<^esub> q)" by simp
   4.702      also from pq have "... = 0" by simp
   4.703      finally have "deg R p + deg R q = 0" .
   4.704      then have f1: "deg R p = 0 & deg R q = 0" by simp
   4.705 -    from f1 R have "p = (\<Oplus>\<^sub>2 i \<in> {..0}. monom P (coeff P p i) i)"
   4.706 +    from f1 R have "p = (\<Oplus>\<^bsub>P\<^esub> i \<in> {..0}. monom P (coeff P p i) i)"
   4.707        by (simp only: up_repr_le)
   4.708      also from R have "... = monom P (coeff P p 0) 0" by simp
   4.709      finally have p: "p = monom P (coeff P p 0) 0" .
   4.710 -    from f1 R have "q = (\<Oplus>\<^sub>2 i \<in> {..0}. monom P (coeff P q i) i)"
   4.711 +    from f1 R have "q = (\<Oplus>\<^bsub>P\<^esub> i \<in> {..0}. monom P (coeff P q i) i)"
   4.712        by (simp only: up_repr_le)
   4.713      also from R have "... = monom P (coeff P q 0) 0" by simp
   4.714      finally have q: "q = monom P (coeff P q 0) 0" .
   4.715 -    from R have "coeff P p 0 \<otimes> coeff P q 0 = coeff P (p \<otimes>\<^sub>2 q) 0" by simp
   4.716 +    from R have "coeff P p 0 \<otimes> coeff P q 0 = coeff P (p \<otimes>\<^bsub>P\<^esub> q) 0" by simp
   4.717      also from pq have "... = \<zero>" by simp
   4.718      finally have "coeff P p 0 \<otimes> coeff P q 0 = \<zero>" .
   4.719      with R have "coeff P p 0 = \<zero> | coeff P q 0 = \<zero>"
   4.720        by (simp add: R.integral_iff)
   4.721 -    with p q show "p = \<zero>\<^sub>2 | q = \<zero>\<^sub>2" by fastsimp
   4.722 +    with p q show "p = \<zero>\<^bsub>P\<^esub> | q = \<zero>\<^bsub>P\<^esub>" by fastsimp
   4.723    qed
   4.724  qed
   4.725  
   4.726 @@ -1113,9 +1124,11 @@
   4.727    by (auto intro!: domainI UP_cring UP_one_not_zero UP_integral del: disjCI)
   4.728  
   4.729  text {*
   4.730 -  Instantiation of results from @{term domain}.
   4.731 +  Instantiation of theorems from @{term domain}.
   4.732  *}
   4.733  
   4.734 +(* TODO: this should be automated with an instantiation command. *)
   4.735 +
   4.736  lemmas (in UP_domain) UP_zero_not_one [simp] =
   4.737    domain.zero_not_one [OF UP_domain]
   4.738  
   4.739 @@ -1129,7 +1142,7 @@
   4.740    domain.m_rcancel [OF UP_domain]
   4.741  
   4.742  lemma (in UP_domain) smult_integral:
   4.743 -  "[| a \<odot>\<^sub>2 p = \<zero>\<^sub>2; a \<in> carrier R; p \<in> carrier P |] ==> a = \<zero> | p = \<zero>\<^sub>2"
   4.744 +  "[| a \<odot>\<^bsub>P\<^esub> p = \<zero>\<^bsub>P\<^esub>; a \<in> carrier R; p \<in> carrier P |] ==> a = \<zero> | p = \<zero>\<^bsub>P\<^esub>"
   4.745    by (simp add: monom_mult_is_smult [THEN sym] UP_integral_iff
   4.746      inj_on_iff [OF monom_inj, of _ "\<zero>", simplified])
   4.747  
   4.748 @@ -1161,8 +1174,6 @@
   4.749        case 0 from Rf Rg show ?case by (simp add: Pi_def)
   4.750      next
   4.751        case (Suc j)
   4.752 -      (* The following could be simplified if there was a reasoner for
   4.753 -        total orders integrated with simp. *)
   4.754        have R6: "!!i k. [| k <= j; i <= Suc j - k |] ==> g i \<in> carrier R"
   4.755          using Suc by (auto intro!: funcset_mem [OF Rg]) arith
   4.756        have R8: "!!i k. [| k <= Suc j; i <= k |] ==> g (k - i) \<in> carrier R"
   4.757 @@ -1189,7 +1200,7 @@
   4.758    assumes bf: "bound \<zero> n f" and bg: "bound \<zero> m g"
   4.759      and Rf: "f \<in> {..n} -> carrier R" and Rg: "g \<in> {..m} -> carrier R"
   4.760    shows "(\<Oplus>k \<in> {..n + m}. \<Oplus>i \<in> {..k}. f i \<otimes> g (k - i)) =
   4.761 -    (\<Oplus>i \<in> {..n}. f i) \<otimes> (\<Oplus>i \<in> {..m}. g i)"        (* State revese direction? *)
   4.762 +    (\<Oplus>i \<in> {..n}. f i) \<otimes> (\<Oplus>i \<in> {..m}. g i)"       (* State revese direction? *)
   4.763  proof -
   4.764    have f: "!!x. f x \<in> carrier R"
   4.765    proof -
   4.766 @@ -1211,7 +1222,8 @@
   4.767    also from f g have "... = (\<Oplus>k \<in> {..n}. \<Oplus>i \<in> {..n + m - k}. f k \<otimes> g i)"
   4.768      by (simp cong: finsum_cong
   4.769        add: bound.bound [OF bf] finsum_Un_disjoint ivl_disj_int_one Pi_def)
   4.770 -  also from f g have "... = (\<Oplus>k \<in> {..n}. \<Oplus>i \<in> {..m} \<union> {m<..n + m - k}. f k \<otimes> g i)"
   4.771 +  also from f g
   4.772 +  have "... = (\<Oplus>k \<in> {..n}. \<Oplus>i \<in> {..m} \<union> {m<..n + m - k}. f k \<otimes> g i)"
   4.773      by (simp cong: finsum_cong add: ivl_disj_un_one le_add_diff Pi_def)
   4.774    also from f g have "... = (\<Oplus>k \<in> {..n}. \<Oplus>i \<in> {..m}. f k \<otimes> g i)"
   4.775      by (simp cong: finsum_cong
   4.776 @@ -1227,28 +1239,25 @@
   4.777    by (auto intro!: ring_hom_memI intro: up_eqI simp: monom_mult_is_smult)
   4.778  
   4.779  constdefs (structure S)
   4.780 -  eval :: "[_, _, 'a => 'b, 'b, nat => 'a] => 'b"
   4.781 +  eval :: "[('a, 'm) ring_scheme, ('b, 'n) ring_scheme,
   4.782 +           'a => 'b, 'b, nat => 'a] => 'b"
   4.783    "eval R S phi s == \<lambda>p \<in> carrier (UP R).
   4.784 -    \<Oplus>i \<in> {..deg R p}. phi (coeff (UP R) p i) \<otimes> pow S s i"
   4.785 -(*
   4.786 -  "eval R S phi s p == if p \<in> carrier (UP R)
   4.787 -  then finsum S (%i. mult S (phi (coeff (UP R) p i)) (pow S s i)) {..deg R p}
   4.788 -  else arbitrary"
   4.789 -*)
   4.790 +    \<Oplus>i \<in> {..deg R p}. phi (coeff (UP R) p i) \<otimes> s (^) i"
   4.791 +
   4.792 +locale UP_univ_prop = ring_hom_cring R S + UP_cring R
   4.793  
   4.794 -locale ring_hom_UP_cring = ring_hom_cring R S + UP_cring R
   4.795 -
   4.796 -lemma (in ring_hom_UP_cring) eval_on_carrier:
   4.797 -  "p \<in> carrier P ==>
   4.798 +lemma (in UP) eval_on_carrier:
   4.799 +  includes struct S
   4.800 +  shows  "p \<in> carrier P ==>
   4.801      eval R S phi s p =
   4.802 -    (\<Oplus>\<^sub>2 i \<in> {..deg R p}. phi (coeff P p i) \<otimes>\<^sub>2 pow S s i)"
   4.803 +    (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R p}. phi (coeff P p i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.804    by (unfold eval_def, fold P_def) simp
   4.805  
   4.806 -lemma (in ring_hom_UP_cring) eval_extensional:
   4.807 +lemma (in UP) eval_extensional:
   4.808    "eval R S phi s \<in> extensional (carrier P)"
   4.809    by (unfold eval_def, fold P_def) simp
   4.810  
   4.811 -theorem (in ring_hom_UP_cring) eval_ring_hom:
   4.812 +theorem (in UP_univ_prop) eval_ring_hom:
   4.813    "s \<in> carrier S ==> eval R S h s \<in> ring_hom P S"
   4.814  proof (rule ring_hom_memI)
   4.815    fix p
   4.816 @@ -1258,126 +1267,132 @@
   4.817  next
   4.818    fix p q
   4.819    assume RS: "p \<in> carrier P" "q \<in> carrier P" "s \<in> carrier S"
   4.820 -  then show "eval R S h s (p \<otimes>\<^sub>3 q) = eval R S h s p \<otimes>\<^sub>2 eval R S h s q"
   4.821 +  then show "eval R S h s (p \<otimes>\<^bsub>P\<^esub> q) = eval R S h s p \<otimes>\<^bsub>S\<^esub> eval R S h s q"
   4.822    proof (simp only: eval_on_carrier UP_mult_closed)
   4.823      from RS have
   4.824 -      "(\<Oplus>\<^sub>2 i \<in> {..deg R (p \<otimes>\<^sub>3 q)}. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) =
   4.825 -      (\<Oplus>\<^sub>2 i \<in> {..deg R (p \<otimes>\<^sub>3 q)} \<union> {deg R (p \<otimes>\<^sub>3 q)<..deg R p + deg R q}.
   4.826 -        h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.827 +      "(\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R (p \<otimes>\<^bsub>P\<^esub> q)}. h (coeff P (p \<otimes>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) =
   4.828 +      (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R (p \<otimes>\<^bsub>P\<^esub> q)} \<union> {deg R (p \<otimes>\<^bsub>P\<^esub> q)<..deg R p + deg R q}.
   4.829 +        h (coeff P (p \<otimes>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.830        by (simp cong: finsum_cong
   4.831          add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def
   4.832          del: coeff_mult)
   4.833      also from RS have "... =
   4.834 -      (\<Oplus>\<^sub>2 i \<in> {..deg R p + deg R q}. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.835 +      (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R p + deg R q}. h (coeff P (p \<otimes>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.836        by (simp only: ivl_disj_un_one deg_mult_cring)
   4.837      also from RS have "... =
   4.838 -      (\<Oplus>\<^sub>2 i \<in> {..deg R p + deg R q}.
   4.839 -       \<Oplus>\<^sub>2 k \<in> {..i}. h (coeff P p k) \<otimes>\<^sub>2 h (coeff P q (i - k)) \<otimes>\<^sub>2 (s (^)\<^sub>2 k \<otimes>\<^sub>2 s (^)\<^sub>2 (i - k)))"
   4.840 +      (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R p + deg R q}.
   4.841 +         \<Oplus>\<^bsub>S\<^esub> k \<in> {..i}.
   4.842 +           h (coeff P p k) \<otimes>\<^bsub>S\<^esub> h (coeff P q (i - k)) \<otimes>\<^bsub>S\<^esub>
   4.843 +           (s (^)\<^bsub>S\<^esub> k \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> (i - k)))"
   4.844        by (simp cong: finsum_cong add: nat_pow_mult Pi_def
   4.845          S.m_ac S.finsum_rdistr)
   4.846      also from RS have "... =
   4.847 -      (\<Oplus>\<^sub>2i\<in>{..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<otimes>\<^sub>2
   4.848 -      (\<Oplus>\<^sub>2i\<in>{..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.849 +      (\<Oplus>\<^bsub>S\<^esub> i\<in>{..deg R p}. h (coeff P p i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) \<otimes>\<^bsub>S\<^esub>
   4.850 +      (\<Oplus>\<^bsub>S\<^esub> i\<in>{..deg R q}. h (coeff P q i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.851        by (simp add: S.cauchy_product [THEN sym] bound.intro deg_aboveD S.m_ac
   4.852          Pi_def)
   4.853      finally show
   4.854 -      "(\<Oplus>\<^sub>2 i \<in> {..deg R (p \<otimes>\<^sub>3 q)}. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) =
   4.855 -      (\<Oplus>\<^sub>2 i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<otimes>\<^sub>2
   4.856 -      (\<Oplus>\<^sub>2 i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" .
   4.857 +      "(\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R (p \<otimes>\<^bsub>P\<^esub> q)}. h (coeff P (p \<otimes>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) =
   4.858 +      (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) \<otimes>\<^bsub>S\<^esub>
   4.859 +      (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)" .
   4.860    qed
   4.861  next
   4.862    fix p q
   4.863    assume RS: "p \<in> carrier P" "q \<in> carrier P" "s \<in> carrier S"
   4.864 -  then show "eval R S h s (p \<oplus>\<^sub>3 q) = eval R S h s p \<oplus>\<^sub>2 eval R S h s q"
   4.865 +  then show "eval R S h s (p \<oplus>\<^bsub>P\<^esub> q) = eval R S h s p \<oplus>\<^bsub>S\<^esub> eval R S h s q"
   4.866    proof (simp only: eval_on_carrier UP_a_closed)
   4.867      from RS have
   4.868 -      "(\<Oplus>\<^sub>2i \<in> {..deg R (p \<oplus>\<^sub>3 q)}. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) =
   4.869 -      (\<Oplus>\<^sub>2i \<in> {..deg R (p \<oplus>\<^sub>3 q)} \<union> {deg R (p \<oplus>\<^sub>3 q)<..max (deg R p) (deg R q)}.
   4.870 -        h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.871 +      "(\<Oplus>\<^bsub>S \<^esub>i\<in>{..deg R (p \<oplus>\<^bsub>P\<^esub> q)}. h (coeff P (p \<oplus>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) =
   4.872 +      (\<Oplus>\<^bsub>S \<^esub>i\<in>{..deg R (p \<oplus>\<^bsub>P\<^esub> q)} \<union> {deg R (p \<oplus>\<^bsub>P\<^esub> q)<..max (deg R p) (deg R q)}.
   4.873 +        h (coeff P (p \<oplus>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.874        by (simp cong: finsum_cong
   4.875          add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def
   4.876          del: coeff_add)
   4.877      also from RS have "... =
   4.878 -        (\<Oplus>\<^sub>2 i \<in> {..max (deg R p) (deg R q)}. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.879 +        (\<Oplus>\<^bsub>S\<^esub> i \<in> {..max (deg R p) (deg R q)}.
   4.880 +          h (coeff P (p \<oplus>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.881        by (simp add: ivl_disj_un_one)
   4.882      also from RS have "... =
   4.883 -      (\<Oplus>\<^sub>2i\<in>{..max (deg R p) (deg R q)}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2
   4.884 -      (\<Oplus>\<^sub>2i\<in>{..max (deg R p) (deg R q)}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.885 +      (\<Oplus>\<^bsub>S\<^esub>i\<in>{..max (deg R p) (deg R q)}. h (coeff P p i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) \<oplus>\<^bsub>S\<^esub>
   4.886 +      (\<Oplus>\<^bsub>S\<^esub>i\<in>{..max (deg R p) (deg R q)}. h (coeff P q i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.887        by (simp cong: finsum_cong
   4.888          add: l_distr deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def)
   4.889      also have "... =
   4.890 -        (\<Oplus>\<^sub>2 i \<in> {..deg R p} \<union> {deg R p<..max (deg R p) (deg R q)}.
   4.891 -          h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2
   4.892 -        (\<Oplus>\<^sub>2 i \<in> {..deg R q} \<union> {deg R q<..max (deg R p) (deg R q)}.
   4.893 -          h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.894 +        (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R p} \<union> {deg R p<..max (deg R p) (deg R q)}.
   4.895 +          h (coeff P p i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) \<oplus>\<^bsub>S\<^esub>
   4.896 +        (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R q} \<union> {deg R q<..max (deg R p) (deg R q)}.
   4.897 +          h (coeff P q i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.898        by (simp only: ivl_disj_un_one le_maxI1 le_maxI2)
   4.899      also from RS have "... =
   4.900 -      (\<Oplus>\<^sub>2 i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2
   4.901 -      (\<Oplus>\<^sub>2 i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.902 +      (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) \<oplus>\<^bsub>S\<^esub>
   4.903 +      (\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
   4.904        by (simp cong: finsum_cong
   4.905          add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def)
   4.906      finally show
   4.907 -      "(\<Oplus>\<^sub>2i \<in> {..deg R (p \<oplus>\<^sub>3 q)}. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) =
   4.908 -      (\<Oplus>\<^sub>2i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2
   4.909 -      (\<Oplus>\<^sub>2i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
   4.910 -      .
   4.911 +      "(\<Oplus>\<^bsub>S\<^esub>i \<in> {..deg R (p \<oplus>\<^bsub>P\<^esub> q)}. h (coeff P (p \<oplus>\<^bsub>P\<^esub> q) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) =
   4.912 +      (\<Oplus>\<^bsub>S\<^esub>i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) \<oplus>\<^bsub>S\<^esub>
   4.913 +      (\<Oplus>\<^bsub>S\<^esub>i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)" .
   4.914    qed
   4.915  next
   4.916    assume S: "s \<in> carrier S"
   4.917 -  then show "eval R S h s \<one>\<^sub>3 = \<one>\<^sub>2"
   4.918 +  then show "eval R S h s \<one>\<^bsub>P\<^esub> = \<one>\<^bsub>S\<^esub>"
   4.919      by (simp only: eval_on_carrier UP_one_closed) simp
   4.920  qed
   4.921  
   4.922  text {* Instantiation of ring homomorphism lemmas. *}
   4.923  
   4.924 -lemma (in ring_hom_UP_cring) ring_hom_cring_P_S:
   4.925 +(* TODO: again, automate with instantiation command *)
   4.926 +
   4.927 +lemma (in UP_univ_prop) ring_hom_cring_P_S:
   4.928    "s \<in> carrier S ==> ring_hom_cring P S (eval R S h s)"
   4.929    by (fast intro!: ring_hom_cring.intro UP_cring cring.axioms prems
   4.930 -  intro: ring_hom_cring_axioms.intro eval_ring_hom)
   4.931 +    intro: ring_hom_cring_axioms.intro eval_ring_hom)
   4.932  
   4.933 -lemma (in ring_hom_UP_cring) UP_hom_closed [intro, simp]:
   4.934 +(*
   4.935 +lemma (in UP_univ_prop) UP_hom_closed [intro, simp]:
   4.936    "[| s \<in> carrier S; p \<in> carrier P |] ==> eval R S h s p \<in> carrier S"
   4.937    by (rule ring_hom_cring.hom_closed [OF ring_hom_cring_P_S])
   4.938  
   4.939 -lemma (in ring_hom_UP_cring) UP_hom_mult [simp]:
   4.940 +lemma (in UP_univ_prop) UP_hom_mult [simp]:
   4.941    "[| s \<in> carrier S; p \<in> carrier P; q \<in> carrier P |] ==>
   4.942 -  eval R S h s (p \<otimes>\<^sub>3 q) = eval R S h s p \<otimes>\<^sub>2 eval R S h s q"
   4.943 +  eval R S h s (p \<otimes>\<^bsub>P\<^esub> q) = eval R S h s p \<otimes>\<^bsub>S\<^esub> eval R S h s q"
   4.944    by (rule ring_hom_cring.hom_mult [OF ring_hom_cring_P_S])
   4.945  
   4.946 -lemma (in ring_hom_UP_cring) UP_hom_add [simp]:
   4.947 +lemma (in UP_univ_prop) UP_hom_add [simp]:
   4.948    "[| s \<in> carrier S; p \<in> carrier P; q \<in> carrier P |] ==>
   4.949 -  eval R S h s (p \<oplus>\<^sub>3 q) = eval R S h s p \<oplus>\<^sub>2 eval R S h s q"
   4.950 +  eval R S h s (p \<oplus>\<^bsub>P\<^esub> q) = eval R S h s p \<oplus>\<^bsub>S\<^esub> eval R S h s q"
   4.951    by (rule ring_hom_cring.hom_add [OF ring_hom_cring_P_S])
   4.952  
   4.953 -lemma (in ring_hom_UP_cring) UP_hom_one [simp]:
   4.954 -  "s \<in> carrier S ==> eval R S h s \<one>\<^sub>3 = \<one>\<^sub>2"
   4.955 +lemma (in UP_univ_prop) UP_hom_one [simp]:
   4.956 +  "s \<in> carrier S ==> eval R S h s \<one>\<^bsub>P\<^esub> = \<one>\<^bsub>S\<^esub>"
   4.957    by (rule ring_hom_cring.hom_one [OF ring_hom_cring_P_S])
   4.958  
   4.959 -lemma (in ring_hom_UP_cring) UP_hom_zero [simp]:
   4.960 -  "s \<in> carrier S ==> eval R S h s \<zero>\<^sub>3 = \<zero>\<^sub>2"
   4.961 +lemma (in UP_univ_prop) UP_hom_zero [simp]:
   4.962 +  "s \<in> carrier S ==> eval R S h s \<zero>\<^bsub>P\<^esub> = \<zero>\<^bsub>S\<^esub>"
   4.963    by (rule ring_hom_cring.hom_zero [OF ring_hom_cring_P_S])
   4.964  
   4.965 -lemma (in ring_hom_UP_cring) UP_hom_a_inv [simp]:
   4.966 +lemma (in UP_univ_prop) UP_hom_a_inv [simp]:
   4.967    "[| s \<in> carrier S; p \<in> carrier P |] ==>
   4.968 -  (eval R S h s) (\<ominus>\<^sub>3 p) = \<ominus>\<^sub>2 (eval R S h s) p"
   4.969 +  (eval R S h s) (\<ominus>\<^bsub>P\<^esub> p) = \<ominus>\<^bsub>S\<^esub> (eval R S h s) p"
   4.970    by (rule ring_hom_cring.hom_a_inv [OF ring_hom_cring_P_S])
   4.971  
   4.972 -lemma (in ring_hom_UP_cring) UP_hom_finsum [simp]:
   4.973 +lemma (in UP_univ_prop) UP_hom_finsum [simp]:
   4.974    "[| s \<in> carrier S; finite A; f \<in> A -> carrier P |] ==>
   4.975    (eval R S h s) (finsum P f A) = finsum S (eval R S h s o f) A"
   4.976    by (rule ring_hom_cring.hom_finsum [OF ring_hom_cring_P_S])
   4.977  
   4.978 -lemma (in ring_hom_UP_cring) UP_hom_finprod [simp]:
   4.979 +lemma (in UP_univ_prop) UP_hom_finprod [simp]:
   4.980    "[| s \<in> carrier S; finite A; f \<in> A -> carrier P |] ==>
   4.981    (eval R S h s) (finprod P f A) = finprod S (eval R S h s o f) A"
   4.982    by (rule ring_hom_cring.hom_finprod [OF ring_hom_cring_P_S])
   4.983 +*)
   4.984  
   4.985  text {* Further properties of the evaluation homomorphism. *}
   4.986  
   4.987  (* The following lemma could be proved in UP\_cring with the additional
   4.988     assumption that h is closed. *)
   4.989  
   4.990 -lemma (in ring_hom_UP_cring) eval_const:
   4.991 +lemma (in UP_univ_prop) eval_const:
   4.992    "[| s \<in> carrier S; r \<in> carrier R |] ==> eval R S h s (monom P r 0) = h r"
   4.993    by (simp only: eval_on_carrier monom_closed) simp
   4.994  
   4.995 @@ -1386,32 +1401,32 @@
   4.996  
   4.997  (* TODO: simplify by cases "one R = zero R" *)
   4.998  
   4.999 -lemma (in ring_hom_UP_cring) eval_monom1:
  4.1000 +lemma (in UP_univ_prop) eval_monom1:
  4.1001    "s \<in> carrier S ==> eval R S h s (monom P \<one> 1) = s"
  4.1002  proof (simp only: eval_on_carrier monom_closed R.one_closed)
  4.1003    assume S: "s \<in> carrier S"
  4.1004    then have
  4.1005 -    "(\<Oplus>\<^sub>2 i \<in> {..deg R (monom P \<one> 1)}. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) =
  4.1006 -    (\<Oplus>\<^sub>2i\<in>{..deg R (monom P \<one> 1)} \<union> {deg R (monom P \<one> 1)<..1}.
  4.1007 -      h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
  4.1008 +    "(\<Oplus>\<^bsub>S\<^esub> i\<in>{..deg R (monom P \<one> 1)}. h (coeff P (monom P \<one> 1) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) =
  4.1009 +    (\<Oplus>\<^bsub>S\<^esub> i\<in>{..deg R (monom P \<one> 1)} \<union> {deg R (monom P \<one> 1)<..1}.
  4.1010 +      h (coeff P (monom P \<one> 1) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
  4.1011      by (simp cong: finsum_cong del: coeff_monom
  4.1012        add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def)
  4.1013    also have "... =
  4.1014 -    (\<Oplus>\<^sub>2 i \<in> {..1}. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)"
  4.1015 +    (\<Oplus>\<^bsub>S\<^esub> i \<in> {..1}. h (coeff P (monom P \<one> 1) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i)"
  4.1016      by (simp only: ivl_disj_un_one deg_monom_le R.one_closed)
  4.1017    also have "... = s"
  4.1018 -  proof (cases "s = \<zero>\<^sub>2")
  4.1019 +  proof (cases "s = \<zero>\<^bsub>S\<^esub>")
  4.1020      case True then show ?thesis by (simp add: Pi_def)
  4.1021    next
  4.1022      case False with S show ?thesis by (simp add: Pi_def)
  4.1023    qed
  4.1024 -  finally show "(\<Oplus>\<^sub>2 i \<in> {..deg R (monom P \<one> 1)}.
  4.1025 -    h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) = s" .
  4.1026 +  finally show "(\<Oplus>\<^bsub>S\<^esub> i \<in> {..deg R (monom P \<one> 1)}.
  4.1027 +    h (coeff P (monom P \<one> 1) i) \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> i) = s" .
  4.1028  qed
  4.1029  
  4.1030  lemma (in UP_cring) monom_pow:
  4.1031    assumes R: "a \<in> carrier R"
  4.1032 -  shows "(monom P a n) (^)\<^sub>2 m = monom P (a (^) m) (n * m)"
  4.1033 +  shows "(monom P a n) (^)\<^bsub>P\<^esub> m = monom P (a (^) m) (n * m)"
  4.1034  proof (induct m)
  4.1035    case 0 from R show ?case by simp
  4.1036  next
  4.1037 @@ -1420,32 +1435,34 @@
  4.1038  qed
  4.1039  
  4.1040  lemma (in ring_hom_cring) hom_pow [simp]:
  4.1041 -  "x \<in> carrier R ==> h (x (^) n) = h x (^)\<^sub>2 (n::nat)"
  4.1042 +  "x \<in> carrier R ==> h (x (^) n) = h x (^)\<^bsub>S\<^esub> (n::nat)"
  4.1043    by (induct n) simp_all
  4.1044  
  4.1045 -lemma (in ring_hom_UP_cring) UP_hom_pow [simp]:
  4.1046 -  "[| s \<in> carrier S; p \<in> carrier P |] ==>
  4.1047 -  (eval R S h s) (p (^)\<^sub>3 n) = eval R S h s p (^)\<^sub>2 (n::nat)"
  4.1048 -  by (rule ring_hom_cring.hom_pow [OF ring_hom_cring_P_S])
  4.1049 -
  4.1050 -lemma (in ring_hom_UP_cring) eval_monom:
  4.1051 +lemma (in UP_univ_prop) eval_monom:
  4.1052    "[| s \<in> carrier S; r \<in> carrier R |] ==>
  4.1053 -  eval R S h s (monom P r n) = h r \<otimes>\<^sub>2 s (^)\<^sub>2 n"
  4.1054 +  eval R S h s (monom P r n) = h r \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> n"
  4.1055  proof -
  4.1056 -  assume RS: "s \<in> carrier S" "r \<in> carrier R"
  4.1057 -  then have "eval R S h s (monom P r n) =
  4.1058 -    eval R S h s (monom P r 0 \<otimes>\<^sub>3 (monom P \<one> 1) (^)\<^sub>3 n)"
  4.1059 -    by (simp del: monom_mult UP_hom_mult UP_hom_pow
  4.1060 +  assume S: "s \<in> carrier S" and R: "r \<in> carrier R"
  4.1061 +  from R S have "eval R S h s (monom P r n) =
  4.1062 +    eval R S h s (monom P r 0 \<otimes>\<^bsub>P\<^esub> (monom P \<one> 1) (^)\<^bsub>P\<^esub> n)"
  4.1063 +    by (simp del: monom_mult (* eval.hom_mult eval.hom_pow, delayed inst! *)
  4.1064        add: monom_mult [THEN sym] monom_pow)
  4.1065 -  also from RS eval_monom1 have "... = h r \<otimes>\<^sub>2 s (^)\<^sub>2 n"
  4.1066 +  also
  4.1067 +  from ring_hom_cring_P_S [OF S] instantiate eval: ring_hom_cring
  4.1068 +  from R S eval_monom1 have "... = h r \<otimes>\<^bsub>S\<^esub> s (^)\<^bsub>S\<^esub> n"
  4.1069      by (simp add: eval_const)
  4.1070    finally show ?thesis .
  4.1071  qed
  4.1072  
  4.1073 -lemma (in ring_hom_UP_cring) eval_smult:
  4.1074 +lemma (in UP_univ_prop) eval_smult:
  4.1075    "[| s \<in> carrier S; r \<in> carrier R; p \<in> carrier P |] ==>
  4.1076 -  eval R S h s (r \<odot>\<^sub>3 p) = h r \<otimes>\<^sub>2 eval R S h s p"
  4.1077 -  by (simp add: monom_mult_is_smult [THEN sym] eval_const)
  4.1078 +  eval R S h s (r \<odot>\<^bsub>P\<^esub> p) = h r \<otimes>\<^bsub>S\<^esub> eval R S h s p"
  4.1079 +proof -
  4.1080 +  assume S: "s \<in> carrier S" and R: "r \<in> carrier R" and P: "p \<in> carrier P"
  4.1081 +  from ring_hom_cring_P_S [OF S] instantiate eval: ring_hom_cring
  4.1082 +  from S R P show ?thesis
  4.1083 +    by (simp add: monom_mult_is_smult [THEN sym] eval_const)
  4.1084 +qed
  4.1085  
  4.1086  lemma ring_hom_cringI:
  4.1087    assumes "cring R"
  4.1088 @@ -1455,34 +1472,41 @@
  4.1089    by (fast intro: ring_hom_cring.intro ring_hom_cring_axioms.intro
  4.1090      cring.axioms prems)
  4.1091  
  4.1092 -lemma (in ring_hom_UP_cring) UP_hom_unique:
  4.1093 +lemma (in UP_univ_prop) UP_hom_unique:
  4.1094    assumes Phi: "Phi \<in> ring_hom P S" "Phi (monom P \<one> (Suc 0)) = s"
  4.1095        "!!r. r \<in> carrier R ==> Phi (monom P r 0) = h r"
  4.1096      and Psi: "Psi \<in> ring_hom P S" "Psi (monom P \<one> (Suc 0)) = s"
  4.1097        "!!r. r \<in> carrier R ==> Psi (monom P r 0) = h r"
  4.1098 -    and RS: "s \<in> carrier S" "p \<in> carrier P"
  4.1099 +    and S: "s \<in> carrier S" and P: "p \<in> carrier P"
  4.1100    shows "Phi p = Psi p"
  4.1101  proof -
  4.1102    have Phi_hom: "ring_hom_cring P S Phi"
  4.1103      by (auto intro: ring_hom_cringI UP_cring S.cring Phi)
  4.1104    have Psi_hom: "ring_hom_cring P S Psi"
  4.1105      by (auto intro: ring_hom_cringI UP_cring S.cring Psi)
  4.1106 -  have "Phi p = Phi (\<Oplus>\<^sub>3i \<in> {..deg R p}. monom P (coeff P p i) 0 \<otimes>\<^sub>3 monom P \<one> 1 (^)\<^sub>3 i)"
  4.1107 -    by (simp add: up_repr RS monom_mult [THEN sym] monom_pow del: monom_mult)
  4.1108 -  also have "... = Psi (\<Oplus>\<^sub>3i\<in>{..deg R p}. monom P (coeff P p i) 0 \<otimes>\<^sub>3 monom P \<one> 1 (^)\<^sub>3 i)"
  4.1109 +  have "Phi p =
  4.1110 +      Phi (\<Oplus>\<^bsub>P \<^esub>i \<in> {..deg R p}. monom P (coeff P p i) 0 \<otimes>\<^bsub>P\<^esub> monom P \<one> 1 (^)\<^bsub>P\<^esub> i)"
  4.1111 +    by (simp add: up_repr P S monom_mult [THEN sym] monom_pow del: monom_mult)
  4.1112 +  also 
  4.1113 +    from Phi_hom instantiate Phi: ring_hom_cring
  4.1114 +    from Psi_hom instantiate Psi: ring_hom_cring
  4.1115 +    have "... =
  4.1116 +      Psi (\<Oplus>\<^bsub>P \<^esub>i\<in>{..deg R p}. monom P (coeff P p i) 0 \<otimes>\<^bsub>P\<^esub> monom P \<one> 1 (^)\<^bsub>P\<^esub> i)"
  4.1117 +    by (simp add: Phi Psi P S Pi_def comp_def)
  4.1118 +(* Without instantiate, the following command would have been necessary.
  4.1119      by (simp add: ring_hom_cring.hom_finsum [OF Phi_hom]
  4.1120        ring_hom_cring.hom_mult [OF Phi_hom]
  4.1121        ring_hom_cring.hom_pow [OF Phi_hom] Phi
  4.1122        ring_hom_cring.hom_finsum [OF Psi_hom]
  4.1123        ring_hom_cring.hom_mult [OF Psi_hom]
  4.1124        ring_hom_cring.hom_pow [OF Psi_hom] Psi RS Pi_def comp_def)
  4.1125 +*)
  4.1126    also have "... = Psi p"
  4.1127 -    by (simp add: up_repr RS monom_mult [THEN sym] monom_pow del: monom_mult)
  4.1128 +    by (simp add: up_repr P S monom_mult [THEN sym] monom_pow del: monom_mult)
  4.1129    finally show ?thesis .
  4.1130  qed
  4.1131  
  4.1132 -
  4.1133 -theorem (in ring_hom_UP_cring) UP_universal_property:
  4.1134 +theorem (in UP_univ_prop) UP_universal_property:
  4.1135    "s \<in> carrier S ==>
  4.1136    EX! Phi. Phi \<in> ring_hom P S \<inter> extensional (carrier P) &
  4.1137      Phi (monom P \<one> 1) = s &
  4.1138 @@ -1495,31 +1519,31 @@
  4.1139  
  4.1140  subsection {* Sample application of evaluation homomorphism *}
  4.1141  
  4.1142 -lemma ring_hom_UP_cringI:
  4.1143 +lemma UP_univ_propI:
  4.1144    assumes "cring R"
  4.1145      and "cring S"
  4.1146      and "h \<in> ring_hom R S"
  4.1147 -  shows "ring_hom_UP_cring R S h"
  4.1148 -  by (fast intro: ring_hom_UP_cring.intro ring_hom_cring_axioms.intro
  4.1149 +  shows "UP_univ_prop R S h"
  4.1150 +  by (fast intro: UP_univ_prop.intro ring_hom_cring_axioms.intro
  4.1151      cring.axioms prems)
  4.1152  
  4.1153  constdefs
  4.1154    INTEG :: "int ring"
  4.1155    "INTEG == (| carrier = UNIV, mult = op *, one = 1, zero = 0, add = op + |)"
  4.1156  
  4.1157 -lemma cring_INTEG:
  4.1158 +lemma INTEG_cring:
  4.1159    "cring INTEG"
  4.1160    by (unfold INTEG_def) (auto intro!: cringI abelian_groupI comm_monoidI
  4.1161      zadd_zminus_inverse2 zadd_zmult_distrib)
  4.1162  
  4.1163 -lemma INTEG_id:
  4.1164 -  "ring_hom_UP_cring INTEG INTEG id"
  4.1165 -  by (fast intro: ring_hom_UP_cringI cring_INTEG id_ring_hom)
  4.1166 +lemma INTEG_id_eval:
  4.1167 +  "UP_univ_prop INTEG INTEG id"
  4.1168 +  by (fast intro: UP_univ_propI INTEG_cring id_ring_hom)
  4.1169  
  4.1170  text {*
  4.1171    An instantiation mechanism would now import all theorems and lemmas
  4.1172    valid in the context of homomorphisms between @{term INTEG} and @{term
  4.1173 -  "UP INTEG"}.
  4.1174 +  "UP INTEG"} globally.
  4.1175  *}
  4.1176  
  4.1177  lemma INTEG_closed [intro, simp]:
  4.1178 @@ -1535,6 +1559,6 @@
  4.1179    by (induct n) (simp_all add: INTEG_def nat_pow_def)
  4.1180  
  4.1181  lemma "eval INTEG INTEG id 10 (monom (UP INTEG) 5 2) = 500"
  4.1182 -  by (simp add: ring_hom_UP_cring.eval_monom [OF INTEG_id])
  4.1183 +  by (simp add: UP_univ_prop.eval_monom [OF INTEG_id_eval])
  4.1184  
  4.1185  end