src/HOL/Real/RealInt.thy
author paulson
Thu, 01 Jan 2004 10:06:32 +0100
changeset 14334 6137d24eef79
parent 14290 84fda1b39947
permissions -rw-r--r--
tweaking of lemmas in RealDef, RealOrd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7292
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
     1
(*  Title:       RealInt.thy
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
     2
    ID:         $Id$
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
     3
    Author:      Jacques D. Fleuriot
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
     4
    Copyright:   1999 University of Edinburgh
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
     5
*)
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
     6
14269
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
     7
header{*Embedding the Integers into the Reals*}
7292
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
     8
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14290
diff changeset
     9
theory RealInt = RealDef:
14269
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    10
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    11
defs (overloaded)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    12
  real_of_int_def:
10919
144ede948e58 renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents: 10834
diff changeset
    13
   "real z == Abs_REAL(UN (i,j): Rep_Integ z. realrel ``
144ede948e58 renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents: 10834
diff changeset
    14
		       {(preal_of_prat(prat_of_pnat(pnat_of_nat i)),
144ede948e58 renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents: 10834
diff changeset
    15
			 preal_of_prat(prat_of_pnat(pnat_of_nat j)))})"
7292
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
    16
14269
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    17
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    18
lemma real_of_int_congruent: 
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    19
  "congruent intrel (%p. (%(i,j). realrel ``  
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    20
   {(preal_of_prat (prat_of_pnat (pnat_of_nat i)),  
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    21
     preal_of_prat (prat_of_pnat (pnat_of_nat j)))}) p)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    22
apply (unfold congruent_def)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    23
apply (auto simp add: pnat_of_nat_add prat_of_pnat_add [symmetric] preal_of_prat_add [symmetric])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    24
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    25
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    26
lemma real_of_int: 
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    27
   "real (Abs_Integ (intrel `` {(i, j)})) =  
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    28
      Abs_REAL(realrel ``  
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    29
        {(preal_of_prat (prat_of_pnat (pnat_of_nat i)),  
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    30
          preal_of_prat (prat_of_pnat (pnat_of_nat j)))})"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    31
apply (unfold real_of_int_def)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    32
apply (rule_tac f = Abs_REAL in arg_cong)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    33
apply (simp add: realrel_in_real [THEN Abs_REAL_inverse] 
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    34
             UN_equiv_class [OF equiv_intrel real_of_int_congruent])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    35
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    36
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    37
lemma inj_real_of_int: "inj(real :: int => real)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    38
apply (rule inj_onI)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    39
apply (rule_tac z = x in eq_Abs_Integ)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    40
apply (rule_tac z = y in eq_Abs_Integ)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    41
apply (auto dest!: inj_preal_of_prat [THEN injD] inj_prat_of_pnat [THEN injD]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    42
                   inj_pnat_of_nat [THEN injD]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    43
      simp add: real_of_int preal_of_prat_add [symmetric] prat_of_pnat_add [symmetric] pnat_of_nat_add)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    44
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    45
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    46
lemma real_of_int_zero: "real (int 0) = 0"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    47
apply (unfold int_def real_zero_def)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    48
apply (simp add: real_of_int preal_add_commute)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    49
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    50
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    51
lemma real_of_one: "real (1::int) = (1::real)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    52
apply (subst int_1 [symmetric])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    53
apply (auto simp add: int_def real_one_def real_of_int preal_of_prat_add [symmetric] pnat_two_eq prat_of_pnat_add [symmetric] pnat_one_iff [symmetric])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    54
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    55
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    56
lemma real_of_int_add: "real (x::int) + real y = real (x + y)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    57
apply (rule_tac z = x in eq_Abs_Integ)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    58
apply (rule_tac z = y in eq_Abs_Integ)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    59
apply (auto simp add: real_of_int preal_of_prat_add [symmetric]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    60
            prat_of_pnat_add [symmetric] zadd real_add pnat_of_nat_add pnat_add_ac)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    61
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    62
declare real_of_int_add [symmetric, simp]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    63
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    64
lemma real_of_int_minus: "-real (x::int) = real (-x)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    65
apply (rule_tac z = x in eq_Abs_Integ)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    66
apply (auto simp add: real_of_int real_minus zminus)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    67
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    68
declare real_of_int_minus [symmetric, simp]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    69
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    70
lemma real_of_int_diff: 
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    71
  "real (x::int) - real y = real (x - y)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    72
