src/HOL/Algebra/Divisibility.thy
author nipkow
Fri, 13 Nov 2009 14:14:04 +0100
changeset 33657 a4179bf442d1
parent 32960 69916a850301
child 35272 c283ae736bea
permissions -rw-r--r--
renamed lemmas "anti_sym" -> "antisym"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
     1
(*
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
     2
  Title:     Divisibility in monoids and rings
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
     3
  Author:    Clemens Ballarin, started 18 July 2008
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
     4
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
     5
Based on work by Stephan Hohe.
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
     6
*)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
     7
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
     8
theory Divisibility
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
     9
imports Permutation Coset Group
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    10
begin
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    11
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
    12
section {* Factorial Monoids *}
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
    13
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
    14
subsection {* Monoids with Cancellation Law *}
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    15
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    16
locale monoid_cancel = monoid +
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    17
  assumes l_cancel: 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    18
          "\<lbrakk>c \<otimes> a = c \<otimes> b; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    19
      and r_cancel: 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    20
          "\<lbrakk>a \<otimes> c = b \<otimes> c; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    21
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    22
lemma (in monoid) monoid_cancelI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    23
  assumes l_cancel: 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    24
          "\<And>a b c. \<lbrakk>c \<otimes> a = c \<otimes> b; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    25
      and r_cancel: 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    26
          "\<And>a b c. \<lbrakk>a \<otimes> c = b \<otimes> c; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    27
  shows "monoid_cancel G"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28600
diff changeset
    28
  proof qed fact+
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    29
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    30
lemma (in monoid_cancel) is_monoid_cancel:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    31
  "monoid_cancel G"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28600
diff changeset
    32
  ..
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    33
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
    34
sublocale group \<subseteq> monoid_cancel
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28600
diff changeset
    35
  proof qed simp+
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    36
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    37
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    38
locale comm_monoid_cancel = monoid_cancel + comm_monoid
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    39
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    40
lemma comm_monoid_cancelI:
28599
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    41
  fixes G (structure)
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    42
  assumes "comm_monoid G"
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    43
  assumes cancel: 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    44
          "\<And>a b c. \<lbrakk>a \<otimes> c = b \<otimes> c; a \<in> carrier G; b \<in> carrier G; c \<in> carrier G\<rbrakk> \<Longrightarrow> a = b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    45
  shows "comm_monoid_cancel G"
28599
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    46
proof -
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
    47
  interpret comm_monoid G by fact
28599
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    48
  show "comm_monoid_cancel G"
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    49
    apply unfold_locales
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    50
    apply (subgoal_tac "a \<otimes> c = b \<otimes> c")
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    51
    apply (iprover intro: cancel)
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    52
    apply (simp add: m_comm)
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    53
    apply (iprover intro: cancel)
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    54
    done
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
    55
qed
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    56
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    57
lemma (in comm_monoid_cancel) is_comm_monoid_cancel:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    58
  "comm_monoid_cancel G"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28600
diff changeset
    59
  by intro_locales
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    60
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
    61
sublocale comm_group \<subseteq> comm_monoid_cancel
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28600
diff changeset
    62
  ..
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    63
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    64
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
    65
