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