apply (unfold zdiff_def real_diff_def)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    73
apply (simp only: real_of_int_add real_of_int_minus)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    74
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    75
declare real_of_int_diff [symmetric, simp]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    76
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    77
lemma real_of_int_mult: "real (x::int) * real y = real (x * y)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    78
apply (rule_tac z = x in eq_Abs_Integ)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    79
apply (rule_tac z = y in eq_Abs_Integ)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    80
apply (auto simp add: real_of_int real_mult zmult
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    81
         preal_of_prat_mult [symmetric] pnat_of_nat_mult 
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    82
        prat_of_pnat_mult [symmetric] preal_of_prat_add [symmetric]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    83
        prat_of_pnat_add [symmetric] pnat_of_nat_add mult_ac add_ac pnat_add_ac)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    84
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    85
declare real_of_int_mult [symmetric, simp]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    86
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    87
lemma real_of_int_Suc: "real (int (Suc n)) = real (int n) + (1::real)"
14290
84fda1b39947 removal of abel_cancel from Real
paulson
parents: 14269
diff changeset
    88
by (simp add: real_of_one [symmetric] zadd_int add_ac)
14269
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    89
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    90
declare real_of_one [simp]
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    91
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    92
(* relating two of the embeddings *)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    93
lemma real_of_int_real_of_nat: "real (int n) = real n"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    94
apply (induct_tac "n")
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    95
apply (simp_all only: real_of_int_zero real_of_nat_zero real_of_int_Suc real_of_nat_Suc)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    96
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    97
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    98
lemma real_of_nat_real_of_int: "~neg z ==> real (nat z) = real z"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
    99
by (simp add: not_neg_eq_ge_0 real_of_int_real_of_nat [symmetric])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   100
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   101
lemma real_of_int_zero_cancel [simp]: "(real x = 0) = (x = int 0)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   102
by (auto intro: inj_real_of_int [THEN injD] 
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   103
         simp only: real_of_int_zero)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   104
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   105
lemma real_of_int_less_cancel: "real (x::int) < real y ==> x < y"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   106
apply (rule ccontr, drule linorder_not_less [THEN iffD1])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   107
apply (auto simp add: zle_iff_zadd real_of_int_add [symmetric] real_of_int_real_of_nat linorder_not_le [symmetric])
14290
84fda1b39947 removal of abel_cancel from Real
paulson
parents: 14269
diff changeset
   108
apply (subgoal_tac "~ real y + 0 \<le> real y + real n") 
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14290
diff changeset
   109
 prefer 2 apply simp 
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14290
diff changeset
   110
apply (simp only: add_le_cancel_left, simp) 
14269
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   111
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   112
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   113
lemma real_of_int_inject [iff]: "(real (x::int) = real y) = (x = y)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   114
by (blast dest!: inj_real_of_int [THEN injD])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   115
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   116
lemma real_of_int_less_mono: "x < y ==> (real (x::int) < real y)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   117
apply (simp add: linorder_not_le [symmetric])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   118
apply (auto dest!: real_of_int_less_cancel simp add: order_le_less)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   119
done
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   120
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   121
lemma real_of_int_less_iff [iff]: "(real (x::int) < real y) = (x < y)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   122
by (blast dest: real_of_int_less_cancel intro: real_of_int_less_mono)
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   123
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   124
lemma real_of_int_le_iff [simp]: "(real (x::int) \<le> real y) = (x \<le> y)"
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   125
by (simp add: linorder_not_less [symmetric])
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   126
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   127
ML
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   128
{*
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   129
val real_of_int_congruent = thm"real_of_int_congruent";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   130
val real_of_int = thm"real_of_int";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   131
val inj_real_of_int = thm"inj_real_of_int";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   132
val real_of_int_zero = thm"real_of_int_zero";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   133
val real_of_one = thm"real_of_one";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   134
val real_of_int_add = thm"real_of_int_add";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   135
val real_of_int_minus = thm"real_of_int_minus";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   136
val real_of_int_diff = thm"real_of_int_diff";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   137
val real_of_int_mult = thm"real_of_int_mult";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   138
val real_of_int_Suc = thm"real_of_int_Suc";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   139
val real_of_int_real_of_nat = thm"real_of_int_real_of_nat";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   140
val real_of_nat_real_of_int = thm"real_of_nat_real_of_int";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   141
val real_of_int_zero_cancel = thm"real_of_int_zero_cancel";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   142
val real_of_int_less_cancel = thm"real_of_int_less_cancel";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   143
val real_of_int_inject = thm"real_of_int_inject";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   144
val real_of_int_less_mono = thm"real_of_int_less_mono";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   145
val real_of_int_less_iff = thm"real_of_int_less_iff";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   146
val real_of_int_le_iff = thm"real_of_int_le_iff";
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   147
*}
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   148
502a7c95de73 conversion of some Real theories to Isar scripts
paulson
parents: 10919
diff changeset
   149
7292
dff3470c5c62 real literals using binary arithmetic
paulson
parents:
diff changeset
   150
end