subsection {* Products of Units in Monoids *}
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    66
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    67
lemma (in monoid) Units_m_closed[simp, intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    68
  assumes h1unit: "h1 \<in> Units G" and h2unit: "h2 \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    69
  shows "h1 \<otimes> h2 \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    70
unfolding Units_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    71
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    72
apply safe
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    73
apply fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    74
apply (intro bexI[of _ "inv h2 \<otimes> inv h1"], safe)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    75
  apply (simp add: m_assoc Units_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    76
  apply (simp add: m_assoc[symmetric] Units_closed Units_l_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    77
 apply (simp add: m_assoc Units_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    78
 apply (simp add: m_assoc[symmetric] Units_closed Units_r_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    79
apply fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    80
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    81
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    82
lemma (in monoid) prod_unit_l:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    83
  assumes abunit[simp]: "a \<otimes> b \<in> Units G" and aunit[simp]: "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    84
    and carr[simp]: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    85
  shows "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    86
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    87
  have c: "inv (a \<otimes> b) \<otimes> a \<in> carrier G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    88
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    89
  have "(inv (a \<otimes> b) \<otimes> a) \<otimes> b = inv (a \<otimes> b) \<otimes> (a \<otimes> b)" by (simp add: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    90
  also have "\<dots> = \<one>" by (simp add: Units_l_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    91
  finally have li: "(inv (a \<otimes> b) \<otimes> a) \<otimes> b = \<one>" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    92
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    93
  have "\<one> = inv a \<otimes> a" by (simp add: Units_l_inv[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    94
  also have "\<dots> = inv a \<otimes> \<one> \<otimes> a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    95
  also have "\<dots> = inv a \<otimes> ((a \<otimes> b) \<otimes> inv (a \<otimes> b)) \<otimes> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    96
       by (simp add: Units_r_inv[OF abunit, symmetric] del: Units_r_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    97
  also have "\<dots> = ((inv a \<otimes> a) \<otimes> b) \<otimes> inv (a \<otimes> b) \<otimes> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    98
    by (simp add: m_assoc del: Units_l_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
    99
  also have "\<dots> = b \<otimes> inv (a \<otimes> b) \<otimes> a" by (simp add: Units_l_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   100
  also have "\<dots> = b \<otimes> (inv (a \<otimes> b) \<otimes> a)" by (simp add: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   101
  finally have ri: "b \<otimes> (inv (a \<otimes> b) \<otimes> a) = \<one> " by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   102
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   103
  from c li ri
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   104
      show "b \<in> Units G" by (simp add: Units_def, fast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   105
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   106
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   107
lemma (in monoid) prod_unit_r:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   108
  assumes abunit[simp]: "a \<otimes> b \<in> Units G" and bunit[simp]: "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   109
    and carr[simp]: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   110
  shows "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   111
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   112
  have c: "b \<otimes> inv (a \<otimes> b) \<in> carrier G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   113
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   114
  have "a \<otimes> (b \<otimes> inv (a \<otimes> b)) = (a \<otimes> b) \<otimes> inv (a \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   115
    by (simp add: m_assoc del: Units_r_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   116
  also have "\<dots> = \<one>" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   117
  finally have li: "a \<otimes> (b \<otimes> inv (a \<otimes> b)) = \<one>" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   118
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   119
  have "\<one> = b \<otimes> inv b" by (simp add: Units_r_inv[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   120
  also have "\<dots> = b \<otimes> \<one> \<otimes> inv b" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   121
  also have "\<dots> = b \<otimes> (inv (a \<otimes> b) \<otimes> (a \<otimes> b)) \<otimes> inv b" 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   122
       by (simp add: Units_l_inv[OF abunit, symmetric] del: Units_l_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   123
  also have "\<dots> = (b \<otimes> inv (a \<otimes> b) \<otimes> a) \<otimes> (b \<otimes> inv b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   124
    by (simp add: m_assoc del: Units_l_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   125
  also have "\<dots> = b \<otimes> inv (a \<otimes> b) \<otimes> a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   126
  finally have ri: "(b \<otimes> inv (a \<otimes> b)) \<otimes> a = \<one> " by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   127
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   128
  from c li ri
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   129
      show "a \<in> Units G" by (simp add: Units_def, fast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   130
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   131
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   132
lemma (in comm_monoid) unit_factor:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   133
  assumes abunit: "a \<otimes> b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   134
    and [simp]: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   135
  shows "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   136
using abunit[simplified Units_def]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   137
proof clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   138
  fix i
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   139
  assume [simp]: "i \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   140
    and li: "i \<otimes> (a \<otimes> b) = \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   141
    and ri: "a \<otimes> b \<otimes> i = \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   142
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   143
  have carr': "b \<otimes> i \<in> carrier G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   144
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   145
  have "(b \<otimes> i) \<otimes> a = (i \<otimes> b) \<otimes> a" by (simp add: m_comm)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   146
  also have "\<dots> = i \<otimes> (b \<otimes> a)" by (simp add: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   147
  also have "\<dots> = i \<otimes> (a \<otimes> b)" by (simp add: m_comm)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   148
  also note li
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   149
  finally have li': "(b \<otimes> i) \<otimes> a = \<one>" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   150
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   151
  have "a \<otimes> (b \<otimes> i) = a \<otimes> b \<otimes> i" by (simp add: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   152
  also note ri
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   153
  finally have ri': "a \<otimes> (b \<otimes> i) = \<one>" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   154
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   155
  from carr' li' ri'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   156
      show "a \<in> Units G" by (simp add: Units_def, fast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   157
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   158
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
   159
subsection {* Divisibility and Association *}
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   160
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   161
subsubsection {* Function definitions *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   162
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   163
constdefs (structure G)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   164
  factor :: "[_, 'a, 'a] \<Rightarrow> bool" (infix "divides\<index>" 65)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   165
  "a divides b == \<exists>c\<in>carrier G. b = a \<otimes> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   166
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   167
constdefs (structure G)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   168
  associated :: "[_, 'a, 'a] => bool" (infix "\<sim>\<index>" 55)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   169
  "a \<sim> b == a divides b \<and> b divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   170
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   171
abbreviation
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   172
  "division_rel G == \<lparr>carrier = carrier G, eq = op \<sim>\<^bsub>G\<^esub>, le = op divides\<^bsub>G\<^esub>\<rparr>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   173
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   174
constdefs (structure G)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   175
  properfactor :: "[_, 'a, 'a] \<Rightarrow> bool"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   176
  "properfactor G a b == a divides b \<and> \<not>(b divides a)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   177
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   178
constdefs (structure G)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   179
  irreducible :: "[_, 'a] \<Rightarrow> bool"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   180
  "irreducible G a == a \<notin> Units G \<and> (\<forall>b\<in>carrier G. properfactor G b a \<longrightarrow> b \<in> Units G)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   181
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   182
constdefs (structure G)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   183
  prime :: "[_, 'a] \<Rightarrow> bool"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   184
  "prime G p == p \<notin> Units G \<and> 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   185
                (\<forall>a\<in>carrier G. \<forall>b\<in>carrier G. p divides (a \<otimes> b) \<longrightarrow> p divides a \<or> p divides b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   186
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   187
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   188
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   189
subsubsection {* Divisibility *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   190
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   191
lemma dividesI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   192
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   193
  assumes carr: "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   194
    and p: "b = a \<otimes> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   195
  shows "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   196
unfolding factor_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   197
using assms by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   198
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   199
lemma dividesI' [intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   200
   fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   201
  assumes p: "b = a \<otimes> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   202
    and carr: "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   203
  shows "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   204
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   205
by (fast intro: dividesI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   206
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   207
lemma dividesD:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   208
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   209
  assumes "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   210
  shows "\<exists>c\<in>carrier G. b = a \<otimes> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   211
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   212
unfolding factor_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   213
by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   214
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   215
lemma dividesE [elim]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   216
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   217
  assumes d: "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   218
    and elim: "\<And>c. \<lbrakk>b = a \<otimes> c; c \<in> carrier G\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   219
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   220
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   221
  from dividesD[OF d]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   222
      obtain c
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   223
      where "c\<in>carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   224
      and "b = a \<otimes> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   225
      by auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   226
  thus "P" by (elim elim)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   227
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   228
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   229
lemma (in monoid) divides_refl[simp, intro!]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   230
  assumes carr: "a \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   231
  shows "a divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   232
apply (intro dividesI[of "\<one>"])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   233
apply (simp, simp add: carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   234
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   235
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   236
lemma (in monoid) divides_trans [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   237
  assumes dvds: "a divides b"  "b divides c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   238
    and acarr: "a \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   239
  shows "a divides c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   240
using dvds[THEN dividesD]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   241
by (blast intro: dividesI m_assoc acarr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   242
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   243
lemma (in monoid) divides_mult_lI [intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   244
  assumes ab: "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   245
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   246
  shows "(c \<otimes> a) divides (c \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   247
using ab
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   248
apply (elim dividesE, simp add: m_assoc[symmetric] carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   249
apply (fast intro: dividesI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   250
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   251
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   252
lemma (in monoid_cancel) divides_mult_l [simp]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   253
  assumes carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   254
  shows "(c \<otimes> a) divides (c \<otimes> b) = a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   255
apply safe
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   256
 apply (elim dividesE, intro dividesI, assumption)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   257
 apply (rule l_cancel[of c])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   258
    apply (simp add: m_assoc carr)+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   259
apply (fast intro: divides_mult_lI carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   260
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   261
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   262
lemma (in comm_monoid) divides_mult_rI [intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   263
  assumes ab: "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   264
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   265
  shows "(a \<otimes> c) divides (b \<otimes> c)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   266
using carr ab
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   267
apply (simp add: m_comm[of a c] m_comm[of b c])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   268
apply (rule divides_mult_lI, assumption+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   269
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   270
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   271
lemma (in comm_monoid_cancel) divides_mult_r [simp]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   272
  assumes carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   273
  shows "(a \<otimes> c) divides (b \<otimes> c) = a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   274
using carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   275
by (simp add: m_comm[of a c] m_comm[of b c])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   276
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   277
lemma (in monoid) divides_prod_r:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   278
  assumes ab: "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   279
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   280
  shows "a divides (b \<otimes> c)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   281
using ab carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   282
by (fast intro: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   283
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   284
lemma (in comm_monoid) divides_prod_l:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   285
  assumes carr[intro]: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   286
    and ab: "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   287
  shows "a divides (c \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   288
using ab carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   289
apply (simp add: m_comm[of c b])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   290
apply (fast intro: divides_prod_r)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   291
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   292
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   293
lemma (in monoid) unit_divides:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   294
  assumes uunit: "u \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   295
      and acarr: "a \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   296
  shows "u divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   297
proof (intro dividesI[of "(inv u) \<otimes> a"], fast intro: uunit acarr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   298
  from uunit acarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   299
      have xcarr: "inv u \<otimes> a \<in> carrier G" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   300
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   301
  from uunit acarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   302
       have "u \<otimes> (inv u \<otimes> a) = (u \<otimes> inv u) \<otimes> a" by (fast intro: m_assoc[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   303
  also have "\<dots> = \<one> \<otimes> a" by (simp add: Units_r_inv[OF uunit])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   304
  also from acarr 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   305
       have "\<dots> = a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   306
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   307
       show "a = u \<otimes> (inv u \<otimes> a)" ..
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   308
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   309
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   310
lemma (in comm_monoid) divides_unit:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   311
  assumes udvd: "a divides u"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   312
      and  carr: "a \<in> carrier G"  "u \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   313
  shows "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   314
using udvd carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   315
by (blast intro: unit_factor)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   316
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   317
lemma (in comm_monoid) Unit_eq_dividesone:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   318
  assumes ucarr: "u \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   319
  shows "u \<in> Units G = u divides \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   320
using ucarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   321
by (fast dest: divides_unit intro: unit_divides)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   322
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   323
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   324
subsubsection {* Association *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   325
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   326
lemma associatedI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   327
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   328
  assumes "a divides b"  "b divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   329
  shows "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   330
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   331
by (simp add: associated_def)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   332
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   333
lemma (in monoid) associatedI2:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   334
  assumes uunit[simp]: "u \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   335
    and a: "a = b \<otimes> u"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   336
    and bcarr[simp]: "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   337
  shows "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   338
using uunit bcarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   339
unfolding a
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   340
apply (intro associatedI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   341
 apply (rule dividesI[of "inv u"], simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   342
 apply (simp add: m_assoc Units_closed Units_r_inv)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   343
apply fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   344
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   345
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   346
lemma (in monoid) associatedI2':
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   347
  assumes a: "a = b \<otimes> u"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   348
    and uunit: "u \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   349
    and bcarr: "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   350
  shows "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   351
using assms by (intro associatedI2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   352
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   353
lemma associatedD:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   354
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   355
  assumes "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   356
  shows "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   357
using assms by (simp add: associated_def)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   358
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   359
lemma (in monoid_cancel) associatedD2:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   360
  assumes assoc: "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   361
    and carr: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   362
  shows "\<exists>u\<in>Units G. a = b \<otimes> u"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   363
using assoc
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   364
unfolding associated_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   365
proof clarify
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   366
  assume "b divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   367
  hence "\<exists>u\<in>carrier G. a = b \<otimes> u" by (rule dividesD)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   368
  from this obtain u
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   369
      where ucarr: "u \<in> carrier G" and a: "a = b \<otimes> u"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   370
      by auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   371
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   372
  assume "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   373
  hence "\<exists>u'\<in>carrier G. b = a \<otimes> u'" by (rule dividesD)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   374
  from this obtain u'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   375
      where u'carr: "u' \<in> carrier G" and b: "b = a \<otimes> u'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   376
      by auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   377
  note carr = carr ucarr u'carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   378
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   379
  from carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   380
       have "a \<otimes> \<one> = a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   381
  also have "\<dots> = b \<otimes> u" by (simp add: a)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   382
  also have "\<dots> = a \<otimes> u' \<otimes> u" by (simp add: b)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   383
  also from carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   384
       have "\<dots> = a \<otimes> (u' \<otimes> u)" by (simp add: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   385
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   386
       have "a \<otimes> \<one> = a \<otimes> (u' \<otimes> u)" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   387
  with carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   388
      have u1: "\<one> = u' \<otimes> u" by (fast dest: l_cancel)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   389
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   390
  from carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   391
       have "b \<otimes> \<one> = b" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   392
  also have "\<dots> = a \<otimes> u'" by (simp add: b)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   393
  also have "\<dots> = b \<otimes> u \<otimes> u'" by (simp add: a)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   394
  also from carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   395
       have "\<dots> = b \<otimes> (u \<otimes> u')" by (simp add: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   396
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   397
       have "b \<otimes> \<one> = b \<otimes> (u \<otimes> u')" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   398
  with carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   399
      have u2: "\<one> = u \<otimes> u'" by (fast dest: l_cancel)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   400
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   401
  from u'carr u1[symmetric] u2[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   402
      have "\<exists>u'\<in>carrier G. u' \<otimes> u = \<one> \<and> u \<otimes> u' = \<one>" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   403
  hence "u \<in> Units G" by (simp add: Units_def ucarr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   404
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   405
  from ucarr this a
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   406
      show "\<exists>u\<in>Units G. a = b \<otimes> u" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   407
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   408
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   409
lemma associatedE:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   410
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   411
  assumes assoc: "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   412
    and e: "\<lbrakk>a divides b; b divides a\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   413
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   414
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   415
  from assoc
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   416
      have "a divides b"  "b divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   417
      by (simp add: associated_def)+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   418
  thus "P" by (elim e)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   419
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   420
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   421
lemma (in monoid_cancel) associatedE2:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   422
  assumes assoc: "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   423
    and e: "\<And>u. \<lbrakk>a = b \<otimes> u; u \<in> Units G\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   424
    and carr: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   425
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   426
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   427
  from assoc and carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   428
      have "\<exists>u\<in>Units G. a = b \<otimes> u" by (rule associatedD2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   429
  from this obtain u
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   430
      where "u \<in> Units G"  "a = b \<otimes> u"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   431
      by auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   432
  thus "P" by (elim e)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   433
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   434
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   435
lemma (in monoid) associated_refl [simp, intro!]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   436
  assumes "a \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   437
  shows "a \<sim> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   438
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   439
by (fast intro: associatedI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   440
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   441
lemma (in monoid) associated_sym [sym]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   442
  assumes "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   443
    and "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   444
  shows "b \<sim> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   445
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   446
by (iprover intro: associatedI elim: associatedE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   447
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   448
lemma (in monoid) associated_trans [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   449
  assumes "a \<sim> b"  "b \<sim> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   450
    and "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   451
  shows "a \<sim> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   452
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   453
by (iprover intro: associatedI divides_trans elim: associatedE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   454
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   455
lemma (in monoid) division_equiv [intro, simp]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   456
  "equivalence (division_rel G)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   457
  apply unfold_locales
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   458
  apply simp_all
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   459
  apply (rule associated_sym, assumption+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   460
  apply (iprover intro: associated_trans)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   461
  done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   462
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   463
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   464
subsubsection {* Division and associativity *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   465
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   466
lemma divides_antisym:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   467
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   468
  assumes "a divides b"  "b divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   469
    and "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   470
  shows "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   471
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   472
by (fast intro: associatedI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   473
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   474
lemma (in monoid) divides_cong_l [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   475
  assumes xx': "x \<sim> x'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   476
    and xdvdy: "x' divides y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   477
    and carr [simp]: "x \<in> carrier G"  "x' \<in> carrier G"  "y \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   478
  shows "x divides y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   479
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   480
  from xx'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   481
       have "x divides x'" by (simp add: associatedD)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   482
  also note xdvdy
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   483
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   484
       show "x divides y" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   485
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   486
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   487
lemma (in monoid) divides_cong_r [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   488
  assumes xdvdy: "x divides y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   489
    and yy': "y \<sim> y'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   490
    and carr[simp]: "x \<in> carrier G"  "y \<in> carrier G"  "y' \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   491
  shows "x divides y'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   492
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   493
  note xdvdy
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   494
  also from yy'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   495
       have "y divides y'" by (simp add: associatedD)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   496
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   497
       show "x divides y'" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   498
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   499
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   500
lemma (in monoid) division_weak_partial_order [simp, intro!]:
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   501
  "weak_partial_order (division_rel G)"
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   502
  apply unfold_locales
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   503
  apply simp_all
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   504
  apply (simp add: associated_sym)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   505
  apply (blast intro: associated_trans)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   506
  apply (simp add: divides_antisym)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   507
  apply (blast intro: divides_trans)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   508
  apply (blast intro: divides_cong_l divides_cong_r associated_sym)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   509
  done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   510
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   511
    
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   512
subsubsection {* Multiplication and associativity *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   513
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   514
lemma (in monoid_cancel) mult_cong_r:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   515
  assumes "b \<sim> b'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   516
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "b' \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   517
  shows "a \<otimes> b \<sim> a \<otimes> b'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   518
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   519
apply (elim associatedE2, intro associatedI2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   520
apply (auto intro: m_assoc[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   521
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   522
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   523
lemma (in comm_monoid_cancel) mult_cong_l:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   524
  assumes "a \<sim> a'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   525
    and carr: "a \<in> carrier G"  "a' \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   526
  shows "a \<otimes> b \<sim> a' \<otimes> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   527
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   528
apply (elim associatedE2, intro associatedI2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   529
    apply assumption
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   530
   apply (simp add: m_assoc Units_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   531
   apply (simp add: m_comm Units_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   532
  apply simp+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   533
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   534
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   535
lemma (in monoid_cancel) assoc_l_cancel:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   536
  assumes carr: "a \<in> carrier G"  "b \<in> carrier G"  "b' \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   537
    and "a \<otimes> b \<sim> a \<otimes> b'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   538
  shows "b \<sim> b'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   539
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   540
apply (elim associatedE2, intro associatedI2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   541
    apply assumption
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   542
   apply (rule l_cancel[of a])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   543
      apply (simp add: m_assoc Units_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   544
     apply fast+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   545
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   546
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   547
lemma (in comm_monoid_cancel) assoc_r_cancel:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   548
  assumes "a \<otimes> b \<sim> a' \<otimes> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   549
    and carr: "a \<in> carrier G"  "a' \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   550
  shows "a \<sim> a'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   551
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   552
apply (elim associatedE2, intro associatedI2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   553
    apply assumption
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   554
   apply (rule r_cancel[of a b])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   555
      apply (simp add: m_assoc Units_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   556
      apply (simp add: m_comm Units_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   557
     apply fast+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   558
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   559
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   560
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   561
subsubsection {* Units *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   562
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   563
lemma (in monoid_cancel) assoc_unit_l [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   564
  assumes asc: "a \<sim> b" and bunit: "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   565
    and carr: "a \<in> carrier G" 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   566
  shows "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   567
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   568
by (fast elim: associatedE2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   569
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   570
lemma (in monoid_cancel) assoc_unit_r [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   571
  assumes aunit: "a \<in> Units G" and asc: "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   572
    and bcarr: "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   573
  shows "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   574
using aunit bcarr associated_sym[OF asc]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   575
by (blast intro: assoc_unit_l)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   576
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   577
lemma (in comm_monoid) Units_cong:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   578
  assumes aunit: "a \<in> Units G" and asc: "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   579
    and bcarr: "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   580
  shows "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   581
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   582
by (blast intro: divides_unit elim: associatedE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   583
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   584
lemma (in monoid) Units_assoc:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   585
  assumes units: "a \<in> Units G"  "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   586
  shows "a \<sim> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   587
using units
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   588
by (fast intro: associatedI unit_divides)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   589
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   590
lemma (in monoid) Units_are_ones:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   591
  "Units G {.=}\<^bsub>(division_rel G)\<^esub> {\<one>}"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   592
apply (simp add: set_eq_def elem_def, rule, simp_all)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   593
proof clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   594
  fix a
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   595
  assume aunit: "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   596
  show "a \<sim> \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   597
  apply (rule associatedI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   598
   apply (fast intro: dividesI[of "inv a"] aunit Units_r_inv[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   599
  apply (fast intro: dividesI[of "a"] l_one[symmetric] Units_closed[OF aunit])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   600
  done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   601
next
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   602
  have "\<one> \<in> Units G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   603
  moreover have "\<one> \<sim> \<one>" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   604
  ultimately show "\<exists>a \<in> Units G. \<one> \<sim> a" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   605
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   606
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   607
lemma (in comm_monoid) Units_Lower:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   608
  "Units G = Lower (division_rel G) (carrier G)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   609
apply (simp add: Units_def Lower_def)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   610
apply (rule, rule)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   611
 apply clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   612
  apply (rule unit_divides)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   613
   apply (unfold Units_def, fast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   614
  apply assumption
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   615
apply clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   616
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   617
  fix x
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   618
  assume xcarr: "x \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   619
  assume r[rule_format]: "\<forall>y. y \<in> carrier G \<longrightarrow> x divides y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   620
  have "\<one> \<in> carrier G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   621
  hence "x divides \<one>" by (rule r)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   622
  hence "\<exists>x'\<in>carrier G. \<one> = x \<otimes> x'" by (rule dividesE, fast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   623
  from this obtain x'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   624
      where x'carr: "x' \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   625
      and xx': "\<one> = x \<otimes> x'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   626
      by auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   627
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   628
  note xx'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   629
  also with xcarr x'carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   630
       have "\<dots> = x' \<otimes> x" by (simp add: m_comm)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   631
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   632
       have "\<one> = x' \<otimes> x" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   633
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   634
  from x'carr xx'[symmetric] this[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   635
      show "\<exists>y\<in>carrier G. y \<otimes> x = \<one> \<and> x \<otimes> y = \<one>" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   636
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   637
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   638
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   639
subsubsection {* Proper factors *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   640
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   641
lemma properfactorI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   642
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   643
  assumes "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   644
    and "\<not>(b divides a)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   645
  shows "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   646
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   647
unfolding properfactor_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   648
by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   649
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   650
lemma properfactorI2:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   651
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   652
  assumes advdb: "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   653
    and neq: "\<not>(a \<sim> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   654
  shows "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   655
apply (rule properfactorI, rule advdb)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   656
proof (rule ccontr, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   657
  assume "b divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   658
  with advdb have "a \<sim> b" by (rule associatedI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   659
  with neq show "False" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   660
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   661
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   662
lemma (in comm_monoid_cancel) properfactorI3:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   663
  assumes p: "p = a \<otimes> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   664
    and nunit: "b \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   665
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "p \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   666
  shows "properfactor G a p"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   667
unfolding p
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   668
using carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   669
apply (intro properfactorI, fast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   670
proof (clarsimp, elim dividesE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   671
  fix c
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   672
  assume ccarr: "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   673
  note [simp] = carr ccarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   674
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   675
  have "a \<otimes> \<one> = a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   676
  also assume "a = a \<otimes> b \<otimes> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   677
  also have "\<dots> = a \<otimes> (b \<otimes> c)" by (simp add: m_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   678
  finally have "a \<otimes> \<one> = a \<otimes> (b \<otimes> c)" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   679
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   680
  hence rinv: "\<one> = b \<otimes> c" by (intro l_cancel[of "a" "\<one>" "b \<otimes> c"], simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   681
  also have "\<dots> = c \<otimes> b" by (simp add: m_comm)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   682
  finally have linv: "\<one> = c \<otimes> b" .
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   683
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   684
  from ccarr linv[symmetric] rinv[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   685
  have "b \<in> Units G" unfolding Units_def by fastsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   686
  with nunit
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   687
      show "False" ..
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   688
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   689
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   690
lemma properfactorE:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   691
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   692
  assumes pf: "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   693
    and r: "\<lbrakk>a divides b; \<not>(b divides a)\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   694
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   695
using pf
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   696
unfolding properfactor_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   697
by (fast intro: r)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   698
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   699
lemma properfactorE2:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   700
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   701
  assumes pf: "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   702
    and elim: "\<lbrakk>a divides b; \<not>(a \<sim> b)\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   703
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   704
using pf
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   705
unfolding properfactor_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   706
by (fast elim: elim associatedE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   707
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   708
lemma (in monoid) properfactor_unitE:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   709
  assumes uunit: "u \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   710
    and pf: "properfactor G a u"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   711
    and acarr: "a \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   712
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   713
using pf unit_divides[OF uunit acarr]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   714
by (fast elim: properfactorE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   715
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   716
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   717
lemma (in monoid) properfactor_divides:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   718
  assumes pf: "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   719
  shows "a divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   720
using pf
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   721
by (elim properfactorE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   722
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   723
lemma (in monoid) properfactor_trans1 [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   724
  assumes dvds: "a divides b"  "properfactor G b c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   725
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   726
  shows "properfactor G a c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   727
using dvds carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   728
apply (elim properfactorE, intro properfactorI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   729
 apply (iprover intro: divides_trans)+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   730
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   731
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   732
lemma (in monoid) properfactor_trans2 [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   733
  assumes dvds: "properfactor G a b"  "b divides c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   734
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   735
  shows "properfactor G a c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   736
using dvds carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   737
apply (elim properfactorE, intro properfactorI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   738
 apply (iprover intro: divides_trans)+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   739
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   740
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   741
lemma properfactor_lless:
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   742
  fixes G (structure)
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   743
  shows "properfactor G = lless (division_rel G)"
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   744
apply (rule ext) apply (rule ext) apply rule
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   745
 apply (fastsimp elim: properfactorE2 intro: weak_llessI)
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   746
apply (fastsimp elim: weak_llessE intro: properfactorI2)
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   747
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   748
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   749
lemma (in monoid) properfactor_cong_l [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   750
  assumes x'x: "x' \<sim> x"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   751
    and pf: "properfactor G x y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   752
    and carr: "x \<in> carrier G"  "x' \<in> carrier G"  "y \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   753
  shows "properfactor G x' y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   754
using pf
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   755
unfolding properfactor_lless
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   756
proof -
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   757
  interpret weak_partial_order "division_rel G" ..
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   758
  from x'x
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   759
       have "x' .=\<^bsub>division_rel G\<^esub> x" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   760
  also assume "x \<sqsubset>\<^bsub>division_rel G\<^esub> y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   761
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   762
       show "x' \<sqsubset>\<^bsub>division_rel G\<^esub> y" by (simp add: carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   763
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   764
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   765
lemma (in monoid) properfactor_cong_r [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   766
  assumes pf: "properfactor G x y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   767
    and yy': "y \<sim> y'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   768
    and carr: "x \<in> carrier G"  "y \<in> carrier G"  "y' \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   769
  shows "properfactor G x y'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   770
using pf
27713
95b36bfe7fc4 New locales for orders and lattices where the equivalence relation is not restricted to equality.
ballarin
parents: 27701
diff changeset
   771
unfolding properfactor_lless
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   772
proof -
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   773
  interpret weak_partial_order "division_rel G" ..
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   774
  assume "x \<sqsubset>\<^bsub>division_rel G\<^esub> y"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   775
  also from yy'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   776
       have "y .=\<^bsub>division_rel G\<^esub> y'" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   777
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   778
       show "x \<sqsubset>\<^bsub>division_rel G\<^esub> y'" by (simp add: carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   779
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   780
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   781
lemma (in monoid_cancel) properfactor_mult_lI [intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   782
  assumes ab: "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   783
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   784
  shows "properfactor G (c \<otimes> a) (c \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   785
using ab carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   786
by (fastsimp elim: properfactorE intro: properfactorI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   787
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   788
lemma (in monoid_cancel) properfactor_mult_l [simp]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   789
  assumes carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   790
  shows "properfactor G (c \<otimes> a) (c \<otimes> b) = properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   791
using carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   792
by (fastsimp elim: properfactorE intro: properfactorI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   793
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   794
lemma (in comm_monoid_cancel) properfactor_mult_rI [intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   795
  assumes ab: "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   796
    and carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   797
  shows "properfactor G (a \<otimes> c) (b \<otimes> c)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   798
using ab carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   799
by (fastsimp elim: properfactorE intro: properfactorI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   800
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   801
lemma (in comm_monoid_cancel) properfactor_mult_r [simp]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   802
  assumes carr: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   803
  shows "properfactor G (a \<otimes> c) (b \<otimes> c) = properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   804
using carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   805
by (fastsimp elim: properfactorE intro: properfactorI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   806
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   807
lemma (in monoid) properfactor_prod_r:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   808
  assumes ab: "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   809
    and carr[simp]: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   810
  shows "properfactor G a (b \<otimes> c)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   811
by (intro properfactor_trans2[OF ab] divides_prod_r, simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   812
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   813
lemma (in comm_monoid) properfactor_prod_l:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   814
  assumes ab: "properfactor G a b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   815
    and carr[simp]: "a \<in> carrier G"  "b \<in> carrier G"  "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   816
  shows "properfactor G a (c \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   817
by (intro properfactor_trans2[OF ab] divides_prod_l, simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   818
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   819
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
   820
subsection {* Irreducible Elements and Primes *}
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   821
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   822
subsubsection {* Irreducible elements *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   823
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   824
lemma irreducibleI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   825
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   826
  assumes "a \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   827
    and "\<And>b. \<lbrakk>b \<in> carrier G; properfactor G b a\<rbrakk> \<Longrightarrow> b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   828
  shows "irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   829
using assms 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   830
unfolding irreducible_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   831
by blast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   832
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   833
lemma irreducibleE:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   834
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   835
  assumes irr: "irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   836
     and elim: "\<lbrakk>a \<notin> Units G; \<forall>b. b \<in> carrier G \<and> properfactor G b a \<longrightarrow> b \<in> Units G\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   837
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   838
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   839
unfolding irreducible_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   840
by blast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   841
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   842
lemma irreducibleD:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   843
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   844
  assumes irr: "irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   845
     and pf: "properfactor G b a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   846
     and bcarr: "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   847
  shows "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   848
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   849
by (fast elim: irreducibleE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   850
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   851
lemma (in monoid_cancel) irreducible_cong [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   852
  assumes irred: "irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   853
    and aa': "a \<sim> a'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   854
    and carr[simp]: "a \<in> carrier G"  "a' \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   855
  shows "irreducible G a'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   856
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   857
apply (elim irreducibleE, intro irreducibleI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   858
apply simp_all
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   859
proof clarify
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   860
  assume "a' \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   861
  also note aa'[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   862
  finally have aunit: "a \<in> Units G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   863
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   864
  assume "a \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   865
  with aunit
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   866
      show "False" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   867
next
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   868
  fix b
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   869
  assume r[rule_format]: "\<forall>b. b \<in> carrier G \<and> properfactor G b a \<longrightarrow> b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   870
    and bcarr[simp]: "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   871
  assume "properfactor G b a'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   872
  also note aa'[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   873
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   874
       have "properfactor G b a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   875
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   876
  with bcarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   877
     show "b \<in> Units G" by (fast intro: r)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   878
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   879
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   880
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   881
lemma (in monoid) irreducible_prod_rI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   882
  assumes airr: "irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   883
    and bunit: "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   884
    and carr[simp]: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   885
  shows "irreducible G (a \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   886
using airr carr bunit
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   887
apply (elim irreducibleE, intro irreducibleI, clarify)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   888
 apply (subgoal_tac "a \<in> Units G", simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   889
 apply (intro prod_unit_r[of a b] carr bunit, assumption)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   890
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   891
  fix c
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   892
  assume [simp]: "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   893
    and r[rule_format]: "\<forall>b. b \<in> carrier G \<and> properfactor G b a \<longrightarrow> b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   894
  assume "properfactor G c (a \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   895
  also have "a \<otimes> b \<sim> a" by (intro associatedI2[OF bunit], simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   896
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   897
       have pfa: "properfactor G c a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   898
  show "c \<in> Units G" by (rule r, simp add: pfa)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   899
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   900
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   901
lemma (in comm_monoid) irreducible_prod_lI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   902
  assumes birr: "irreducible G b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   903
    and aunit: "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   904
    and carr [simp]: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   905
  shows "irreducible G (a \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   906
apply (subst m_comm, simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   907
apply (intro irreducible_prod_rI assms)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   908
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   909
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   910
lemma (in comm_monoid_cancel) irreducible_prodE [elim]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   911
  assumes irr: "irreducible G (a \<otimes> b)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   912
    and carr[simp]: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   913
    and e1: "\<lbrakk>irreducible G a; b \<in> Units G\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   914
    and e2: "\<lbrakk>a \<in> Units G; irreducible G b\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   915
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   916
using irr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   917
proof (elim irreducibleE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   918
  assume abnunit: "a \<otimes> b \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   919
    and isunit[rule_format]: "\<forall>ba. ba \<in> carrier G \<and> properfactor G ba (a \<otimes> b) \<longrightarrow> ba \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   920
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   921
  show "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   922
  proof (cases "a \<in> Units G")
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   923
    assume aunit: "a \<in>  Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   924
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   925
    have "irreducible G b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   926
    apply (rule irreducibleI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   927
    proof (rule ccontr, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   928
      assume "b \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   929
      with aunit have "(a \<otimes> b) \<in> Units G" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   930
      with abnunit show "False" ..
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   931
    next
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   932
      fix c
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   933
      assume ccarr: "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   934
        and "properfactor G c b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   935
      hence "properfactor G c (a \<otimes> b)" by (simp add: properfactor_prod_l[of c b a])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   936
      from ccarr this show "c \<in> Units G" by (fast intro: isunit)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   937
    qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   938
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   939
    from aunit this show "P" by (rule e2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   940
  next
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   941
    assume anunit: "a \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   942
    with carr have "properfactor G b (b \<otimes> a)" by (fast intro: properfactorI3)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   943
    hence bf: "properfactor G b (a \<otimes> b)" by (subst m_comm[of a b], simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   944
    hence bunit: "b \<in> Units G" by (intro isunit, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   945
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   946
    have "irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   947
    apply (rule irreducibleI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   948
    proof (rule ccontr, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   949
      assume "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   950
      with bunit have "(a \<otimes> b) \<in> Units G" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   951
      with abnunit show "False" ..
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   952
    next
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   953
      fix c
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   954
      assume ccarr: "c \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   955
        and "properfactor G c a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   956
      hence "properfactor G c (a \<otimes> b)" by (simp add: properfactor_prod_r[of c a b])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   957
      from ccarr this show "c \<in> Units G" by (fast intro: isunit)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   958
    qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   959
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   960
    from this bunit show "P" by (rule e1)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   961
  qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   962
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   963
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   964
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   965
subsubsection {* Prime elements *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   966
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   967
lemma primeI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   968
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   969
  assumes "p \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   970
    and "\<And>a b. \<lbrakk>a \<in> carrier G; b \<in> carrier G; p divides (a \<otimes> b)\<rbrakk> \<Longrightarrow> p divides a \<or> p divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   971
  shows "prime G p"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   972
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   973
unfolding prime_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   974
by blast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   975
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   976
lemma primeE:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   977
  fixes G (structure)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   978
  assumes pprime: "prime G p"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   979
    and e: "\<lbrakk>p \<notin> Units G; \<forall>a\<in>carrier G. \<forall>b\<in>carrier G.
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   980
                          p divides a \<otimes> b \<longrightarrow> p divides a \<or> p divides b\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   981
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   982
using pprime
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   983
unfolding prime_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   984
by (blast dest: e)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   985
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   986
lemma (in comm_monoid_cancel) prime_divides:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   987
  assumes carr: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   988
    and pprime: "prime G p"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   989
    and pdvd: "p divides a \<otimes> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   990
  shows "p divides a \<or> p divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   991
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   992
by (blast elim: primeE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   993
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   994
lemma (in monoid_cancel) prime_cong [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   995
  assumes pprime: "prime G p"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   996
    and pp': "p \<sim> p'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   997
    and carr[simp]: "p \<in> carrier G"  "p' \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   998
  shows "prime G p'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
   999
using pprime
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1000
apply (elim primeE, intro primeI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1001
proof clarify
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1002
  assume pnunit: "p \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1003
  assume "p' \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1004
  also note pp'[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1005
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1006
       have "p \<in> Units G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1007
  with pnunit
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1008
       show False ..
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1009
next
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1010
  fix a b
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1011
  assume r[rule_format]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1012
         "\<forall>a\<in>carrier G. \<forall>b\<in>carrier G. p divides a \<otimes> b \<longrightarrow> p divides a \<or> p divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1013
  assume p'dvd: "p' divides a \<otimes> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1014
    and carr'[simp]: "a \<in> carrier G"  "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1015
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1016
  note pp'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1017
  also note p'dvd
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1018
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1019
       have "p divides a \<otimes> b" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1020
  hence "p divides a \<or> p divides b" by (intro r, simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1021
  moreover {
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1022
    note pp'[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1023
    also assume "p divides a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1024
    finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1025
         have "p' divides a" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1026
    hence "p' divides a \<or> p' divides b" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1027
  }
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1028
  moreover {
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1029
    note pp'[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1030
    also assume "p divides b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1031
    finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1032
         have "p' divides b" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1033
    hence "p' divides a \<or> p' divides b" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1034
  }
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1035
  ultimately
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1036
    show "p' divides a \<or> p' divides b" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1037
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1038
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1039
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27713
diff changeset
  1040
subsection {* Factorization and Factorial Monoids *}
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1041
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1042
subsubsection {* Function definitions *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1043
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1044
constdefs (structure G)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1045
  factors :: "[_, 'a list, 'a] \<Rightarrow> bool"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1046
  "factors G fs a == (\<forall>x \<in> (set fs). irreducible G x) \<and> foldr (op \<otimes>) fs \<one> = a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1047
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1048
  wfactors ::"[_, 'a list, 'a] \<Rightarrow> bool"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1049
  "wfactors G fs a == (\<forall>x \<in> (set fs). irreducible G x) \<and> foldr (op \<otimes>) fs \<one> \<sim> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1050
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1051
abbreviation
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1052
  list_assoc :: "('a,_) monoid_scheme \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "[\<sim>]\<index>" 44) where
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1053
  "list_assoc G == list_all2 (op \<sim>\<^bsub>G\<^esub>)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1054
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1055
constdefs (structure G)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1056
  essentially_equal :: "[_, 'a list, 'a list] \<Rightarrow> bool"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1057
  "essentially_equal G fs1 fs2 == (\<exists>fs1'. fs1 <~~> fs1' \<and> fs1' [\<sim>] fs2)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1058
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1059
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1060
locale factorial_monoid = comm_monoid_cancel +
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1061
  assumes factors_exist: 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1062
          "\<lbrakk>a \<in> carrier G; a \<notin> Units G\<rbrakk> \<Longrightarrow> \<exists>fs. set fs \<subseteq> carrier G \<and> factors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1063
      and factors_unique: 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1064
          "\<lbrakk>factors G fs a; factors G fs' a; a \<in> carrier G; a \<notin> Units G; 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1065
            set fs \<subseteq> carrier G; set fs' \<subseteq> carrier G\<rbrakk> \<Longrightarrow> essentially_equal G fs fs'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1066
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1067
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1068
subsubsection {* Comparing lists of elements *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1069
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1070
text {* Association on lists *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1071
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1072
lemma (in monoid) listassoc_refl [simp, intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1073
  assumes "set as \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1074
  shows "as [\<sim>] as"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1075
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1076
by (induct as) simp+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1077
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1078
lemma (in monoid) listassoc_sym [sym]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1079
  assumes "as [\<sim>] bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1080
    and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1081
  shows "bs [\<sim>] as"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1082
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1083
proof (induct as arbitrary: bs, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1084
  case Cons
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1085
  thus ?case
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1086
    apply (induct bs, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1087
    apply clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1088
    apply (iprover intro: associated_sym)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1089
  done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1090
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1091
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1092
lemma (in monoid) listassoc_trans [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1093
  assumes "as [\<sim>] bs" and "bs [\<sim>] cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1094
    and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G" and "set cs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1095
  shows "as [\<sim>] cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1096
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1097
apply (simp add: list_all2_conv_all_nth set_conv_nth, safe)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1098
apply (rule associated_trans)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1099
    apply (subgoal_tac "as ! i \<sim> bs ! i", assumption)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1100
    apply (simp, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1101
  apply blast+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1102
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1103
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1104
lemma (in monoid_cancel) irrlist_listassoc_cong:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1105
  assumes "\<forall>a\<in>set as. irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1106
    and "as [\<sim>] bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1107
    and "set as \<subseteq> carrier G" and "set bs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1108
  shows "\<forall>a\<in>set bs. irreducible G a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1109
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1110
apply (clarsimp simp add: list_all2_conv_all_nth set_conv_nth)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1111
apply (blast intro: irreducible_cong)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1112
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1113
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1114
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1115
text {* Permutations *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1116
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1117
lemma perm_map [intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1118
  assumes p: "a <~~> b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1119
  shows "map f a <~~> map f b"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1120
using p
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1121
by induct auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1122
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1123
lemma perm_map_switch:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1124
  assumes m: "map f a = map f b" and p: "b <~~> c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1125
  shows "\<exists>d. a <~~> d \<and> map f d = map f c"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1126
using p m
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1127
by (induct arbitrary: a) (simp, force, force, blast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1128
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1129
lemma (in monoid) perm_assoc_switch:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1130
   assumes a:"as [\<sim>] bs" and p: "bs <~~> cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1131
   shows "\<exists>bs'. as <~~> bs' \<and> bs' [\<sim>] cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1132
using p a
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1133
apply (induct bs cs arbitrary: as, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1134
  apply (clarsimp simp add: list_all2_Cons2, blast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1135
 apply (clarsimp simp add: list_all2_Cons2)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1136
 apply blast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1137
apply blast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1138
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1139
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1140
lemma (in monoid) perm_assoc_switch_r:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1141
   assumes p: "as <~~> bs" and a:"bs [\<sim>] cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1142
   shows "\<exists>bs'. as [\<sim>] bs' \<and> bs' <~~> cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1143
using p a
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1144
apply (induct as bs arbitrary: cs, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1145
  apply (clarsimp simp add: list_all2_Cons1, blast)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1146
 apply (clarsimp simp add: list_all2_Cons1)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1147
 apply blast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1148
apply blast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1149
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1150
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1151
declare perm_sym [sym]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1152
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1153
lemma perm_setP:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1154
  assumes perm: "as <~~> bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1155
    and as: "P (set as)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1156
  shows "P (set bs)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1157
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1158
  from perm
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1159
      have "multiset_of as = multiset_of bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1160
      by (simp add: multiset_of_eq_perm)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1161
  hence "set as = set bs" by (rule multiset_of_eq_setD)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1162
  with as
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1163
      show "P (set bs)" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1164
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1165
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1166
lemmas (in monoid) perm_closed =
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1167
    perm_setP[of _ _ "\<lambda>as. as \<subseteq> carrier G"]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1168
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1169
lemmas (in monoid) irrlist_perm_cong =
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1170
    perm_setP[of _ _ "\<lambda>as. \<forall>a\<in>as. irreducible G a"]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1171
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1172
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1173
text {* Essentially equal factorizations *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1174
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1175
lemma (in monoid) essentially_equalI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1176
  assumes ex: "fs1 <~~> fs1'"  "fs1' [\<sim>] fs2"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1177
  shows "essentially_equal G fs1 fs2"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1178
using ex
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1179
unfolding essentially_equal_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1180
by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1181
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1182
lemma (in monoid) essentially_equalE:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1183
  assumes ee: "essentially_equal G fs1 fs2"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1184
    and e: "\<And>fs1'. \<lbrakk>fs1 <~~> fs1'; fs1' [\<sim>] fs2\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1185
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1186
using ee
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1187
unfolding essentially_equal_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1188
by (fast intro: e)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1189
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1190
lemma (in monoid) ee_refl [simp,intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1191
  assumes carr: "set as \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1192
  shows "essentially_equal G as as"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1193
using carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1194
by (fast intro: essentially_equalI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1195
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1196
lemma (in monoid) ee_sym [sym]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1197
  assumes ee: "essentially_equal G as bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1198
    and carr: "set as \<subseteq> carrier G"  "set bs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1199
  shows "essentially_equal G bs as"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1200
using ee
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1201
proof (elim essentially_equalE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1202
  fix fs
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1203
  assume "as <~~> fs"  "fs [\<sim>] bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1204
  hence "\<exists>fs'. as [\<sim>] fs' \<and> fs' <~~> bs" by (rule perm_assoc_switch_r)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1205
  from this obtain fs'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1206
      where a: "as [\<sim>] fs'" and p: "fs' <~~> bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1207
      by auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1208
  from p have "bs <~~> fs'" by (rule perm_sym)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1209
  with a[symmetric] carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1210
      show ?thesis
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1211
      by (iprover intro: essentially_equalI perm_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1212
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1213
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1214
lemma (in monoid) ee_trans [trans]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1215
  assumes ab: "essentially_equal G as bs" and bc: "essentially_equal G bs cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1216
    and ascarr: "set as \<subseteq> carrier G" 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1217
    and bscarr: "set bs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1218
    and cscarr: "set cs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1219
  shows "essentially_equal G as cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1220
using ab bc
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1221
proof (elim essentially_equalE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1222
  fix abs bcs
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1223
  assume  "abs [\<sim>] bs" and pb: "bs <~~> bcs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1224
  hence "\<exists>bs'. abs <~~> bs' \<and> bs' [\<sim>] bcs" by (rule perm_assoc_switch)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1225
  from this obtain bs'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1226
      where p: "abs <~~> bs'" and a: "bs' [\<sim>] bcs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1227
      by auto
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1228
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1229
  assume "as <~~> abs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1230
  with p
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1231
      have pp: "as <~~> bs'" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1232
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1233
  from pp ascarr have c1: "set bs' \<subseteq> carrier G" by (rule perm_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1234
  from pb bscarr have c2: "set bcs \<subseteq> carrier G" by (rule perm_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1235
  note a
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1236
  also assume "bcs [\<sim>] cs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1237
  finally (listassoc_trans) have"bs' [\<sim>] cs" by (simp add: c1 c2 cscarr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1238
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1239
  with pp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1240
      show ?thesis
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1241
      by (rule essentially_equalI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1242
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1243
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1244
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1245
subsubsection {* Properties of lists of elements *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1246
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1247
text {* Multiplication of factors in a list *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1248
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1249
lemma (in monoid) multlist_closed [simp, intro]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1250
  assumes ascarr: "set fs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1251
  shows "foldr (op \<otimes>) fs \<one> \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1252
by (insert ascarr, induct fs, simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1253
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1254
lemma  (in comm_monoid) multlist_dividesI (*[intro]*):
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1255
  assumes "f \<in> set fs" and "f \<in> carrier G" and "set fs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1256
  shows "f divides (foldr (op \<otimes>) fs \<one>)"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1257
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1258
apply (induct fs)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1259
 apply simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1260
apply (case_tac "f = a", simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1261
 apply (fast intro: dividesI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1262
apply clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1263
apply (elim dividesE, intro dividesI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1264
 defer 1
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1265
 apply (simp add: m_comm)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1266
 apply (simp add: m_assoc[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1267
 apply (simp add: m_comm)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1268
apply simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1269
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1270
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1271
lemma (in comm_monoid_cancel) multlist_listassoc_cong:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1272
  assumes "fs [\<sim>] fs'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1273
    and "set fs \<subseteq> carrier G" and "set fs' \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1274
  shows "foldr (op \<otimes>) fs \<one> \<sim> foldr (op \<otimes>) fs' \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1275
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1276
proof (induct fs arbitrary: fs', simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1277
  case (Cons a as fs')
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1278
  thus ?case
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1279
  apply (induct fs', simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1280
  proof clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1281
    fix b bs
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1282
    assume "a \<sim> b" 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1283
      and acarr: "a \<in> carrier G" and bcarr: "b \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1284
      and ascarr: "set as \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1285
    hence p: "a \<otimes> foldr op \<otimes> as \<one> \<sim> b \<otimes> foldr op \<otimes> as \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1286
        by (fast intro: mult_cong_l)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1287
    also
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1288
      assume "as [\<sim>] bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1289
         and bscarr: "set bs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1290
         and "\<And>fs'. \<lbrakk>as [\<sim>] fs'; set fs' \<subseteq> carrier G\<rbrakk> \<Longrightarrow> foldr op \<otimes> as \<one> \<sim> foldr op \<otimes> fs' \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1291
      hence "foldr op \<otimes> as \<one> \<sim> foldr op \<otimes> bs \<one>" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1292
      with ascarr bscarr bcarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1293
          have "b \<otimes> foldr op \<otimes> as \<one> \<sim> b \<otimes> foldr op \<otimes> bs \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1294
          by (fast intro: mult_cong_r)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1295
   finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1296
       show "a \<otimes> foldr op \<otimes> as \<one> \<sim> b \<otimes> foldr op \<otimes> bs \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1297
       by (simp add: ascarr bscarr acarr bcarr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1298
  qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1299
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1300
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1301
lemma (in comm_monoid) multlist_perm_cong:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1302
  assumes prm: "as <~~> bs"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1303
    and ascarr: "set as \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1304
  shows "foldr (op \<otimes>) as \<one> = foldr (op \<otimes>) bs \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1305
using prm ascarr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1306
apply (induct, simp, clarsimp simp add: m_ac, clarsimp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1307
proof clarsimp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1308
  fix xs ys zs
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1309
  assume "xs <~~> ys"  "set xs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1310
  hence "set ys \<subseteq> carrier G" by (rule perm_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1311
  moreover assume "set ys \<subseteq> carrier G \<Longrightarrow> foldr op \<otimes> ys \<one> = foldr op \<otimes> zs \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1312
  ultimately show "foldr op \<otimes> ys \<one> = foldr op \<otimes> zs \<one>" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1313
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1314
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1315
lemma (in comm_monoid_cancel) multlist_ee_cong:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1316
  assumes "essentially_equal G fs fs'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1317
    and "set fs \<subseteq> carrier G" and "set fs' \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1318
  shows "foldr (op \<otimes>) fs \<one> \<sim> foldr (op \<otimes>) fs' \<one>"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1319
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1320
apply (elim essentially_equalE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1321
apply (simp add: multlist_perm_cong multlist_listassoc_cong perm_closed)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1322
done
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1323
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1324
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1325
subsubsection {* Factorization in irreducible elements *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1326
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1327
lemma wfactorsI:
28599
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
  1328
  fixes G (structure)
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1329
  assumes "\<forall>f\<in>set fs. irreducible G f"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1330
    and "foldr (op \<otimes>) fs \<one> \<sim> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1331
  shows "wfactors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1332
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1333
unfolding wfactors_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1334
by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1335
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1336
lemma wfactorsE:
28599
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
  1337
  fixes G (structure)
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1338
  assumes wf: "wfactors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1339
    and e: "\<lbrakk>\<forall>f\<in>set fs. irreducible G f; foldr (op \<otimes>) fs \<one> \<sim> a\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1340
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1341
using wf
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1342
unfolding wfactors_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1343
by (fast dest: e)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1344
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1345
lemma (in monoid) factorsI:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1346
  assumes "\<forall>f\<in>set fs. irreducible G f"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1347
    and "foldr (op \<otimes>) fs \<one> = a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1348
  shows "factors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1349
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1350
unfolding factors_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1351
by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1352
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1353
lemma factorsE:
28599
12d914277b8d Removed 'includes'.
ballarin
parents: 27717
diff changeset
  1354
  fixes G (structure)
27701
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1355
  assumes f: "factors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1356
    and e: "\<lbrakk>\<forall>f\<in>set fs. irreducible G f; foldr (op \<otimes>) fs \<one> = a\<rbrakk> \<Longrightarrow> P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1357
  shows "P"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1358
using f
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1359
unfolding factors_def
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1360
by (simp add: e)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1361
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1362
lemma (in monoid) factors_wfactors:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1363
  assumes "factors G as a" and "set as \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1364
  shows "wfactors G as a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1365
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1366
by (blast elim: factorsE intro: wfactorsI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1367
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1368
lemma (in monoid) wfactors_factors:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1369
  assumes "wfactors G as a" and "set as \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1370
  shows "\<exists>a'. factors G as a' \<and> a' \<sim> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1371
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1372
by (blast elim: wfactorsE intro: factorsI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1373
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1374
lemma (in monoid) factors_closed [dest]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1375
  assumes "factors G fs a" and "set fs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1376
  shows "a \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1377
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1378
by (elim factorsE, clarsimp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1379
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1380
lemma (in monoid) nunit_factors:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1381
  assumes anunit: "a \<notin> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1382
    and fs: "factors G as a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1383
  shows "length as > 0"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1384
apply (insert fs, elim factorsE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1385
proof (cases "length as = 0")
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1386
  assume "length as = 0"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1387
  hence fold: "foldr op \<otimes> as \<one> = \<one>" by force
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1388
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1389
  assume "foldr op \<otimes> as \<one> = a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1390
  with fold
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1391
       have "a = \<one>" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1392
  then have "a \<in> Units G" by fast
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1393
  with anunit
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1394
       have "False" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1395
  thus ?thesis ..
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1396
qed simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1397
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1398
lemma (in monoid) unit_wfactors [simp]:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1399
  assumes aunit: "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1400
  shows "wfactors G [] a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1401
using aunit
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1402
by (intro wfactorsI) (simp, simp add: Units_assoc)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1403
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1404
lemma (in comm_monoid_cancel) unit_wfactors_empty:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1405
  assumes aunit: "a \<in> Units G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1406
    and wf: "wfactors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1407
    and carr[simp]: "set fs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1408
  shows "fs = []"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1409
proof (rule ccontr, cases fs, simp)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1410
  fix f fs'
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1411
  assume fs: "fs = f # fs'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1412
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1413
  from carr
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1414
      have fcarr[simp]: "f \<in> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1415
      and carr'[simp]: "set fs' \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1416
      by (simp add: fs)+
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1417
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1418
  from fs wf
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1419
      have "irreducible G f" by (simp add: wfactors_def)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1420
  hence fnunit: "f \<notin> Units G" by (fast elim: irreducibleE)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1421
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1422
  from fs wf
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1423
      have a: "f \<otimes> foldr (op \<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1424
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1425
  note aunit
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1426
  also from fs wf
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1427
       have a: "f \<otimes> foldr (op \<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1428
       have "a \<sim> f \<otimes> foldr (op \<otimes>) fs' \<one>" 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1429
       by (simp add: Units_closed[OF aunit] a[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1430
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1431
       have "f \<otimes> foldr (op \<otimes>) fs' \<one> \<in> Units G" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1432
  hence "f \<in> Units G" by (intro unit_factor[of f], simp+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1433
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1434
  with fnunit show "False" by simp
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1435
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1436
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1437
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1438
text {* Comparing wfactors *}
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1439
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1440
lemma (in comm_monoid_cancel) wfactors_listassoc_cong_l:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1441
  assumes fact: "wfactors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1442
    and asc: "fs [\<sim>] fs'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1443
    and carr: "a \<in> carrier G"  "set fs \<subseteq> carrier G"  "set fs' \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1444
  shows "wfactors G fs' a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1445
using fact
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1446
apply (elim wfactorsE, intro wfactorsI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1447
proof -
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1448
  assume "\<forall>f\<in>set fs. irreducible G f"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1449
  also note asc
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1450
  finally (irrlist_listassoc_cong)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1451
       show "\<forall>f\<in>set fs'. irreducible G f" by (simp add: carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1452
next
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1453
  from asc[symmetric]
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1454
       have "foldr op \<otimes> fs' \<one> \<sim> foldr op \<otimes> fs \<one>" 
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1455
       by (simp add: multlist_listassoc_cong carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1456
  also assume "foldr op \<otimes> fs \<one> \<sim> a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1457
  finally
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1458
       show "foldr op \<otimes> fs' \<one> \<sim> a" by (simp add: carr)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1459
qed
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1460
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1461
lemma (in comm_monoid) wfactors_perm_cong_l:
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1462
  assumes "wfactors G fs a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1463
    and "fs <~~> fs'"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1464
    and "set fs \<subseteq> carrier G"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1465
  shows "wfactors G fs' a"
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1466
using assms
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1467
apply (elim wfactorsE, intro wfactorsI)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1468
 apply (rule irrlist_perm_cong, assumption+)
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1469
apply (simp add: multlist_perm_cong[symmetric])
ed7a2e0fab59 New theory on divisibility.
ballarin
parents:
diff changeset
  1470