author wenzelm Wed Sep 07 16:53:49 2011 +0200 (2011-09-07) changeset 44780 a13cdb1e9e08 parent 44779 98d597c4193d child 44781 210b127e0b03
tuned/simplified proofs;
```     1.1 --- a/src/HOL/Library/Abstract_Rat.thy	Wed Sep 07 16:37:50 2011 +0200
1.2 +++ b/src/HOL/Library/Abstract_Rat.thy	Wed Sep 07 16:53:49 2011 +0200
1.3 @@ -10,10 +10,10 @@
1.4
1.5  type_synonym Num = "int \<times> int"
1.6
1.7 -abbreviation Num0_syn :: Num ("0\<^sub>N")
1.8 +abbreviation Num0_syn :: Num  ("0\<^sub>N")
1.9    where "0\<^sub>N \<equiv> (0, 0)"
1.10
1.11 -abbreviation Numi_syn :: "int \<Rightarrow> Num" ("_\<^sub>N")
1.12 +abbreviation Numi_syn :: "int \<Rightarrow> Num"  ("_\<^sub>N")
1.13    where "i\<^sub>N \<equiv> (i, 1)"
1.14
1.15  definition isnormNum :: "Num \<Rightarrow> bool" where
1.16 @@ -22,16 +22,15 @@
1.17  definition normNum :: "Num \<Rightarrow> Num" where
1.18    "normNum = (\<lambda>(a,b).
1.19      (if a=0 \<or> b = 0 then (0,0) else
1.20 -      (let g = gcd a b
1.21 +      (let g = gcd a b
1.22         in if b > 0 then (a div g, b div g) else (- (a div g), - (b div g)))))"
1.23
1.24  declare gcd_dvd1_int[presburger] gcd_dvd2_int[presburger]
1.25
1.26  lemma normNum_isnormNum [simp]: "isnormNum (normNum x)"
1.27  proof -
1.28 -  have " \<exists> a b. x = (a,b)" by auto
1.29 -  then obtain a b where x[simp]: "x = (a,b)" by blast
1.30 -  { assume "a=0 \<or> b = 0" hence ?thesis by (simp add: normNum_def isnormNum_def) }
1.31 +  obtain a b where x: "x = (a, b)" by (cases x)
1.32 +  { assume "a=0 \<or> b = 0" hence ?thesis by (simp add: x normNum_def isnormNum_def) }
1.33    moreover
1.34    { assume anz: "a \<noteq> 0" and bnz: "b \<noteq> 0"
1.35      let ?g = "gcd a b"
1.36 @@ -42,7 +41,7 @@
1.37      have gpos: "?g > 0" by arith
1.38      have gdvd: "?g dvd a" "?g dvd b" by arith+
1.39      from zdvd_mult_div_cancel[OF gdvd(1)] zdvd_mult_div_cancel[OF gdvd(2)] anz bnz
1.40 -    have nz':"?a' \<noteq> 0" "?b' \<noteq> 0" by - (rule notI, simp)+
1.41 +    have nz': "?a' \<noteq> 0" "?b' \<noteq> 0" by - (rule notI, simp)+
1.42      from anz bnz have stupid: "a \<noteq> 0 \<or> b \<noteq> 0" by arith
1.43      from div_gcd_coprime_int[OF stupid] have gp1: "?g' = 1" .
1.44      from bnz have "b < 0 \<or> b > 0" by arith
1.45 @@ -50,18 +49,18 @@
1.46      { assume b: "b > 0"
1.47        from b have "?b' \<ge> 0"
1.48          by (presburger add: pos_imp_zdiv_nonneg_iff[OF gpos])
1.49 -      with nz' have b': "?b' > 0" by arith
1.50 -      from b b' anz bnz nz' gp1 have ?thesis
1.51 -        by (simp add: isnormNum_def normNum_def Let_def split_def)}
1.52 +      with nz' have b': "?b' > 0" by arith
1.53 +      from b b' anz bnz nz' gp1 have ?thesis
1.54 +        by (simp add: x isnormNum_def normNum_def Let_def split_def) }
1.55      moreover {
1.56        assume b: "b < 0"
1.57 -      { assume b': "?b' \<ge> 0"
1.58 +      { assume b': "?b' \<ge> 0"
1.59          from gpos have th: "?g \<ge> 0" by arith
1.60          from mult_nonneg_nonneg[OF th b'] zdvd_mult_div_cancel[OF gdvd(2)]
1.61          have False using b by arith }
1.62        hence b': "?b' < 0" by (presburger add: linorder_not_le[symmetric])
1.63 -      from anz bnz nz' b b' gp1 have ?thesis
1.64 -        by (simp add: isnormNum_def normNum_def Let_def split_def) }
1.65 +      from anz bnz nz' b b' gp1 have ?thesis
1.66 +        by (simp add: x isnormNum_def normNum_def Let_def split_def) }
1.67      ultimately have ?thesis by blast
1.68    }
1.69    ultimately show ?thesis by blast
1.70 @@ -69,25 +68,25 @@
1.71
1.72  text {* Arithmetic over Num *}
1.73
1.74 -definition Nadd :: "Num \<Rightarrow> Num \<Rightarrow> Num" (infixl "+\<^sub>N" 60) where
1.75 +definition Nadd :: "Num \<Rightarrow> Num \<Rightarrow> Num"  (infixl "+\<^sub>N" 60) where
1.76    "Nadd = (\<lambda>(a,b) (a',b'). if a = 0 \<or> b = 0 then normNum(a',b')
1.77 -    else if a'=0 \<or> b' = 0 then normNum(a,b)
1.78 +    else if a'=0 \<or> b' = 0 then normNum(a,b)
1.79      else normNum(a*b' + b*a', b*b'))"
1.80
1.81 -definition Nmul :: "Num \<Rightarrow> Num \<Rightarrow> Num" (infixl "*\<^sub>N" 60) where
1.82 -  "Nmul = (\<lambda>(a,b) (a',b'). let g = gcd (a*a') (b*b')
1.83 +definition Nmul :: "Num \<Rightarrow> Num \<Rightarrow> Num"  (infixl "*\<^sub>N" 60) where
1.84 +  "Nmul = (\<lambda>(a,b) (a',b'). let g = gcd (a*a') (b*b')
1.85      in (a*a' div g, b*b' div g))"
1.86
1.87  definition Nneg :: "Num \<Rightarrow> Num" ("~\<^sub>N")
1.88    where "Nneg \<equiv> (\<lambda>(a,b). (-a,b))"
1.89
1.90 -definition Nsub :: "Num \<Rightarrow> Num \<Rightarrow> Num" (infixl "-\<^sub>N" 60)
1.91 +definition Nsub :: "Num \<Rightarrow> Num \<Rightarrow> Num"  (infixl "-\<^sub>N" 60)
1.92    where "Nsub = (\<lambda>a b. a +\<^sub>N ~\<^sub>N b)"
1.93
1.94  definition Ninv :: "Num \<Rightarrow> Num"
1.95    where "Ninv = (\<lambda>(a,b). if a < 0 then (-b, \<bar>a\<bar>) else (b,a))"
1.96
1.97 -definition Ndiv :: "Num \<Rightarrow> Num \<Rightarrow> Num" (infixl "\<div>\<^sub>N" 60)
1.98 +definition Ndiv :: "Num \<Rightarrow> Num \<Rightarrow> Num"  (infixl "\<div>\<^sub>N" 60)
1.99    where "Ndiv = (\<lambda>a b. a *\<^sub>N Ninv b)"
1.100
1.101  lemma Nneg_normN[simp]: "isnormNum x \<Longrightarrow> isnormNum (~\<^sub>N x)"
1.102 @@ -100,24 +99,24 @@
1.103    by (simp add: Nsub_def split_def)
1.104
1.105  lemma Nmul_normN[simp]:
1.106 -  assumes xn:"isnormNum x" and yn: "isnormNum y"
1.107 +  assumes xn: "isnormNum x" and yn: "isnormNum y"
1.108    shows "isnormNum (x *\<^sub>N y)"
1.109  proof -
1.110 -  have "\<exists>a b. x = (a,b)" and "\<exists> a' b'. y = (a',b')" by auto
1.111 -  then obtain a b a' b' where ab: "x = (a,b)"  and ab': "y = (a',b')" by blast
1.112 -  {assume "a = 0"
1.113 -    hence ?thesis using xn ab ab'
1.114 -      by (simp add: isnormNum_def Let_def Nmul_def split_def)}
1.115 +  obtain a b where x: "x = (a, b)" by (cases x)
1.116 +  obtain a' b' where y: "y = (a', b')" by (cases y)
1.117 +  { assume "a = 0"
1.118 +    hence ?thesis using xn x y
1.119 +      by (simp add: isnormNum_def Let_def Nmul_def split_def) }
1.120    moreover
1.121 -  {assume "a' = 0"
1.122 -    hence ?thesis using yn ab ab'
1.123 -      by (simp add: isnormNum_def Let_def Nmul_def split_def)}
1.124 +  { assume "a' = 0"
1.125 +    hence ?thesis using yn x y
1.126 +      by (simp add: isnormNum_def Let_def Nmul_def split_def) }
1.127    moreover
1.128 -  {assume a: "a \<noteq>0" and a': "a'\<noteq>0"
1.129 -    hence bp: "b > 0" "b' > 0" using xn yn ab ab' by (simp_all add: isnormNum_def)
1.130 -    from mult_pos_pos[OF bp] have "x *\<^sub>N y = normNum (a*a', b*b')"
1.131 -      using ab ab' a a' bp by (simp add: Nmul_def Let_def split_def normNum_def)
1.132 -    hence ?thesis by simp}
1.133 +  { assume a: "a \<noteq>0" and a': "a'\<noteq>0"
1.134 +    hence bp: "b > 0" "b' > 0" using xn yn x y by (simp_all add: isnormNum_def)
1.135 +    from mult_pos_pos[OF bp] have "x *\<^sub>N y = normNum (a * a', b * b')"
1.136 +      using x y a a' bp by (simp add: Nmul_def Let_def split_def normNum_def)
1.137 +    hence ?thesis by simp }
1.138    ultimately show ?thesis by blast
1.139  qed
1.140
1.141 @@ -125,26 +124,26 @@
1.142    by (simp add: Ninv_def isnormNum_def split_def)
1.143      (cases "fst x = 0", auto simp add: gcd_commute_int)
1.144
1.145 -lemma isnormNum_int[simp]:
1.146 +lemma isnormNum_int[simp]:
1.147    "isnormNum 0\<^sub>N" "isnormNum ((1::int)\<^sub>N)" "i \<noteq> 0 \<Longrightarrow> isnormNum (i\<^sub>N)"
1.149
1.150
1.151  text {* Relations over Num *}
1.152
1.153 -definition Nlt0:: "Num \<Rightarrow> bool" ("0>\<^sub>N")
1.154 +definition Nlt0:: "Num \<Rightarrow> bool"  ("0>\<^sub>N")
1.155    where "Nlt0 = (\<lambda>(a,b). a < 0)"
1.156
1.157 -definition Nle0:: "Num \<Rightarrow> bool" ("0\<ge>\<^sub>N")
1.158 +definition Nle0:: "Num \<Rightarrow> bool"  ("0\<ge>\<^sub>N")
1.159    where "Nle0 = (\<lambda>(a,b). a \<le> 0)"
1.160
1.161 -definition Ngt0:: "Num \<Rightarrow> bool" ("0<\<^sub>N")
1.162 +definition Ngt0:: "Num \<Rightarrow> bool"  ("0<\<^sub>N")
1.163    where "Ngt0 = (\<lambda>(a,b). a > 0)"
1.164
1.165 -definition Nge0:: "Num \<Rightarrow> bool" ("0\<le>\<^sub>N")
1.166 +definition Nge0:: "Num \<Rightarrow> bool"  ("0\<le>\<^sub>N")
1.167    where "Nge0 = (\<lambda>(a,b). a \<ge> 0)"
1.168
1.169 -definition Nlt :: "Num \<Rightarrow> Num \<Rightarrow> bool" (infix "<\<^sub>N" 55)
1.170 +definition Nlt :: "Num \<Rightarrow> Num \<Rightarrow> bool"  (infix "<\<^sub>N" 55)
1.171    where "Nlt = (\<lambda>a b. 0>\<^sub>N (a -\<^sub>N b))"
1.172
1.173  definition Nle :: "Num \<Rightarrow> Num \<Rightarrow> bool"  (infix "\<le>\<^sub>N" 55)
1.174 @@ -155,35 +154,35 @@
1.175  lemma INum_int [simp]: "INum (i\<^sub>N) = ((of_int i) ::'a::field)" "INum 0\<^sub>N = (0::'a::field)"
1.177
1.178 -lemma isnormNum_unique[simp]:
1.179 -  assumes na: "isnormNum x" and nb: "isnormNum y"
1.180 +lemma isnormNum_unique[simp]:
1.181 +  assumes na: "isnormNum x" and nb: "isnormNum y"
1.182    shows "((INum x ::'a::{field_char_0, field_inverse_zero}) = INum y) = (x = y)" (is "?lhs = ?rhs")
1.183  proof
1.184 -  have "\<exists> a b a' b'. x = (a,b) \<and> y = (a',b')" by auto
1.185 -  then obtain a b a' b' where xy[simp]: "x = (a,b)" "y=(a',b')" by blast
1.186 -  assume H: ?lhs
1.187 +  obtain a b where x: "x = (a, b)" by (cases x)
1.188 +  obtain a' b' where y: "y = (a', b')" by (cases y)
1.189 +  assume H: ?lhs
1.190    { assume "a = 0 \<or> b = 0 \<or> a' = 0 \<or> b' = 0"
1.191      hence ?rhs using na nb H
1.192 -      by (simp add: INum_def split_def isnormNum_def split: split_if_asm) }
1.193 +      by (simp add: x y INum_def split_def isnormNum_def split: split_if_asm) }
1.194    moreover
1.195    { assume az: "a \<noteq> 0" and bz: "b \<noteq> 0" and a'z: "a'\<noteq>0" and b'z: "b'\<noteq>0"
1.196 -    from az bz a'z b'z na nb have pos: "b > 0" "b' > 0" by (simp_all add: isnormNum_def)
1.197 -    from H bz b'z have eq:"a * b' = a'*b"
1.198 -      by (simp add: INum_def  eq_divide_eq divide_eq_eq of_int_mult[symmetric] del: of_int_mult)
1.199 -    from az a'z na nb have gcd1: "gcd a b = 1" "gcd b a = 1" "gcd a' b' = 1" "gcd b' a' = 1"
1.201 -    from eq have raw_dvd: "a dvd a'*b" "b dvd b'*a" "a' dvd a*b'" "b' dvd b*a'"
1.202 -      apply -
1.203 +    from az bz a'z b'z na nb have pos: "b > 0" "b' > 0" by (simp_all add: x y isnormNum_def)
1.204 +    from H bz b'z have eq: "a * b' = a'*b"
1.205 +      by (simp add: x y INum_def eq_divide_eq divide_eq_eq of_int_mult[symmetric] del: of_int_mult)
1.206 +    from az a'z na nb have gcd1: "gcd a b = 1" "gcd b a = 1" "gcd a' b' = 1" "gcd b' a' = 1"
1.208 +    from eq have raw_dvd: "a dvd a' * b" "b dvd b' * a" "a' dvd a * b'" "b' dvd b * a'"
1.209 +      apply -
1.210        apply algebra
1.211        apply algebra
1.212        apply simp
1.213        apply algebra
1.214        done
1.215      from zdvd_antisym_abs[OF coprime_dvd_mult_int[OF gcd1(2) raw_dvd(2)]
1.216 -      coprime_dvd_mult_int[OF gcd1(4) raw_dvd(4)]]
1.217 +        coprime_dvd_mult_int[OF gcd1(4) raw_dvd(4)]]
1.218        have eq1: "b = b'" using pos by arith
1.219        with eq have "a = a'" using pos by simp
1.220 -      with eq1 have ?rhs by simp}
1.221 +      with eq1 have ?rhs by (simp add: x y) }
1.222    ultimately show ?rhs by blast
1.223  next
1.224    assume ?rhs thus ?lhs by simp
1.225 @@ -195,7 +194,7 @@
1.226    unfolding INum_int(2)[symmetric]
1.227    by (rule isnormNum_unique) simp_all
1.228
1.229 -lemma of_int_div_aux: "d ~= 0 ==> ((of_int x)::'a::field_char_0) / (of_int d) =
1.230 +lemma of_int_div_aux: "d ~= 0 ==> ((of_int x)::'a::field_char_0) / (of_int d) =
1.231      of_int (x div d) + (of_int (x mod d)) / ((of_int d)::'a)"
1.232  proof -
1.233    assume "d ~= 0"
1.234 @@ -205,7 +204,7 @@
1.235      by auto
1.236    then have eq: "of_int x = ?t"
1.237      by (simp only: of_int_mult[symmetric] of_int_add [symmetric])
1.238 -  then have "of_int x / of_int d = ?t / of_int d"
1.239 +  then have "of_int x / of_int d = ?t / of_int d"
1.240      using cong[OF refl[of ?f] eq] by simp
1.241    then show ?thesis by (simp add: add_divide_distrib algebra_simps `d ~= 0`)
1.242  qed
1.243 @@ -220,12 +219,11 @@
1.244
1.245  lemma normNum[simp]: "INum (normNum x) = (INum x :: 'a::{field_char_0, field_inverse_zero})"
1.246  proof -
1.247 -  have "\<exists> a b. x = (a,b)" by auto
1.248 -  then obtain a b where x: "x = (a,b)" by blast
1.249 -  { assume "a=0 \<or> b = 0" hence ?thesis
1.250 -      by (simp add: x INum_def normNum_def split_def Let_def)}
1.251 -  moreover
1.252 -  { assume a: "a\<noteq>0" and b: "b\<noteq>0"
1.253 +  obtain a b where x: "x = (a, b)" by (cases x)
1.254 +  { assume "a = 0 \<or> b = 0"
1.255 +    hence ?thesis by (simp add: x INum_def normNum_def split_def Let_def) }
1.256 +  moreover
1.257 +  { assume a: "a \<noteq> 0" and b: "b \<noteq> 0"
1.258      let ?g = "gcd a b"
1.259      from a b have g: "?g \<noteq> 0"by simp
1.260      from of_int_div[OF g, where ?'a = 'a]
1.261 @@ -246,26 +244,26 @@
1.262  lemma Nadd[simp]: "INum (x +\<^sub>N y) = INum x + (INum y :: 'a :: {field_char_0, field_inverse_zero})"
1.263  proof -
1.264    let ?z = "0:: 'a"
1.265 -  have "\<exists>a b. x = (a,b)" " \<exists> a' b'. y = (a',b')" by auto
1.266 -  then obtain a b a' b' where x: "x = (a,b)"
1.267 -    and y[simp]: "y = (a',b')" by blast
1.268 +  obtain a b where x: "x = (a, b)" by (cases x)
1.269 +  obtain a' b' where y: "y = (a', b')" by (cases y)
1.270    { assume "a=0 \<or> a'= 0 \<or> b =0 \<or> b' = 0"
1.271 -    hence ?thesis
1.273 +    hence ?thesis
1.275        apply (cases "b= 0", simp_all add: INum_def)
1.276         apply (cases "a'= 0", simp_all)
1.277         apply (cases "b'= 0", simp_all)
1.278         done }
1.279 -  moreover
1.280 -  { assume aa':"a \<noteq> 0" "a'\<noteq> 0" and bb': "b \<noteq> 0" "b' \<noteq> 0"
1.281 +  moreover
1.282 +  { assume aa': "a \<noteq> 0" "a'\<noteq> 0" and bb': "b \<noteq> 0" "b' \<noteq> 0"
1.283      { assume z: "a * b' + b * a' = 0"
1.284        hence "of_int (a*b' + b*a') / (of_int b* of_int b') = ?z" by simp
1.285 -      hence "of_int b' * of_int a / (of_int b * of_int b') + of_int b * of_int a' / (of_int b * of_int b') = ?z"
1.287 +      hence "of_int b' * of_int a / (of_int b * of_int b') +
1.288 +          of_int b * of_int a' / (of_int b * of_int b') = ?z"
1.290        hence th: "of_int a / of_int b + of_int a' / of_int b' = ?z" using bb' aa'
1.291 -        by simp
1.292 -      from z aa' bb' have ?thesis
1.293 -        by (simp add: x th Nadd_def normNum_def INum_def split_def) }
1.294 +        by simp
1.295 +      from z aa' bb' have ?thesis
1.296 +        by (simp add: x y th Nadd_def normNum_def INum_def split_def) }
1.297      moreover {
1.298        assume z: "a * b' + b * a' \<noteq> 0"
1.299        let ?g = "gcd (a * b' + b * a') (b*b')"
1.300 @@ -273,29 +271,29 @@
1.301        have ?thesis using aa' bb' z gz
1.302          of_int_div[where ?'a = 'a, OF gz gcd_dvd1_int[where x="a * b' + b * a'" and y="b*b'"]]
1.303          of_int_div[where ?'a = 'a, OF gz gcd_dvd2_int[where x="a * b' + b * a'" and y="b*b'"]]
1.306      ultimately have ?thesis using aa' bb'
1.308 +      by (simp add: x y Nadd_def INum_def normNum_def Let_def) }
1.309    ultimately show ?thesis by blast
1.310  qed
1.311
1.312  lemma Nmul[simp]: "INum (x *\<^sub>N y) = INum x * (INum y:: 'a :: {field_char_0, field_inverse_zero})"
1.313  proof -
1.314    let ?z = "0::'a"
1.315 -  have "\<exists>a b. x = (a,b)" " \<exists> a' b'. y = (a',b')" by auto
1.316 -  then obtain a b a' b' where x: "x = (a,b)" and y: "y = (a',b')" by blast
1.317 +  obtain a b where x: "x = (a, b)" by (cases x)
1.318 +  obtain a' b' where y: "y = (a', b')" by (cases y)
1.319    { assume "a=0 \<or> a'= 0 \<or> b = 0 \<or> b' = 0"
1.320 -    hence ?thesis
1.321 +    hence ?thesis
1.322        apply (cases "a=0", simp_all add: x y Nmul_def INum_def Let_def)
1.323        apply (cases "b=0", simp_all)
1.324 -      apply (cases "a'=0", simp_all)
1.325 +      apply (cases "a'=0", simp_all)
1.326        done }
1.327    moreover
1.328    { assume z: "a \<noteq> 0" "a' \<noteq> 0" "b \<noteq> 0" "b' \<noteq> 0"
1.329      let ?g="gcd (a*a') (b*b')"
1.330      have gz: "?g \<noteq> 0" using z by simp
1.331      from z of_int_div[where ?'a = 'a, OF gz gcd_dvd1_int[where x="a*a'" and y="b*b'"]]
1.332 -      of_int_div[where ?'a = 'a , OF gz gcd_dvd2_int[where x="a*a'" and y="b*b'"]]
1.333 +      of_int_div[where ?'a = 'a , OF gz gcd_dvd2_int[where x="a*a'" and y="b*b'"]]
1.334      have ?thesis by (simp add: Nmul_def x y Let_def INum_def) }
1.335    ultimately show ?thesis by blast
1.336  qed
1.337 @@ -313,16 +311,16 @@
1.339
1.340  lemma Nlt0_iff[simp]:
1.341 -  assumes nx: "isnormNum x"
1.342 +  assumes nx: "isnormNum x"
1.343    shows "((INum x :: 'a :: {field_char_0, linordered_field_inverse_zero})< 0) = 0>\<^sub>N x"
1.344  proof -
1.345 -  have "\<exists> a b. x = (a,b)" by simp
1.346 -  then obtain a b where x[simp]:"x = (a,b)" by blast
1.347 -  {assume "a = 0" hence ?thesis by (simp add: Nlt0_def INum_def) }
1.348 +  obtain a b where x: "x = (a, b)" by (cases x)
1.349 +  { assume "a = 0" hence ?thesis by (simp add: x Nlt0_def INum_def) }
1.350    moreover
1.351 -  { assume a: "a\<noteq>0" hence b: "(of_int b::'a) > 0" using nx by (simp add: isnormNum_def)
1.352 +  { assume a: "a \<noteq> 0" hence b: "(of_int b::'a) > 0"
1.353 +      using nx by (simp add: x isnormNum_def)
1.354      from pos_divide_less_eq[OF b, where b="of_int a" and a="0::'a"]
1.355 -    have ?thesis by (simp add: Nlt0_def INum_def) }
1.356 +    have ?thesis by (simp add: x Nlt0_def INum_def) }
1.357    ultimately show ?thesis by blast
1.358  qed
1.359
1.360 @@ -330,13 +328,13 @@
1.361    assumes nx: "isnormNum x"
1.362    shows "((INum x :: 'a :: {field_char_0, linordered_field_inverse_zero}) \<le> 0) = 0\<ge>\<^sub>N x"
1.363  proof -
1.364 -  have "\<exists>a b. x = (a,b)" by simp
1.365 -  then obtain a b where x[simp]:"x = (a,b)" by blast
1.366 -  { assume "a = 0" hence ?thesis by (simp add: Nle0_def INum_def) }
1.367 +  obtain a b where x: "x = (a, b)" by (cases x)
1.368 +  { assume "a = 0" hence ?thesis by (simp add: x Nle0_def INum_def) }
1.369    moreover
1.370 -  { assume a: "a\<noteq>0" hence b: "(of_int b :: 'a) > 0" using nx by (simp add: isnormNum_def)
1.371 +  { assume a: "a \<noteq> 0" hence b: "(of_int b :: 'a) > 0"
1.372 +      using nx by (simp add: x isnormNum_def)
1.373      from pos_divide_le_eq[OF b, where b="of_int a" and a="0::'a"]
1.374 -    have ?thesis by (simp add: Nle0_def INum_def)}
1.375 +    have ?thesis by (simp add: x Nle0_def INum_def) }
1.376    ultimately show ?thesis by blast
1.377  qed
1.378
1.379 @@ -344,14 +342,13 @@
1.380    assumes nx: "isnormNum x"
1.381    shows "((INum x :: 'a :: {field_char_0, linordered_field_inverse_zero})> 0) = 0<\<^sub>N x"
1.382  proof -
1.383 -  have "\<exists> a b. x = (a,b)" by simp
1.384 -  then obtain a b where x[simp]:"x = (a,b)" by blast
1.385 -  { assume "a = 0" hence ?thesis by (simp add: Ngt0_def INum_def) }
1.386 +  obtain a b where x: "x = (a, b)" by (cases x)
1.387 +  { assume "a = 0" hence ?thesis by (simp add: x Ngt0_def INum_def) }
1.388    moreover
1.389 -  { assume a: "a\<noteq>0" hence b: "(of_int b::'a) > 0" using nx
1.390 -      by (simp add: isnormNum_def)
1.391 +  { assume a: "a \<noteq> 0" hence b: "(of_int b::'a) > 0" using nx
1.392 +      by (simp add: x isnormNum_def)
1.393      from pos_less_divide_eq[OF b, where b="of_int a" and a="0::'a"]
1.394 -    have ?thesis by (simp add: Ngt0_def INum_def) }
1.395 +    have ?thesis by (simp add: x Ngt0_def INum_def) }
1.396    ultimately show ?thesis by blast
1.397  qed
1.398
1.399 @@ -359,14 +356,13 @@
1.400    assumes nx: "isnormNum x"
1.401    shows "((INum x :: 'a :: {field_char_0, linordered_field_inverse_zero}) \<ge> 0) = 0\<le>\<^sub>N x"
1.402  proof -
1.403 -  have "\<exists> a b. x = (a,b)" by simp
1.404 -  then obtain a b where x[simp]:"x = (a,b)" by blast
1.405 -  { assume "a = 0" hence ?thesis by (simp add: Nge0_def INum_def) }
1.406 +  obtain a b where x: "x = (a, b)" by (cases x)
1.407 +  { assume "a = 0" hence ?thesis by (simp add: x Nge0_def INum_def) }
1.408    moreover
1.409    { assume "a \<noteq> 0" hence b: "(of_int b::'a) > 0" using nx
1.410 -      by (simp add: isnormNum_def)
1.411 +      by (simp add: x isnormNum_def)
1.412      from pos_le_divide_eq[OF b, where b="of_int a" and a="0::'a"]
1.413 -    have ?thesis by (simp add: Nge0_def INum_def) }
1.414 +    have ?thesis by (simp add: x Nge0_def INum_def) }
1.415    ultimately show ?thesis by blast
1.416  qed
1.417
1.418 @@ -405,7 +401,7 @@
1.419  lemma [simp]:
1.420    assumes "SORT_CONSTRAINT('a::{field_char_0, field_inverse_zero})"
1.421    shows "(0, b) +\<^sub>N y = normNum y"
1.422 -    and "(a, 0) +\<^sub>N y = normNum y"
1.423 +    and "(a, 0) +\<^sub>N y = normNum y"
1.424      and "x +\<^sub>N (0, b) = normNum x"
1.425      and "x +\<^sub>N (a, 0) = normNum x"
1.427 @@ -416,7 +412,7 @@
1.428
1.429  lemma normNum_nilpotent_aux[simp]:
1.430    assumes "SORT_CONSTRAINT('a::{field_char_0, field_inverse_zero})"
1.431 -  assumes nx: "isnormNum x"
1.432 +  assumes nx: "isnormNum x"
1.433    shows "normNum x = x"
1.434  proof -
1.435    let ?a = "normNum x"
1.436 @@ -471,10 +467,10 @@
1.437
1.438  lemma Nmul_assoc:
1.439    assumes "SORT_CONSTRAINT('a::{field_char_0, field_inverse_zero})"
1.440 -  assumes nx: "isnormNum x" and ny:"isnormNum y" and nz:"isnormNum z"
1.441 +  assumes nx: "isnormNum x" and ny: "isnormNum y" and nz: "isnormNum z"
1.442    shows "x *\<^sub>N y *\<^sub>N z = x *\<^sub>N (y *\<^sub>N z)"
1.443  proof -
1.444 -  from nx ny nz have n: "isnormNum (x *\<^sub>N y *\<^sub>N z)" "isnormNum (x *\<^sub>N (y *\<^sub>N z))"
1.445 +  from nx ny nz have n: "isnormNum (x *\<^sub>N y *\<^sub>N z)" "isnormNum (x *\<^sub>N (y *\<^sub>N z))"
1.446      by simp_all
1.447    have "INum (x +\<^sub>N y +\<^sub>N z) = (INum (x +\<^sub>N (y +\<^sub>N z)) :: 'a)" by simp
1.448    with isnormNum_unique[OF n] show ?thesis by simp
1.449 @@ -482,10 +478,11 @@
1.450
1.451  lemma Nsub0:
1.452    assumes "SORT_CONSTRAINT('a::{field_char_0, field_inverse_zero})"
1.453 -  assumes x: "isnormNum x" and y:"isnormNum y" shows "(x -\<^sub>N y = 0\<^sub>N) = (x = y)"
1.454 +  assumes x: "isnormNum x" and y: "isnormNum y"
1.455 +  shows "x -\<^sub>N y = 0\<^sub>N \<longleftrightarrow> x = y"
1.456  proof -
1.457    fix h :: 'a
1.458 -  from isnormNum_unique[where 'a = 'a, OF Nsub_normN[OF y], where y="0\<^sub>N"]
1.459 +  from isnormNum_unique[where 'a = 'a, OF Nsub_normN[OF y], where y="0\<^sub>N"]
1.460    have "(x -\<^sub>N y = 0\<^sub>N) = (INum (x -\<^sub>N y) = (INum 0\<^sub>N :: 'a)) " by simp
1.461    also have "\<dots> = (INum x = (INum y :: 'a))" by simp
1.462    also have "\<dots> = (x = y)" using x y by simp
1.463 @@ -497,26 +494,26 @@
1.464
1.465  lemma Nmul_eq0[simp]:
1.466    assumes "SORT_CONSTRAINT('a::{field_char_0, field_inverse_zero})"
1.467 -  assumes nx:"isnormNum x" and ny: "isnormNum y"
1.468 -  shows "(x*\<^sub>N y = 0\<^sub>N) = (x = 0\<^sub>N \<or> y = 0\<^sub>N)"
1.469 +  assumes nx: "isnormNum x" and ny: "isnormNum y"
1.470 +  shows "x*\<^sub>N y = 0\<^sub>N \<longleftrightarrow> x = 0\<^sub>N \<or> y = 0\<^sub>N"
1.471  proof -
1.472    fix h :: 'a
1.473 -  have " \<exists> a b a' b'. x = (a,b) \<and> y= (a',b')" by auto
1.474 -  then obtain a b a' b' where xy[simp]: "x = (a,b)" "y = (a',b')" by blast
1.475 +  obtain a b where x: "x = (a, b)" by (cases x)
1.476 +  obtain a' b' where y: "y = (a', b')" by (cases y)
1.477    have n0: "isnormNum 0\<^sub>N" by simp
1.478 -  show ?thesis using nx ny
1.479 +  show ?thesis using nx ny
1.480      apply (simp only: isnormNum_unique[where ?'a = 'a, OF  Nmul_normN[OF nx ny] n0, symmetric]
1.481        Nmul[where ?'a = 'a])
1.482 -    apply (simp add: INum_def split_def isnormNum_def split: split_if_asm)
1.483 +    apply (simp add: x y INum_def split_def isnormNum_def split: split_if_asm)
1.484      done
1.485  qed
1.486
1.487  lemma Nneg_Nneg[simp]: "~\<^sub>N (~\<^sub>N c) = c"
1.488    by (simp add: Nneg_def split_def)
1.489
1.490 -lemma Nmul1[simp]:
1.491 -  "isnormNum c \<Longrightarrow> 1\<^sub>N *\<^sub>N c = c"
1.492 -  "isnormNum c \<Longrightarrow> c *\<^sub>N (1\<^sub>N) = c"
1.493 +lemma Nmul1[simp]:
1.494 +    "isnormNum c \<Longrightarrow> 1\<^sub>N *\<^sub>N c = c"
1.495 +    "isnormNum c \<Longrightarrow> c *\<^sub>N (1\<^sub>N) = c"
1.496    apply (simp_all add: Nmul_def Let_def split_def isnormNum_def)
1.497    apply (cases "fst c = 0", simp_all, cases c, simp_all)+
1.498    done
```