src/HOL/Algebra/IntRing.thy
author huffman
Fri, 05 Mar 2010 14:05:25 -0800
changeset 35596 49a02dab35ed
parent 35416 d8d7d1b785af
child 35848 5443079512ea
permissions -rw-r--r--
add comment
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     1
(*
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     2
  Title:     HOL/Algebra/IntRing.thy
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     3
  Author:    Stephan Hohe, TU Muenchen
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     4
*)
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
theory IntRing
32480
6c19da8e661a some reorganization of number theory
haftmann
parents: 30729
diff changeset
     7
imports QuotRing Lattice Int "~~/src/HOL/Old_Number_Theory/Primes"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     8
begin
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     9
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    10
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    11
section {* The Ring of Integers *}
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 {* Some properties of @{typ int} *}
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    14
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    15
lemma dvds_eq_abseq:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    16
  "(l dvd k \<and> k dvd l) = (abs l = abs (k::int))"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    17
apply rule
33657
a4179bf442d1 renamed lemmas "anti_sym" -> "antisym"
nipkow
parents: 32480
diff changeset
    18
 apply (simp add: zdvd_antisym_abs)
33676
802f5e233e48 moved lemma from Algebra/IntRing to Ring_and_Field
nipkow
parents: 33657
diff changeset
    19
apply (simp add: dvd_if_abs_eq)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    20
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    21
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    22
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
    23
