src/HOL/Integ/Int.thy
changeset 14290 84fda1b39947
parent 14275 031a5a051bb4
child 14294 f4d806fd72ce
equal deleted inserted replaced
14289:deb8e1e62002 14290:84fda1b39947
   233 apply (rule int_zle_neg [THEN iffD1])
   233 apply (rule int_zle_neg [THEN iffD1])
   234 apply (drule sym)
   234 apply (drule sym)
   235 apply (simp_all (no_asm_simp))
   235 apply (simp_all (no_asm_simp))
   236 done
   236 done
   237 
   237 
   238 lemma zle_iff_zadd: "(w \<le> z) = (EX n. z = w + int n)"
   238 lemma zle_iff_zadd: "(w \<le> z) = (\<exists>n. z = w + int n)"
   239 by (force intro: exI [of _ "0::nat"] 
   239 by (force intro: exI [of _ "0::nat"] 
   240             intro!: not_sym [THEN not0_implies_Suc]
   240             intro!: not_sym [THEN not0_implies_Suc]
   241             simp add: zless_iff_Suc_zadd int_le_less)
   241             simp add: zless_iff_Suc_zadd int_le_less)
   242 
   242 
   243 lemma abs_int_eq [simp]: "abs (int m) = int m"
   243 lemma abs_int_eq [simp]: "abs (int m) = int m"
   319 
   319 
   320 lemma zmult_cancel1 [simp]: "(k*m = k*n) = (k = (0::int) | m=n)"
   320 lemma zmult_cancel1 [simp]: "(k*m = k*n) = (k = (0::int) | m=n)"
   321  by (rule Ring_and_Field.mult_cancel_left)
   321  by (rule Ring_and_Field.mult_cancel_left)
   322 
   322 
   323 
   323 
   324 subsection{*For the @{text abel_cancel} Simproc (DELETE)*}
       
   325 
       
   326 (* Lemmas needed for the simprocs *)
       
   327 
       
   328 (** The idea is to cancel like terms on opposite sides by subtraction **)
       
   329 
       
   330 lemma zless_eqI: "(x::int) - y = x' - y' ==> (x<y) = (x'<y')"
       
   331 by (simp add: zless_def)
       
   332 
       
   333 lemma zle_eqI: "(x::int) - y = x' - y' ==> (y<=x) = (y'<=x')"
       
   334 apply (drule zless_eqI)
       
   335 apply (simp (no_asm_simp) add: zle_def)
       
   336 done
       
   337 
       
   338 lemma zeq_eqI: "(x::int) - y = x' - y' ==> (x=y) = (x'=y')"
       
   339 apply safe
       
   340 apply (simp_all add: eq_diff_eq diff_eq_eq)
       
   341 done
       
   342 
       
   343 (*Deletion of other terms in the formula, seeking the -x at the front of z*)
       
   344 lemma zadd_cancel_21: "((x::int) + (y + z) = y + u) = ((x + z) = u)"
       
   345 apply (subst zadd_left_commute)
       
   346 apply (rule zadd_left_cancel)
       
   347 done
       
   348 
       
   349 (*A further rule to deal with the case that
       
   350   everything gets cancelled on the right.*)
       
   351 lemma zadd_cancel_end: "((x::int) + (y + z) = y) = (x = -z)"
       
   352 apply (subst zadd_left_commute)
       
   353 apply (rule_tac t = y in zadd_0_right [THEN subst], subst zadd_left_cancel)
       
   354 apply (simp add: eq_diff_eq [symmetric])
       
   355 done
       
   356 
       
   357 
       
   358 
       
   359 text{*A case theorem distinguishing non-negative and negative int*}
   324 text{*A case theorem distinguishing non-negative and negative int*}
   360 
   325 
   361 lemma negD: "neg x ==> EX n. x = - (int (Suc n))"
   326 lemma negD: "neg x ==> \<exists>n. x = - (int (Suc n))"
   362 by (auto simp add: neg_eq_less_0 zless_iff_Suc_zadd 
   327 by (auto simp add: neg_eq_less_0 zless_iff_Suc_zadd 
   363                    diff_eq_eq [symmetric] zdiff_def)
   328                    diff_eq_eq [symmetric] zdiff_def)
   364 
   329 
   365 lemma int_cases: 
   330 lemma int_cases: 
   366      "[|!! n. z = int n ==> P;  !! n. z =  - (int (Suc n)) ==> P |] ==> P"
   331      "[|!! n. z = int n ==> P;  !! n. z =  - (int (Suc n)) ==> P |] ==> P"
   373 (*Legacy ML bindings, but no longer the structure Int.*)
   338 (*Legacy ML bindings, but no longer the structure Int.*)
   374 ML
   339 ML
   375 {*
   340 {*
   376 val zabs_def = thm "zabs_def"
   341 val zabs_def = thm "zabs_def"
   377 val nat_def  = thm "nat_def"
   342 val nat_def  = thm "nat_def"
   378 
       
   379 val zless_eqI = thm "zless_eqI";
       
   380 val zle_eqI = thm "zle_eqI";
       
   381 val zeq_eqI = thm "zeq_eqI";
       
   382 
   343 
   383 val int_0 = thm "int_0";
   344 val int_0 = thm "int_0";
   384 val int_1 = thm "int_1";
   345 val int_1 = thm "int_1";
   385 val int_Suc0_eq_1 = thm "int_Suc0_eq_1";
   346 val int_Suc0_eq_1 = thm "int_Suc0_eq_1";
   386 val neg_eq_less_0 = thm "neg_eq_less_0";
   347 val neg_eq_less_0 = thm "neg_eq_less_0";