src/HOL/Algebra/abstract/Ring2.thy
author haftmann
Wed, 24 Feb 2010 11:21:37 +0100
changeset 35330 e7eb254db165
parent 35267 8dfd816713c6
child 35408 b48ab741683b
permissions -rw-r--r--
tuned comment
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29269
5c25a2012975 moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents: 27651
diff changeset
     1
(*  Title:     HOL/Algebra/abstract/Ring2.thy
5c25a2012975 moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents: 27651
diff changeset
     2
    Author:    Clemens Ballarin
5c25a2012975 moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents: 27651
diff changeset
     3
5c25a2012975 moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents: 27651
diff changeset
     4
The algebraic hierarchy of rings as axiomatic classes.
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     5
*)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     6
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
     7
header {* The algebraic hierarchy of rings as type classes *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     8
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
     9
theory Ring2
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    10
imports Main
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    11
begin
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    12
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    13
subsection {* Ring axioms *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    14
31001
7e6ffd8f51a9 cleaned up theory power further
haftmann
parents: 30968
diff changeset
    15
class ring = zero + one + plus + minus + uminus + times + inverse + power + dvd +
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    16
  assumes a_assoc:      "(a + b) + c = a + (b + c)"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    17
  and l_zero:           "0 + a = a"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    18
  and l_neg:            "(-a) + a = 0"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    19
  and a_comm:           "a + b = b + a"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    20
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    21
  assumes m_assoc:      "(a * b) * c = a * (b * c)"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    22
  and l_one:            "1 * a = a"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    23
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    24
  assumes l_distr:      "(a + b) * c = a * c + b * c"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    25
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    26
  assumes m_comm:       "a * b = b * a"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    27
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    28
  assumes minus_def:    "a - b = a + (-b)"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    29
  and inverse_def:      "inverse a = (if a dvd 1 then THE x. a*x = 1 else 0)"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    30
  and divide_def:       "a / b = a * inverse b"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    31
begin
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    32
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    33
definition assoc :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "assoc" 50) where
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    34
  assoc_def: "a assoc b \<longleftrightarrow> a dvd b & b dvd a"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    35
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    36
definition irred :: "'a \<Rightarrow> bool" where
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    37
  irred_def: "irred a \<longleftrightarrow> a ~= 0 & ~ a dvd 1
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    38
                          & (ALL d. d dvd a --> d dvd 1 | a dvd d)"
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    39
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    40
definition prime :: "'a \<Rightarrow> bool" where
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    41
  prime_def: "prime p \<longleftrightarrow> p ~= 0 & ~ p dvd 1
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    42
                          & (ALL a b. p dvd (a*b) --> p dvd a | p dvd b)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    43
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    44
end
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    45
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    46
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    47
subsection {* Integral domains *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    48
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    49
class "domain" = ring +
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    50
  assumes one_not_zero: "1 ~= 0"
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    51
  and integral: "a * b = 0 ==> a = 0 | b = 0"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    52
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    53
subsection {* Factorial domains *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    54
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    55
class factorial = "domain" +
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    56
(*
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    57
  Proper definition using divisor chain condition currently not supported.
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    58
  factorial_divisor:    "wf {(a, b). a dvd b & ~ (b dvd a)}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    59
*)
29665
2b956243d123 explicit check for exactly one type variable in class specification elements
haftmann
parents: 29269
diff changeset
    60
  (*assumes factorial_divisor: "True"*)
2b956243d123 explicit check for exactly one type variable in class specification elements
haftmann
parents: 29269
diff changeset
    61
  assumes factorial_prime: "irred a ==> prime a"
2b956243d123 explicit check for exactly one type variable in class specification elements
haftmann
parents: 29269
diff changeset
    62
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    63
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    64
subsection {* Euclidean domains *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    65
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    66
(*
35330
e7eb254db165 tuned comment
haftmann
parents: 35267
diff changeset
    67
class euclidean = "domain" +
e7eb254db165 tuned comment
haftmann
parents: 35267
diff changeset
    68
  assumes euclidean_ax: "b ~= 0 ==> Ex (% (q, r, e_size::('a::ringS)=>nat).
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    69
                   a = b * q + r & e_size r < e_size b)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    70
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    71
  Nothing has been proved about Euclidean domains, yet.
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    72
  Design question:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    73
    Fix quo, rem and e_size as constants that are axiomatised with
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    74
    euclidean_ax?
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    75
    - advantage: more pragmatic and easier to use
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    76
    - disadvantage: for every type, one definition of quo and rem will
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    77
        be fixed, users may want to use differing ones;
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    78
        also, it seems not possible to prove that fields are euclidean
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    79
        domains, because that would require generic (type-independent)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    80
        definitions of quo and rem.
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    81
*)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    82
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    83
subsection {* Fields *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    84
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    85
class field = ring +
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    86
  assumes field_one_not_zero: "1 ~= 0"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    87
                (* Avoid a common superclass as the first thing we will
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    88
                   prove about fields is that they are domains. *)
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
    89
  and field_ax: "a ~= 0 ==> a dvd 1"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    90
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
    91
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    92
section {* Basic facts *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    93
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    94
subsection {* Normaliser for rings *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    95
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
    96
(* derived rewrite rules *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
    97
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
    98
lemma a_lcomm: "(a::'a::ring)+(b+c) = b+(a+c)"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
    99
  apply (rule a_comm [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   100
  apply (rule a_assoc [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   101
  apply (rule a_comm [THEN arg_cong])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   102
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   103
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   104
lemma r_zero: "(a::'a::ring) + 0 = a"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   105
  apply (rule a_comm [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   106
  apply (rule l_zero)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   107
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   108
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   109
lemma r_neg: "(a::'a::ring) + (-a) = 0"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   110
  apply (rule a_comm [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   111
  apply (rule l_neg)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   112
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   113
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   114
lemma r_neg2: "(a::'a::ring) + (-a + b) = b"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   115
  apply (rule a_assoc [symmetric, THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   116
  apply (simp add: r_neg l_zero)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   117
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   118
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   119
lemma r_neg1: "-(a::'a::ring) + (a + b) = b"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   120
  apply (rule a_assoc [symmetric, THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   121
  apply (simp add: l_neg l_zero)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   122
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   123
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   124
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   125
(* auxiliary *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   126
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   127
lemma a_lcancel: "!! a::'a::ring. a + b = a + c ==> b = c"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   128
  apply (rule box_equals)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   129
  prefer 2
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   130
  apply (rule l_zero)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   131
  prefer 2
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   132
  apply (rule l_zero)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   133
  apply (rule_tac a1 = a in l_neg [THEN subst])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   134
  apply (simp add: a_assoc)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   135
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   136
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   137
lemma minus_add: "-((a::'a::ring) + b) = (-a) + (-b)"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   138
  apply (rule_tac a = "a + b" in a_lcancel)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   139
  apply (simp add: r_neg l_neg l_zero a_assoc a_comm a_lcomm)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   140
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   141
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   142
lemma minus_minus: "-(-(a::'a::ring)) = a"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   143
  apply (rule a_lcancel)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   144
  apply (rule r_neg [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   145
  apply (rule l_neg [symmetric])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   146
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   147
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   148
lemma minus0: "- 0 = (0::'a::ring)"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   149
  apply (rule a_lcancel)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   150
  apply (rule r_neg [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   151
  apply (rule l_zero [symmetric])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   152
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   153
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   154
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   155
(* derived rules for multiplication *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   156
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   157
lemma m_lcomm: "(a::'a::ring)*(b*c) = b*(a*c)"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   158
  apply (rule m_comm [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   159
  apply (rule m_assoc [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   160
  apply (rule m_comm [THEN arg_cong])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   161
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   162
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   163
lemma r_one: "(a::'a::ring) * 1 = a"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   164
  apply (rule m_comm [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   165
  apply (rule l_one)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   166
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   167
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   168
lemma r_distr: "(a::'a::ring) * (b + c) = a * b + a * c"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   169
  apply (rule m_comm [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   170
  apply (rule l_distr [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   171
  apply (simp add: m_comm)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   172
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   173
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   174
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   175
(* the following proof is from Jacobson, Basic Algebra I, pp. 88-89 *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   176
lemma l_null: "0 * (a::'a::ring) = 0"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   177
  apply (rule a_lcancel)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   178
  apply (rule l_distr [symmetric, THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   179
  apply (simp add: r_zero)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   180
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   181
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   182
lemma r_null: "(a::'a::ring) * 0 = 0"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   183
  apply (rule m_comm [THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   184
  apply (rule l_null)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   185
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   186
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   187
lemma l_minus: "(-(a::'a::ring)) * b = - (a * b)"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   188
  apply (rule a_lcancel)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   189
  apply (rule r_neg [symmetric, THEN [2] trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   190
  apply (rule l_distr [symmetric, THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   191
  apply (simp add: l_null r_neg)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   192
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   193
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   194
lemma r_minus: "(a::'a::ring) * (-b) = - (a * b)"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   195
  apply (rule a_lcancel)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   196
  apply (rule r_neg [symmetric, THEN [2] trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   197
  apply (rule r_distr [symmetric, THEN trans])
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   198
  apply (simp add: r_null r_neg)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   199
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   200
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   201
(*** Term order for commutative rings ***)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   202
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   203
ML {*
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   204
fun ring_ord (Const (a, _)) =
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   205
    find_index (fn a' => a = a')
35267
8dfd816713c6 moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents: 34974
diff changeset
   206
      [@{const_name Groups.zero}, @{const_name Groups.plus}, @{const_name Groups.uminus},
8dfd816713c6 moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents: 34974
diff changeset
   207
        @{const_name Groups.minus}, @{const_name Groups.one}, @{const_name Groups.times}]
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   208
  | ring_ord _ = ~1;
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   209
29269
5c25a2012975 moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents: 27651
diff changeset
   210
fun termless_ring (a, b) = (TermOrd.term_lpo ring_ord (a, b) = LESS);
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   211
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   212
val ring_ss = HOL_basic_ss settermless termless_ring addsimps
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   213
  [thm "a_assoc", thm "l_zero", thm "l_neg", thm "a_comm", thm "m_assoc",
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   214
   thm "l_one", thm "l_distr", thm "m_comm", thm "minus_def",
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   215
   thm "r_zero", thm "r_neg", thm "r_neg2", thm "r_neg1", thm "minus_add",
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   216
   thm "minus_minus", thm "minus0", thm "a_lcomm", thm "m_lcomm", (*thm "r_one",*)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   217
   thm "r_distr", thm "l_null", thm "r_null", thm "l_minus", thm "r_minus"];
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   218
*}   (* Note: r_one is not necessary in ring_ss *)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   219
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   220
method_setup ring =
30549
d2d7874648bd simplified method setup;
wenzelm
parents: 30510
diff changeset
   221
  {* Scan.succeed (K (SIMPLE_METHOD' (full_simp_tac ring_ss))) *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   222
  {* computes distributive normal form in rings *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   223
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   224
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   225
subsection {* Rings and the summation operator *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   226
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   227
(* Basic facts --- move to HOL!!! *)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   228
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   229
(* needed because natsum_cong (below) disables atMost_0 *)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   230
lemma natsum_0 [simp]: "setsum f {..(0::nat)} = (f 0::'a::comm_monoid_add)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   231
by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   232
(*
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   233
lemma natsum_Suc [simp]:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   234
  "setsum f {..Suc n} = (f (Suc n) + setsum f {..n}::'a::comm_monoid_add)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   235
by (simp add: atMost_Suc)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   236
*)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   237
lemma natsum_Suc2:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   238
  "setsum f {..Suc n} = (f 0::'a::comm_monoid_add) + (setsum (%i. f (Suc i)) {..n})"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   239
proof (induct n)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   240
  case 0 show ?case by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   241
next
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   242
  case Suc thus ?case by (simp add: add_assoc)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   243
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   244
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   245
lemma natsum_cong [cong]:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   246
  "!!k. [| j = k; !!i::nat. i <= k ==> f i = (g i::'a::comm_monoid_add) |] ==>
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   247
        setsum f {..j} = setsum g {..k}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   248
by (induct j) auto
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   249
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   250
lemma natsum_zero [simp]: "setsum (%i. 0) {..n::nat} = (0::'a::comm_monoid_add)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   251
by (induct n) simp_all
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   252
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   253
lemma natsum_add [simp]:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   254
  "!!f::nat=>'a::comm_monoid_add.
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   255
   setsum (%i. f i + g i) {..n::nat} = setsum f {..n} + setsum g {..n}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   256
by (induct n) (simp_all add: add_ac)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   257
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   258
(* Facts specific to rings *)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   259
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
   260
subclass (in ring) comm_monoid_add
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   261
proof
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   262
  fix x y z
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
   263
  show "x + y = y + x" by (rule a_comm)
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
   264
  show "(x + y) + z = x + (y + z)" by (rule a_assoc)
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
   265
  show "0 + x = x" by (rule l_zero)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   266
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   267
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   268
ML {*
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   269
  local
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   270
    val lhss =
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   271
        ["t + u::'a::ring",
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   272
         "t - u::'a::ring",
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   273
         "t * u::'a::ring",
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   274
         "- t::'a::ring"];
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   275
    fun proc ss t =
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   276
      let val rew = Goal.prove (Simplifier.the_context ss) [] []
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   277
            (HOLogic.mk_Trueprop
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   278
              (HOLogic.mk_eq (t, Var (("x", Term.maxidx_of_term t + 1), fastype_of t))))
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   279
                (fn _ => simp_tac (Simplifier.inherit_context ss ring_ss) 1)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   280
            |> mk_meta_eq;
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   281
          val (t', u) = Logic.dest_equals (Thm.prop_of rew);
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   282
      in if t' aconv u
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   283
        then NONE
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   284
        else SOME rew
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   285
    end;
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   286
  in
32010
cb1a1c94b4cd more antiquotations;
wenzelm
parents: 31001
diff changeset
   287
    val ring_simproc = Simplifier.simproc @{theory} "ring" lhss (K proc);
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   288
  end;
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   289
*}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   290
26480
544cef16045b replaced 'ML_setup' by 'ML';
wenzelm
parents: 26342
diff changeset
   291
ML {* Addsimprocs [ring_simproc] *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   292
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   293
lemma natsum_ldistr:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   294
  "!!a::'a::ring. setsum f {..n::nat} * a = setsum (%i. f i * a) {..n}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   295
by (induct n) simp_all
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   296
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   297
lemma natsum_rdistr:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   298
  "!!a::'a::ring. a * setsum f {..n::nat} = setsum (%i. a * f i) {..n}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   299
by (induct n) simp_all
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   300
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   301
subsection {* Integral Domains *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   302
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   303
declare one_not_zero [simp]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   304
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   305
lemma zero_not_one [simp]:
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   306
  "0 ~= (1::'a::domain)"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   307
by (rule not_sym) simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   308
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   309
lemma integral_iff: (* not by default a simp rule! *)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   310
  "(a * b = (0::'a::domain)) = (a = 0 | b = 0)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   311
proof
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   312
  assume "a * b = 0" then show "a = 0 | b = 0" by (simp add: integral)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   313
next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   314
  assume "a = 0 | b = 0" then show "a * b = 0" by auto
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   315
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   316
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   317
(*
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   318
lemma "(a::'a::ring) - (a - b) = b" apply simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   319
 simproc seems to fail on this example (fixed with new term order)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   320
*)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   321
(*
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   322
lemma bug: "(b::'a::ring) - (b - a) = a" by simp
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   323
   simproc for rings cannot prove "(a::'a::ring) - (a - b) = b"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   324
*)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   325
lemma m_lcancel:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   326
  assumes prem: "(a::'a::domain) ~= 0" shows conc: "(a * b = a * c) = (b = c)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   327
proof
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   328
  assume eq: "a * b = a * c"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   329
  then have "a * (b - c) = 0" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   330
  then have "a = 0 | (b - c) = 0" by (simp only: integral_iff)
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   331
  with prem have "b - c = 0" by auto
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   332
  then have "b = b - (b - c)" by simp
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   333
  also have "b - (b - c) = c" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   334
  finally show "b = c" .
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   335
next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   336
  assume "b = c" then show "a * b = a * c" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   337
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   338
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   339
lemma m_rcancel:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   340
  "(a::'a::domain) ~= 0 ==> (b * a = c * a) = (b = c)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   341
by (simp add: m_lcancel)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   342
27542
9bf0a22f8bcd class instead of axclass
haftmann
parents: 26480
diff changeset
   343
declare power_Suc [simp]
21416
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   344
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   345
lemma power_one [simp]:
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   346
  "1 ^ n = (1::'a::ring)" by (induct n) simp_all
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   347
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   348
lemma power_zero [simp]:
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   349
  "n \<noteq> 0 \<Longrightarrow> 0 ^ n = (0::'a::ring)" by (induct n) simp_all
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   350
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   351
lemma power_mult [simp]:
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   352
  "(a::'a::ring) ^ m * a ^ n = a ^ (m + n)"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   353
  by (induct m) simp_all
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   354
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   355
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   356
section "Divisibility"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   357
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   358
lemma dvd_zero_right [simp]:
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   359
  "(a::'a::ring) dvd 0"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   360
proof
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   361
  show "0 = a * 0" by simp
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   362
qed
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   363
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   364
lemma dvd_zero_left:
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   365
  "0 dvd (a::'a::ring) \<Longrightarrow> a = 0" unfolding dvd_def by simp
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   366
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   367
lemma dvd_refl_ring [simp]:
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   368
  "(a::'a::ring) dvd a"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   369
proof
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   370
  show "a = a * 1" by simp
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   371
qed
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   372
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   373
lemma dvd_trans_ring:
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   374
  fixes a b c :: "'a::ring"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   375
  assumes a_dvd_b: "a dvd b"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   376
  and b_dvd_c: "b dvd c"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   377
  shows "a dvd c"
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   378
proof -
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   379
  from a_dvd_b obtain l where "b = a * l" using dvd_def by blast
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   380
  moreover from b_dvd_c obtain j where "c = b * j" using dvd_def by blast
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   381
  ultimately have "c = a * (l * j)" by simp
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   382
  then have "\<exists>k. c = a * k" ..
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   383
  then show ?thesis using dvd_def by blast
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   384
qed
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   385
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   386
32449
696d64ed85da eliminated hard tabs;
wenzelm
parents: 32010
diff changeset
   387
lemma unit_mult:
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   388
  "!!a::'a::ring. [| a dvd 1; b dvd 1 |] ==> a * b dvd 1"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   389
  apply (unfold dvd_def)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   390
  apply clarify
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   391
  apply (rule_tac x = "k * ka" in exI)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   392
  apply simp
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   393
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   394
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   395
lemma unit_power: "!!a::'a::ring. a dvd 1 ==> a^n dvd 1"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   396
  apply (induct_tac n)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   397
   apply simp
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   398
  apply (simp add: unit_mult)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   399
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   400
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   401
lemma dvd_add_right [simp]:
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   402
  "!! a::'a::ring. [| a dvd b; a dvd c |] ==> a dvd b + c"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   403
  apply (unfold dvd_def)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   404
  apply clarify
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   405
  apply (rule_tac x = "k + ka" in exI)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   406
  apply (simp add: r_distr)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   407
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   408
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   409
lemma dvd_uminus_right [simp]:
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   410
  "!! a::'a::ring. a dvd b ==> a dvd -b"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   411
  apply (unfold dvd_def)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   412
  apply clarify
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   413
  apply (rule_tac x = "-k" in exI)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   414
  apply (simp add: r_minus)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   415
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   416
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   417
lemma dvd_l_mult_right [simp]:
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   418
  "!! a::'a::ring. a dvd b ==> a dvd c*b"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   419
  apply (unfold dvd_def)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   420
  apply clarify
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   421
  apply (rule_tac x = "c * k" in exI)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   422
  apply simp
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   423
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   424
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   425
lemma dvd_r_mult_right [simp]:
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   426
  "!! a::'a::ring. a dvd b ==> a dvd b*c"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   427
  apply (unfold dvd_def)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   428
  apply clarify
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   429
  apply (rule_tac x = "k * c" in exI)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   430
  apply simp
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   431
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   432
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   433
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   434
(* Inverse of multiplication *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   435
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   436
section "inverse"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   437
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   438
lemma inverse_unique: "!! a::'a::ring. [| a * x = 1; a * y = 1 |] ==> x = y"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   439
  apply (rule_tac a = "(a*y) * x" and b = "y * (a*x)" in box_equals)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   440
    apply (simp (no_asm))
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   441
  apply auto
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   442
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   443
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   444
lemma r_inverse_ring: "!! a::'a::ring. a dvd 1 ==> a * inverse a = 1"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   445
  apply (unfold inverse_def dvd_def)
26342
0f65fa163304 more antiquotations;
wenzelm
parents: 25762
diff changeset
   446
  apply (tactic {* asm_full_simp_tac (@{simpset} delsimprocs [ring_simproc]) 1 *})
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   447
  apply clarify
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   448
  apply (rule theI)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   449
   apply assumption
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   450
  apply (rule inverse_unique)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   451
   apply assumption
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   452
  apply assumption
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   453
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   454
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   455
lemma l_inverse_ring: "!! a::'a::ring. a dvd 1 ==> inverse a * a = 1"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   456
  by (simp add: r_inverse_ring)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   457
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   458
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   459
(* Fields *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   460
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   461
section "Fields"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   462
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   463
lemma field_unit [simp]: "!! a::'a::field. (a dvd 1) = (a ~= 0)"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   464
  by (auto dest: field_ax dvd_zero_left simp add: field_one_not_zero)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   465
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   466
lemma r_inverse [simp]: "!! a::'a::field. a ~= 0 ==> a * inverse a = 1"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   467
  by (simp add: r_inverse_ring)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   468
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   469
lemma l_inverse [simp]: "!! a::'a::field. a ~= 0 ==> inverse a * a= 1"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   470
  by (simp add: l_inverse_ring)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   471
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   472
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   473
(* fields are integral domains *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   474
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   475
lemma field_integral: "!! a::'a::field. a * b = 0 ==> a = 0 | b = 0"
23894
1a4167d761ac tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents: 22997
diff changeset
   476
  apply (tactic "step_tac @{claset} 1")
21423
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   477
  apply (rule_tac a = " (a*b) * inverse b" in box_equals)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   478
    apply (rule_tac [3] refl)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   479
   prefer 2
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   480
   apply (simp (no_asm))
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   481
   apply auto
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   482
  done
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   483
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   484
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   485
(* fields are factorial domains *)
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   486
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   487
lemma field_fact_prime: "!! a::'a::field. irred a ==> prime a"
6cdd0589aa73 HOL-Algebra: converted legacy ML scripts;
wenzelm
parents: 21416
diff changeset
   488
  unfolding prime_def irred_def by (blast intro: field_ax)
21416
f23e4e75dfd3 dvd_def now with object equality
haftmann
parents: 20318
diff changeset
   489
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   490
end