src/HOL/Algebra/abstract/Ring.thy
author wenzelm
Mon, 15 Oct 2001 20:34:12 +0200
changeset 11778 37efbe093d3c
parent 11093 62c2e0af1d30
child 13735 7de9342aca7a
permissions -rw-r--r--
ring includes plus_ac0;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     1
(*
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     2
    Abstract class ring (commutative, with 1)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     3
    $Id$
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     4
    Author: Clemens Ballarin, started 9 December 1996
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     5
*)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     6
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     7
Ring = Main +
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     8
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
     9
(* Syntactic class ring *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    10
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    11
axclass
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    12
  ringS < zero, plus, minus, times, power, inverse
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    13
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    14
consts
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    15
  (* Basic rings *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    16
  "<1>"		:: 'a::ringS				("<1>")
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    17
  "--"		:: ['a, 'a] => 'a::ringS		(infixl 65)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    18
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    19
  (* Divisibility *)
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    20
  assoc		:: ['a::times, 'a] => bool		(infixl 50)
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    21
  irred		:: 'a::ringS => bool
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    22
  prime		:: 'a::ringS => bool
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    23
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    24
translations
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    25
  "a -- b" 	== "a + (-b)"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    26
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    27
(* Class ring and ring axioms *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    28
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    29
axclass
11778
37efbe093d3c ring includes plus_ac0;
wenzelm
parents: 11093
diff changeset
    30
  ring < ringS, plus_ac0
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    31
11778
37efbe093d3c ring includes plus_ac0;
wenzelm
parents: 11093
diff changeset
    32
(*a_assoc	"(a + b) + c = a + (b + c)"*)
37efbe093d3c ring includes plus_ac0;
wenzelm
parents: 11093
diff changeset
    33
(*l_zero	"0 + a = a"*)
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    34
  l_neg		"(-a) + a = 0"
11778
37efbe093d3c ring includes plus_ac0;
wenzelm
parents: 11093
diff changeset
    35
(*a_comm	"a + b = b + a"*)
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    36
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    37
  m_assoc	"(a * b) * c = a * (b * c)"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    38
  l_one		"<1> * a = a"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    39
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    40
  l_distr	"(a + b) * c = a * c + b * c"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    41
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    42
  m_comm	"a * b = b * a"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    43
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    44
  (* Definition of derived operations *)
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    45
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    46
  inverse_ax    "inverse a = (if a dvd <1> then @x. a*x = <1> else 0)"
10447
1dbd79bd3bc6 use inverse, divide from basic HOL;
wenzelm
parents: 9390
diff changeset
    47
  divide_ax     "a / b = a * inverse b"
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    48
  power_ax	"a ^ n = nat_rec <1> (%u b. b * a) n"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    49
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    50
defs
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    51
  assoc_def	"a assoc b == a dvd b & b dvd a"
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    52
  irred_def	"irred a == a ~= 0 & ~ a dvd <1>
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    53
                          & (ALL d. d dvd a --> d dvd <1> | a dvd d)"
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    54
  prime_def	"prime p == p ~= 0 & ~ p dvd <1>
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    55
                          & (ALL a b. p dvd (a*b) --> p dvd a | p dvd b)"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    56
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    57
(* Integral domains *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    58
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    59
axclass
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    60
  domain < ring
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    61
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    62
  one_not_zero	"<1> ~= 0"
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    63
  integral	"a * b = 0 ==> a = 0 | b = 0"
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    64
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    65
(* Factorial domains *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    66
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    67
axclass
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    68
  factorial < domain
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    69
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    70
(*
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    71
  Proper definition using divisor chain condition currently not supported.
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    72
  factorial_divisor	"wf {(a, b). a dvd b & ~ (b dvd a)}"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    73
*)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    74
  factorial_divisor	"True"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    75
  factorial_prime	"irred a ==> prime a"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    76
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    77
(* Euclidean domains *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    78
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    79
(*
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    80
axclass
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    81
  euclidean < domain
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    82
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
    83
  euclidean_ax	"b ~= 0 ==> Ex (% (q, r, e_size::('a::ringS)=>nat).
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    84
                   a = b * q + r & e_size r < e_size b)"
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    85
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    86
  Nothing has been proved about euclidean domains, yet.
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    87
  Design question:
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    88
    Fix quo, rem and e_size as constants that are axiomatised with
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    89
    euclidean_ax?
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    90
    - advantage: more pragmatic and easier to use
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    91
    - disadvantage: for every type, one definition of quo and rem will
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    92
        be fixed, users may want to use differing ones;
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    93
        also, it seems not possible to prove that fields are euclidean
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    94
        domains, because that would require generic (type-independent)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    95
        definitions of quo and rem.
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    96
*)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    97
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    98
(* Fields *)
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
    99
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   100
axclass
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   101
  field < ring
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   102
11093
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
   103
  field_one_not_zero	"<1> ~= 0"
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
   104
		(* Avoid a common superclass as the first thing we will
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
   105
		   prove about fields is that they are domains. *)
62c2e0af1d30 Changes to HOL/Algebra:
ballarin
parents: 10447
diff changeset
   106
  field_ax	"a ~= 0 ==> a dvd <1>"
7998
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   107
3d0c34795831 Algebra and Polynomial theories, by Clemens Ballarin
paulson
parents:
diff changeset
   108
end