subsection {* @{text "\<Z>"}: The Set of Integers as Algebraic Structure *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    24
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33676
diff changeset
    25
definition int_ring :: "int ring" ("\<Z>") where
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    26
  "int_ring \<equiv> \<lparr>carrier = UNIV, mult = op *, one = 1, zero = 0, add = op +\<rparr>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    27
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    28
lemma int_Zcarr [intro!, simp]:
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    29
  "k \<in> carrier \<Z>"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    30
  by (simp add: int_ring_def)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    31
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    32
lemma int_is_cring:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    33
  "cring \<Z>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    34
unfolding int_ring_def
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    35
apply (rule cringI)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    36
  apply (rule abelian_groupI, simp_all)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    37
  defer 1
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    38
  apply (rule comm_monoidI, simp_all)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    39
 apply (rule zadd_zmult_distrib)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    40
apply (fast intro: zadd_zminus_inverse2)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    41
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    42
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    43
(*
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    44
lemma int_is_domain:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    45
  "domain \<Z>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    46
apply (intro domain.intro domain_axioms.intro)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    47
  apply (rule int_is_cring)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    48
 apply (unfold int_ring_def, simp+)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    49
done
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    50
*)
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
    51
subsection {* Interpretations *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    52
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    53
text {* Since definitions of derived operations are global, their
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    54
  interpretation needs to be done as early as possible --- that is,
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    55
  with as few assumptions as possible. *}
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    56
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
    57
interpretation int: monoid \<Z>
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    58
  where "carrier \<Z> = UNIV"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    59
    and "mult \<Z> x y = x * y"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    60
    and "one \<Z> = 1"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    61
    and "pow \<Z> x n = x^n"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    62
proof -
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    63
  -- "Specification"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28524
diff changeset
    64
  show "monoid \<Z>" proof qed (auto simp: int_ring_def)
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
    65
  then interpret int: monoid \<Z> .
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    66
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    67
  -- "Carrier"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    68
  show "carrier \<Z> = UNIV" by (simp add: int_ring_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    69
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    70
  -- "Operations"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    71
  { fix x y show "mult \<Z> x y = x * y" by (simp add: int_ring_def) }
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    72
  note mult = this
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    73
  show one: "one \<Z> = 1" by (simp add: int_ring_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    74
  show "pow \<Z> x n = x^n" by (induct n) (simp, simp add: int_ring_def)+
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    75
qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    76
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
    77
interpretation int: comm_monoid \<Z>
28524
644b62cf678f arbitrary is undefined
haftmann
parents: 28085
diff changeset
    78
  where "finprod \<Z> f A = (if finite A then setprod f A else undefined)"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    79
proof -
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    80
  -- "Specification"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28524
diff changeset
    81
  show "comm_monoid \<Z>" proof qed (auto simp: int_ring_def)
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
    82
  then interpret int: comm_monoid \<Z> .
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    83
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    84
  -- "Operations"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    85
  { fix x y have "mult \<Z> x y = x * y" by (simp add: int_ring_def) }
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    86
  note mult = this
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    87
  have one: "one \<Z> = 1" by (simp add: int_ring_def)
28524
644b62cf678f arbitrary is undefined
haftmann
parents: 28085
diff changeset
    88
  show "finprod \<Z> f A = (if finite A then setprod f A else undefined)"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    89
  proof (cases "finite A")
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    90
    case True then show ?thesis proof induct
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    91
      case empty show ?case by (simp add: one)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    92
    next
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    93
      case insert then show ?case by (simp add: Pi_def mult)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    94
    qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    95
  next
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    96
    case False then show ?thesis by (simp add: finprod_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    97
  qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    98
qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
    99
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   100
interpretation int: abelian_monoid \<Z>
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   101
  where "zero \<Z> = 0"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   102
    and "add \<Z> x y = x + y"
28524
644b62cf678f arbitrary is undefined
haftmann
parents: 28085
diff changeset
   103
    and "finsum \<Z> f A = (if finite A then setsum f A else undefined)"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   104
proof -
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   105
  -- "Specification"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28524
diff changeset
   106
  show "abelian_monoid \<Z>" proof qed (auto simp: int_ring_def)
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   107
  then interpret int: abelian_monoid \<Z> .
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   108
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   109
  -- "Operations"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   110
  { fix x y show "add \<Z> x y = x + y" by (simp add: int_ring_def) }
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   111
  note add = this
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   112
  show zero: "zero \<Z> = 0" by (simp add: int_ring_def)
28524
644b62cf678f arbitrary is undefined
haftmann
parents: 28085
diff changeset
   113
  show "finsum \<Z> f A = (if finite A then setsum f A else undefined)"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   114
  proof (cases "finite A")
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   115
    case True then show ?thesis proof induct
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   116
      case empty show ?case by (simp add: zero)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   117
    next
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   118
      case insert then show ?case by (simp add: Pi_def add)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   119
    qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   120
  next
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   121
    case False then show ?thesis by (simp add: finsum_def finprod_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   122
  qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   123
qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   124
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   125
interpretation int: abelian_group \<Z>
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   126
  where "a_inv \<Z> x = - x"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   127
    and "a_minus \<Z> x y = x - y"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   128
proof -
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   129
  -- "Specification"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   130
  show "abelian_group \<Z>"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   131
  proof (rule abelian_groupI)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   132
    show "!!x. x \<in> carrier \<Z> ==> EX y : carrier \<Z>. y \<oplus>\<^bsub>\<Z>\<^esub> x = \<zero>\<^bsub>\<Z>\<^esub>"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   133
      by (simp add: int_ring_def) arith
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   134
  qed (auto simp: int_ring_def)
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   135
  then interpret int: abelian_group \<Z> .
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   136
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   137
  -- "Operations"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   138
  { fix x y have "add \<Z> x y = x + y" by (simp add: int_ring_def) }
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   139
  note add = this
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   140
  have zero: "zero \<Z> = 0" by (simp add: int_ring_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   141
  { fix x
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   142
    have "add \<Z> (-x) x = zero \<Z>" by (simp add: add zero)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   143
    then show "a_inv \<Z> x = - x" by (simp add: int.minus_equality) }
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   144
  note a_inv = this
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   145
  show "a_minus \<Z> x y = x - y" by (simp add: int.minus_eq add a_inv)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   146
qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   147
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   148
interpretation int: "domain" \<Z>
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28524
diff changeset
   149
  proof qed (auto simp: int_ring_def left_distrib right_distrib)
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   150
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   151
24131
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   152
text {* Removal of occurrences of @{term UNIV} in interpretation result
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   153
  --- experimental. *}
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   154
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   155
lemma UNIV:
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   156
  "x \<in> UNIV = True"
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   157
  "A \<subseteq> UNIV = True"
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   158
  "(ALL x : UNIV. P x) = (ALL x. P x)"
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   159
  "(EX x : UNIV. P x) = (EX x. P x)"
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   160
  "(True --> Q) = Q"
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   161
  "(True ==> PROP R) == PROP R"
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   162
  by simp_all
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   163
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   164
interpretation int (* FIXME [unfolded UNIV] *) :
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   165
  partial_order "(| carrier = UNIV::int set, eq = op =, le = op \<le> |)"
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   166
  where "carrier (| carrier = UNIV::int set, eq = op =, le = op \<le> |) = UNIV"
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   167
    and "le (| carrier = UNIV::int set, eq = op =, le = op \<le> |) x y = (x \<le> y)"
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   168
    and "lless (| carrier = UNIV::int set, eq = op =, le = op \<le> |) x y = (x < y)"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   169
proof -
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   170
  show "partial_order (| carrier = UNIV::int set, eq = op =, le = op \<le> |)"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28524
diff changeset
   171
    proof qed simp_all
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   172
  show "carrier (| carrier = UNIV::int set, eq = op =, le = op \<le> |) = UNIV"
24131
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   173
    by simp
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   174
  show "le (| carrier = UNIV::int set, eq = op =, le = op \<le> |) x y = (x \<le> y)"
24131
1099f6c73649 Experimental removal of assumptions of the form x : UNIV and the like after interpretation.
ballarin
parents: 23957
diff changeset
   175
    by simp
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   176
  show "lless (| carrier = UNIV::int set, eq = op =, le = op \<le> |) x y = (x < y)"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   177
    by (simp add: lless_def) auto
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   178
qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   179
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   180
interpretation int (* FIXME [unfolded UNIV] *) :
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   181
  lattice "(| carrier = UNIV::int set, eq = op =, le = op \<le> |)"
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   182
  where "join (| carrier = UNIV::int set, eq = op =, le = op \<le> |) x y = max x y"
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   183
    and "meet (| carrier = UNIV::int set, eq = op =, le = op \<le> |) x y = min x y"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   184
proof -
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 25919
diff changeset
   185
  let ?Z = "(| carrier = UNIV::int set, eq = op =, le = op \<le> |)"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   186
  show "lattice ?Z"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   187
    apply unfold_locales
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   188
    apply (simp add: least_def Upper_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   189
    apply arith
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   190
    apply (simp add: greatest_def Lower_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   191
    apply arith
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   192
    done
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   193
  then interpret int: lattice "?Z" .
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   194
  show "join ?Z x y = max x y"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   195
    apply (rule int.joinI)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   196
    apply (simp_all add: least_def Upper_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   197
    apply arith
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   198
    done
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   199
  show "meet ?Z x y = min x y"
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   200
    apply (rule int.meetI)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   201
    apply (simp_all add: greatest_def Lower_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   202
    apply arith
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   203
    done
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   204
qed
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   205
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 29948
diff changeset
   206
interpretation int (* [unfolded UNIV] *) :
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   207
  total_order "(| carrier = UNIV::int set, eq = op =, le = op \<le> |)"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28524
diff changeset
   208
  proof qed clarsimp
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   209
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   210
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
   211
subsection {* Generated Ideals of @{text "\<Z>"} *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   212
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   213
lemma int_Idl:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   214
  "Idl\<^bsub>\<Z>\<^esub> {a} = {x * a | x. True}"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   215
  apply (subst int.cgenideal_eq_genideal[symmetric]) apply (simp add: int_ring_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   216
  apply (simp add: cgenideal_def int_ring_def)
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   217
  done
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   218
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   219
lemma multiples_principalideal:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   220
  "principalideal {x * a | x. True } \<Z>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   221
apply (subst int_Idl[symmetric], rule principalidealI)
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   222
 apply (rule int.genideal_ideal, simp)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   223
apply fast
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   224
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   225
29700
22faf21db3df added some simp rules
nipkow
parents: 29424
diff changeset
   226
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   227
lemma prime_primeideal:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   228
  assumes prime: "prime (nat p)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   229
  shows "primeideal (Idl\<^bsub>\<Z>\<^esub> {p}) \<Z>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   230
apply (rule primeidealI)
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   231
   apply (rule int.genideal_ideal, simp)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   232
  apply (rule int_is_cring)
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   233
 apply (simp add: int.cgenideal_eq_genideal[symmetric] cgenideal_def)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   234
 apply (simp add: int_ring_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   235
 apply clarsimp defer 1
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   236
 apply (simp add: int.cgenideal_eq_genideal[symmetric] cgenideal_def)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   237
 apply (simp add: int_ring_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   238
 apply (elim exE)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   239
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   240
  fix a b x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   241
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   242
  from prime
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   243
      have ppos: "0 <= p" by (simp add: prime_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   244
  have unnat: "!!x. nat p dvd nat (abs x) ==> p dvd x"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   245
  proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   246
    fix x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   247
    assume "nat p dvd nat (abs x)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   248
    hence "int (nat p) dvd x" by (simp add: int_dvd_iff[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   249
    thus "p dvd x" by (simp add: ppos)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   250
  qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   251
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
  assume "a * b = x * p"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   254
  hence "p dvd a * b" by simp
29700
22faf21db3df added some simp rules
nipkow
parents: 29424
diff changeset
   255
  hence "nat p dvd nat (abs (a * b))" using ppos by (simp add: nat_dvd_iff)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   256
  hence "nat p dvd (nat (abs a) * nat (abs b))" by (simp add: nat_abs_mult_distrib)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   257
  hence "nat p dvd nat (abs a) | nat p dvd nat (abs b)" by (rule prime_dvd_mult[OF prime])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   258
  hence "p dvd a | p dvd b" by (fast intro: unnat)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   259
  thus "(EX x. a = x * p) | (EX x. b = x * p)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   260
  proof
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   261
    assume "p dvd a"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   262
    hence "EX x. a = p * x" by (simp add: dvd_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   263
    from this obtain x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   264
        where "a = p * x" by fast
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   265
    hence "a = x * p" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   266
    hence "EX x. a = x * p" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   267
    thus "(EX x. a = x * p) | (EX x. b = x * p)" ..
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   268
  next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   269
    assume "p dvd b"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   270
    hence "EX x. b = p * x" by (simp add: dvd_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   271
    from this obtain x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   272
        where "b = p * x" by fast
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   273
    hence "b = x * p" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   274
    hence "EX x. b = x * p" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   275
    thus "(EX x. a = x * p) | (EX x. b = x * p)" ..
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   276
  qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   277
next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   278
  assume "UNIV = {uu. EX x. uu = x * p}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   279
  from this obtain x 
29242
e190bc2a5399 More porting to new locales
ballarin
parents: 29237
diff changeset
   280
      where "1 = x * p" by best
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   281
  from this [symmetric]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   282
      have "p * x = 1" by (subst zmult_commute)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   283
  hence "\<bar>p * x\<bar> = 1" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   284
  hence "\<bar>p\<bar> = 1" by (rule abs_zmult_eq_1)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   285
  from this and prime
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   286
      show "False" by (simp add: prime_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   287
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   288
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   289
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
   290
subsection {* Ideals and Divisibility *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   291
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   292
lemma int_Idl_subset_ideal:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   293
  "Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l} = (k \<in> Idl\<^bsub>\<Z>\<^esub> {l})"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   294
by (rule int.Idl_subset_ideal', simp+)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   295
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   296
lemma Idl_subset_eq_dvd:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   297
  "(Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l}) = (l dvd k)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   298
apply (subst int_Idl_subset_ideal, subst int_Idl, simp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   299
apply (rule, clarify)
29424
948d616959e4 fixed proof involving dvd;
wenzelm
parents: 29242
diff changeset
   300
apply (simp add: dvd_def)
948d616959e4 fixed proof involving dvd;
wenzelm
parents: 29242
diff changeset
   301
apply (simp add: dvd_def mult_ac)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   302
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   303
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   304
lemma dvds_eq_Idl:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   305
  "(l dvd k \<and> k dvd l) = (Idl\<^bsub>\<Z>\<^esub> {k} = Idl\<^bsub>\<Z>\<^esub> {l})"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   306
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   307
  have a: "l dvd k = (Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l})" by (rule Idl_subset_eq_dvd[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   308
  have b: "k dvd l = (Idl\<^bsub>\<Z>\<^esub> {l} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {k})" by (rule Idl_subset_eq_dvd[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   309
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   310
  have "(l dvd k \<and> k dvd l) = ((Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l}) \<and> (Idl\<^bsub>\<Z>\<^esub> {l} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {k}))"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   311
  by (subst a, subst b, simp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   312
  also have "((Idl\<^bsub>\<Z>\<^esub> {k} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {l}) \<and> (Idl\<^bsub>\<Z>\<^esub> {l} \<subseteq> Idl\<^bsub>\<Z>\<^esub> {k})) = (Idl\<^bsub>\<Z>\<^esub> {k} = Idl\<^bsub>\<Z>\<^esub> {l})" by (rule, fast+)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   313
  finally
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   314
    show ?thesis .
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
lemma Idl_eq_abs:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   318
  "(Idl\<^bsub>\<Z>\<^esub> {k} = Idl\<^bsub>\<Z>\<^esub> {l}) = (abs l = abs k)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   319
apply (subst dvds_eq_abseq[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   320
apply (rule dvds_eq_Idl[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   321
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   322
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   323
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
   324
subsection {* Ideals and the Modulus *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   325
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33676
diff changeset
   326
definition ZMod :: "int => int => int set" where
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   327
  "ZMod k r == (Idl\<^bsub>\<Z>\<^esub> {k}) +>\<^bsub>\<Z>\<^esub> r"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   328
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   329
lemmas ZMod_defs =
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   330
  ZMod_def genideal_def
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   331
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   332
lemma rcos_zfact:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   333
  assumes kIl: "k \<in> ZMod l r"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   334
  shows "EX x. k = x * l + r"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   335
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   336
  from kIl[unfolded ZMod_def]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   337
      have "\<exists>xl\<in>Idl\<^bsub>\<Z>\<^esub> {l}. k = xl + r" by (simp add: a_r_coset_defs int_ring_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   338
  from this obtain xl
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   339
      where xl: "xl \<in> Idl\<^bsub>\<Z>\<^esub> {l}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   340
      and k: "k = xl + r"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   341
      by auto
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   342
  from xl obtain x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   343
      where "xl = x * l"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   344
      by (simp add: int_Idl, fast)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   345
  from k and this
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   346
      have "k = x * l + r" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   347
  thus "\<exists>x. k = x * l + r" ..
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   348
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   349
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   350
lemma ZMod_imp_zmod:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   351
  assumes zmods: "ZMod m a = ZMod m b"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   352
  shows "a mod m = b mod m"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   353
proof -
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   354
  interpret ideal "Idl\<^bsub>\<Z>\<^esub> {m}" \<Z> by (rule int.genideal_ideal, fast)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   355
  from zmods
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   356
      have "b \<in> ZMod m a"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   357
      unfolding ZMod_def
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   358
      by (simp add: a_repr_independenceD)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   359
  from this
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   360
      have "EX x. b = x * m + a" by (rule rcos_zfact)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   361
  from this obtain x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   362
      where "b = x * m + a"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   363
      by fast
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   364
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   365
  hence "b mod m = (x * m + a) mod m" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   366
  also
29948
cdf12a1cb963 Cleaned up IntDiv and removed subsumed lemmas.
nipkow
parents: 29700
diff changeset
   367
      have "\<dots> = ((x * m) mod m) + (a mod m)" by (simp add: mod_add_eq)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   368
  also
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   369
      have "\<dots> = a mod m" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   370
  finally
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   371
      have "b mod m = a mod m" .
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   372
  thus "a mod m = b mod m" ..
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   373
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   374
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   375
lemma ZMod_mod:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   376
  shows "ZMod m a = ZMod m (a mod m)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   377
proof -
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   378
  interpret ideal "Idl\<^bsub>\<Z>\<^esub> {m}" \<Z> by (rule int.genideal_ideal, fast)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   379
  show ?thesis
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   380
      unfolding ZMod_def
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   381
  apply (rule a_repr_independence'[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   382
  apply (simp add: int_Idl a_r_coset_defs)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   383
  apply (simp add: int_ring_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   384
  proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   385
    have "a = m * (a div m) + (a mod m)" by (simp add: zmod_zdiv_equality)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   386
    hence "a = (a div m) * m + (a mod m)" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   387
    thus "\<exists>h. (\<exists>x. h = x * m) \<and> a = h + a mod m" by fast
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   388
  qed simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   389
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   390
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   391
lemma zmod_imp_ZMod:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   392
  assumes modeq: "a mod m = b mod m"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   393
  shows "ZMod m a = ZMod m b"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   394
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   395
  have "ZMod m a = ZMod m (a mod m)" by (rule ZMod_mod)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   396
  also have "\<dots> = ZMod m (b mod m)" by (simp add: modeq[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   397
  also have "\<dots> = ZMod m b" by (rule ZMod_mod[symmetric])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   398
  finally show ?thesis .
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   399
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   400
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   401
corollary ZMod_eq_mod:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   402
  shows "(ZMod m a = ZMod m b) = (a mod m = b mod m)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   403
by (rule, erule ZMod_imp_zmod, erule zmod_imp_ZMod)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   404
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   405
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
   406
subsection {* Factorization *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   407
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 33676
diff changeset
   408
definition ZFact :: "int \<Rightarrow> int set ring" where
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   409
  "ZFact k == \<Z> Quot (Idl\<^bsub>\<Z>\<^esub> {k})"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   410
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   411
lemmas ZFact_defs = ZFact_def FactRing_def
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   412
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   413
lemma ZFact_is_cring:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   414
  shows "cring (ZFact k)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   415
apply (unfold ZFact_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   416
apply (rule ideal.quotient_is_cring)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   417
 apply (intro ring.genideal_ideal)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   418
  apply (simp add: cring.axioms[OF int_is_cring] ring.intro)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   419
 apply simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   420
apply (rule int_is_cring)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   421
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   422
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   423
lemma ZFact_zero:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   424
  "carrier (ZFact 0) = (\<Union>a. {{a}})"
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   425
apply (insert int.genideal_zero)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   426
apply (simp add: ZFact_defs A_RCOSETS_defs r_coset_def int_ring_def ring_record_simps)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   427
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   428
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   429
lemma ZFact_one:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   430
  "carrier (ZFact 1) = {UNIV}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   431
apply (simp only: ZFact_defs A_RCOSETS_defs r_coset_def int_ring_def ring_record_simps)
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 22063
diff changeset
   432
apply (subst int.genideal_one[unfolded int_ring_def, simplified ring_record_simps])
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   433
apply (rule, rule, clarsimp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   434
 apply (rule, rule, clarsimp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   435
 apply (rule, clarsimp, arith)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   436
apply (rule, clarsimp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   437
apply (rule exI[of _ "0"], clarsimp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   438
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   439
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   440
lemma ZFact_prime_is_domain:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   441
  assumes pprime: "prime (nat p)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   442
  shows "domain (ZFact p)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   443
apply (unfold ZFact_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   444
apply (rule primeideal.quotient_is_domain)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   445
apply (rule prime_primeideal[OF pprime])
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   446
done
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   447
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   448
end