src/HOL/Algebra/Divisibility.thy
changeset 63846 23134a486dc6
parent 63832 a400b127853c
child 63847 34dccc2dd6db
equal deleted inserted replaced
63844:9c22a97b7674 63846:23134a486dc6
   185   fixes G (structure)
   185   fixes G (structure)
   186   assumes d: "a divides b"
   186   assumes d: "a divides b"
   187     and elim: "\<And>c. \<lbrakk>b = a \<otimes> c; c \<in> carrier G\<rbrakk> \<Longrightarrow> P"
   187     and elim: "\<And>c. \<lbrakk>b = a \<otimes> c; c \<in> carrier G\<rbrakk> \<Longrightarrow> P"
   188   shows "P"
   188   shows "P"
   189 proof -
   189 proof -
   190   from dividesD[OF d]
   190   from dividesD[OF d] obtain c where "c \<in> carrier G" and "b = a \<otimes> c" by auto
   191   obtain c where "c \<in> carrier G" and "b = a \<otimes> c" by auto
       
   192   then show P by (elim elim)
   191   then show P by (elim elim)
   193 qed
   192 qed
   194 
   193 
   195 lemma (in monoid) divides_refl[simp, intro!]:
   194 lemma (in monoid) divides_refl[simp, intro!]:
   196   assumes carr: "a \<in> carrier G"
   195   assumes carr: "a \<in> carrier G"
   317   shows "\<exists>u\<in>Units G. a = b \<otimes> u"
   316   shows "\<exists>u\<in>Units G. a = b \<otimes> u"
   318   using assoc
   317   using assoc
   319   unfolding associated_def
   318   unfolding associated_def
   320 proof clarify
   319 proof clarify
   321   assume "b divides a"
   320   assume "b divides a"
   322   then have "\<exists>u\<in>carrier G. a = b \<otimes> u" by (rule dividesD)
       
   323   then obtain u where ucarr: "u \<in> carrier G" and a: "a = b \<otimes> u"
   321   then obtain u where ucarr: "u \<in> carrier G" and a: "a = b \<otimes> u"
   324     by auto
   322     by (rule dividesE)
   325 
   323 
   326   assume "a divides b"
   324   assume "a divides b"
   327   then have "\<exists>u'\<in>carrier G. b = a \<otimes> u'" by (rule dividesD)
       
   328   then obtain u' where u'carr: "u' \<in> carrier G" and b: "b = a \<otimes> u'"
   325   then obtain u' where u'carr: "u' \<in> carrier G" and b: "b = a \<otimes> u'"
   329     by auto
   326     by (rule dividesE)
   330   note carr = carr ucarr u'carr
   327   note carr = carr ucarr u'carr
   331 
   328 
   332   from carr have "a \<otimes> \<one> = a" by simp
   329   from carr have "a \<otimes> \<one> = a" by simp
   333   also have "\<dots> = b \<otimes> u" by (simp add: a)
   330   also have "\<dots> = b \<otimes> u" by (simp add: a)
   334   also have "\<dots> = a \<otimes> u' \<otimes> u" by (simp add: b)
   331   also have "\<dots> = a \<otimes> u' \<otimes> u" by (simp add: b)
   557 lemma properfactorI2:
   554 lemma properfactorI2:
   558   fixes G (structure)
   555   fixes G (structure)
   559   assumes advdb: "a divides b"
   556   assumes advdb: "a divides b"
   560     and neq: "\<not>(a \<sim> b)"
   557     and neq: "\<not>(a \<sim> b)"
   561   shows "properfactor G a b"
   558   shows "properfactor G a b"
   562   apply (rule properfactorI, rule advdb)
   559 proof (rule properfactorI, rule advdb, rule notI)
   563 proof (rule ccontr, simp)
       
   564   assume "b divides a"
   560   assume "b divides a"
   565   with advdb have "a \<sim> b" by (rule associatedI)
   561   with advdb have "a \<sim> b" by (rule associatedI)
   566   with neq show "False" by fast
   562   with neq show "False" by fast
   567 qed
   563 qed
   568 
   564 
   782     and isunit[rule_format]: "\<forall>ba. ba \<in> carrier G \<and> properfactor G ba (a \<otimes> b) \<longrightarrow> ba \<in> Units G"
   778     and isunit[rule_format]: "\<forall>ba. ba \<in> carrier G \<and> properfactor G ba (a \<otimes> b) \<longrightarrow> ba \<in> Units G"
   783   show P
   779   show P
   784   proof (cases "a \<in> Units G")
   780   proof (cases "a \<in> Units G")
   785     case aunit: True
   781     case aunit: True
   786     have "irreducible G b"
   782     have "irreducible G b"
   787       apply (rule irreducibleI)
   783     proof (rule irreducibleI, rule notI)
   788     proof (rule ccontr, simp)
       
   789       assume "b \<in> Units G"
   784       assume "b \<in> Units G"
   790       with aunit have "(a \<otimes> b) \<in> Units G" by fast
   785       with aunit have "(a \<otimes> b) \<in> Units G" by fast
   791       with abnunit show "False" ..
   786       with abnunit show "False" ..
   792     next
   787     next
   793       fix c
   788       fix c
   802     with carr have "properfactor G b (b \<otimes> a)" by (fast intro: properfactorI3)
   797     with carr have "properfactor G b (b \<otimes> a)" by (fast intro: properfactorI3)
   803     then have bf: "properfactor G b (a \<otimes> b)" by (subst m_comm[of a b], simp+)
   798     then have bf: "properfactor G b (a \<otimes> b)" by (subst m_comm[of a b], simp+)
   804     then have bunit: "b \<in> Units G" by (intro isunit, simp)
   799     then have bunit: "b \<in> Units G" by (intro isunit, simp)
   805 
   800 
   806     have "irreducible G a"
   801     have "irreducible G a"
   807       apply (rule irreducibleI)
   802     proof (rule irreducibleI, rule notI)
   808     proof (rule ccontr, simp)
       
   809       assume "a \<in> Units G"
   803       assume "a \<in> Units G"
   810       with bunit have "(a \<otimes> b) \<in> Units G" by fast
   804       with bunit have "(a \<otimes> b) \<in> Units G" by fast
   811       with abnunit show "False" ..
   805       with abnunit show "False" ..
   812     next
   806     next
   813       fix c
   807       fix c
  1182 lemma (in comm_monoid_cancel) unit_wfactors_empty:
  1176 lemma (in comm_monoid_cancel) unit_wfactors_empty:
  1183   assumes aunit: "a \<in> Units G"
  1177   assumes aunit: "a \<in> Units G"
  1184     and wf: "wfactors G fs a"
  1178     and wf: "wfactors G fs a"
  1185     and carr[simp]: "set fs \<subseteq> carrier G"
  1179     and carr[simp]: "set fs \<subseteq> carrier G"
  1186   shows "fs = []"
  1180   shows "fs = []"
  1187 proof (rule ccontr, cases fs, simp)
  1181 proof (cases fs)
  1188   fix f fs'
  1182   case Nil
  1189   assume fs: "fs = f # fs'"
  1183   then show ?thesis .
  1190 
  1184 next
       
  1185   case fs: (Cons f fs')
  1191   from carr have fcarr[simp]: "f \<in> carrier G" and carr'[simp]: "set fs' \<subseteq> carrier G"
  1186   from carr have fcarr[simp]: "f \<in> carrier G" and carr'[simp]: "set fs' \<subseteq> carrier G"
  1192     by (simp_all add: fs)
  1187     by (simp_all add: fs)
  1193 
  1188 
  1194   from fs wf have "irreducible G f" by (simp add: wfactors_def)
  1189   from fs wf have "irreducible G f" by (simp add: wfactors_def)
  1195   then have fnunit: "f \<notin> Units G" by (fast elim: irreducibleE)
  1190   then have fnunit: "f \<notin> Units G" by (fast elim: irreducibleE)
  1201   have a: "f \<otimes> foldr (op \<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def)
  1196   have a: "f \<otimes> foldr (op \<otimes>) fs' \<one> \<sim> a" by (simp add: wfactors_def)
  1202   have "a \<sim> f \<otimes> foldr (op \<otimes>) fs' \<one>"
  1197   have "a \<sim> f \<otimes> foldr (op \<otimes>) fs' \<one>"
  1203     by (simp add: Units_closed[OF aunit] a[symmetric])
  1198     by (simp add: Units_closed[OF aunit] a[symmetric])
  1204   finally have "f \<otimes> foldr (op \<otimes>) fs' \<one> \<in> Units G" by simp
  1199   finally have "f \<otimes> foldr (op \<otimes>) fs' \<one> \<in> Units G" by simp
  1205   then have "f \<in> Units G" by (intro unit_factor[of f], simp+)
  1200   then have "f \<in> Units G" by (intro unit_factor[of f], simp+)
  1206   with fnunit show "False" by simp
  1201   with fnunit show ?thesis by contradiction
  1207 qed
  1202 qed
  1208 
  1203 
  1209 
  1204 
  1210 text \<open>Comparing wfactors\<close>
  1205 text \<open>Comparing wfactors\<close>
  1211 
  1206 
  2179       finally have "p divides a" by simp
  2174       finally have "p divides a" by simp
  2180       then show ?thesis ..
  2175       then show ?thesis ..
  2181     next
  2176     next
  2182       case bnunit: False
  2177       case bnunit: False
  2183       have cnunit: "c \<notin> Units G"
  2178       have cnunit: "c \<notin> Units G"
  2184       proof (rule ccontr, simp)
  2179       proof
  2185         assume cunit: "c \<in> Units G"
  2180         assume cunit: "c \<in> Units G"
  2186         from bnunit have "properfactor G a (a \<otimes> b)"
  2181         from bnunit have "properfactor G a (a \<otimes> b)"
  2187           by (intro properfactorI3[of _ _ b], simp+)
  2182           by (intro properfactorI3[of _ _ b], simp+)
  2188         also note abpc
  2183         also note abpc
  2189         also from cunit have "p \<otimes> c \<sim> p"
  2184         also from cunit have "p \<otimes> c \<sim> p"
  2838            apply (fast intro: unit_divides)
  2833            apply (fast intro: unit_divides)
  2839           apply (fast intro: unit_divides)
  2834           apply (fast intro: unit_divides)
  2840          apply (clarsimp simp add: Unit_eq_dividesone[symmetric])
  2835          apply (clarsimp simp add: Unit_eq_dividesone[symmetric])
  2841          apply (rule r, rule, assumption)
  2836          apply (rule r, rule, assumption)
  2842          apply (rule properfactorI, assumption)
  2837          apply (rule properfactorI, assumption)
  2843     proof (rule ccontr, simp)
  2838     proof
  2844       fix y
  2839       fix y
  2845       assume ycarr: "y \<in> carrier G"
  2840       assume ycarr: "y \<in> carrier G"
  2846       assume "p divides y"
  2841       assume "p divides y"
  2847       also assume "y divides a"
  2842       also assume "y divides a"
  2848       finally have "p divides a"
  2843       finally have "p divides a"
  2858            apply (fast intro: unit_divides)
  2853            apply (fast intro: unit_divides)
  2859           apply (fast intro: unit_divides)
  2854           apply (fast intro: unit_divides)
  2860          apply (clarsimp simp add: Unit_eq_dividesone[symmetric])
  2855          apply (clarsimp simp add: Unit_eq_dividesone[symmetric])
  2861          apply (rule r, rule, assumption)
  2856          apply (rule r, rule, assumption)
  2862          apply (rule properfactorI, assumption)
  2857          apply (rule properfactorI, assumption)
  2863     proof (rule ccontr, simp)
  2858     proof
  2864       fix y
  2859       fix y
  2865       assume ycarr: "y \<in> carrier G"
  2860       assume ycarr: "y \<in> carrier G"
  2866       assume "p divides y"
  2861       assume "p divides y"
  2867       also assume "y divides b"
  2862       also assume "y divides b"
  2868       finally have "p divides b" by (simp add: pcarr ycarr bcarr)
  2863       finally have "p divides b" by (simp add: pcarr ycarr bcarr)
  3309   then have fcb: "factorcount G b = length as + length cs"
  3304   then have fcb: "factorcount G b = length as + length cs"
  3310     by simp
  3305     by simp
  3311 
  3306 
  3312   assume nbdvda: "\<not> b divides a"
  3307   assume nbdvda: "\<not> b divides a"
  3313   have "c \<notin> Units G"
  3308   have "c \<notin> Units G"
  3314   proof (rule ccontr, simp)
  3309   proof
  3315     assume cunit:"c \<in> Units G"
  3310     assume cunit:"c \<in> Units G"
  3316     have "b \<otimes> inv c = a \<otimes> c \<otimes> inv c"
  3311     have "b \<otimes> inv c = a \<otimes> c \<otimes> inv c"
  3317       by (simp add: b)
  3312       by (simp add: b)
  3318     also from ccarr acarr cunit have "\<dots> = a \<otimes> (c \<otimes> inv c)"
  3313     also from ccarr acarr cunit have "\<dots> = a \<otimes> (c \<otimes> inv c)"
  3319       by (fast intro: m_assoc)
  3314       by (fast intro: m_assoc)