src/HOL/Hyperreal/HLog.thy
changeset 17298 ad73fb6144cf
parent 15140 322485b816ac
child 17318 bc1c75855f3d
equal deleted inserted replaced
17297:17256fe71aca 17298:ad73fb6144cf
    10 begin
    10 begin
    11 
    11 
    12 
    12 
    13 (* should be in NSA.ML *)
    13 (* should be in NSA.ML *)
    14 lemma epsilon_ge_zero [simp]: "0 \<le> epsilon"
    14 lemma epsilon_ge_zero [simp]: "0 \<le> epsilon"
    15 by (simp add: epsilon_def hypreal_zero_num hypreal_le)
    15 by (simp add: epsilon_def star_n_def hypreal_zero_num hypreal_le)
    16 
    16 
    17 lemma hpfinite_witness: "epsilon : {x. 0 \<le> x & x : HFinite}"
    17 lemma hpfinite_witness: "epsilon : {x. 0 \<le> x & x : HFinite}"
    18 by auto
    18 by auto
    19 
    19 
    20 
    20 
    22 
    22 
    23     powhr  :: "[hypreal,hypreal] => hypreal"     (infixr "powhr" 80)
    23     powhr  :: "[hypreal,hypreal] => hypreal"     (infixr "powhr" 80)
    24     "x powhr a == ( *f* exp) (a * ( *f* ln) x)"
    24     "x powhr a == ( *f* exp) (a * ( *f* ln) x)"
    25   
    25   
    26     hlog :: "[hypreal,hypreal] => hypreal"
    26     hlog :: "[hypreal,hypreal] => hypreal"
    27     "hlog a x == Abs_hypreal(\<Union>A \<in> Rep_hypreal(a).\<Union>X \<in> Rep_hypreal(x).
    27     "hlog a x == Abs_star(\<Union>A \<in> Rep_star(a).\<Union>X \<in> Rep_star(x).
    28 			     hyprel `` {%n. log (A n) (X n)})"
    28 			     starrel `` {%n. log (A n) (X n)})"
    29 
    29 
    30 
    30 
    31 lemma powhr: 
    31 lemma powhr: 
    32     "(Abs_hypreal(hyprel `` {X})) powhr (Abs_hypreal(hyprel `` {Y})) =  
    32     "(Abs_star(starrel `` {X})) powhr (Abs_star(starrel `` {Y})) =  
    33      Abs_hypreal(hyprel `` {%n.  (X n) powr (Y n)})"
    33      Abs_star(starrel `` {%n.  (X n) powr (Y n)})"
    34 by (simp add: powhr_def starfun hypreal_mult powr_def)
    34 by (simp add: powhr_def starfun hypreal_mult powr_def)
    35 
    35 
    36 lemma powhr_one_eq_one [simp]: "1 powhr a = 1"
    36 lemma powhr_one_eq_one [simp]: "1 powhr a = 1"
    37 apply (cases a)
    37 apply (rule_tac z=a in eq_Abs_star)
    38 apply (simp add: powhr hypreal_one_num)
    38 apply (simp add: powhr hypreal_one_num)
    39 done
    39 done
    40 
    40 
    41 lemma powhr_mult:
    41 lemma powhr_mult:
    42      "[| 0 < x; 0 < y |] ==> (x * y) powhr a = (x powhr a) * (y powhr a)"
    42      "[| 0 < x; 0 < y |] ==> (x * y) powhr a = (x powhr a) * (y powhr a)"
    43 apply (cases x, cases y, cases a)
    43 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star, rule_tac z=a in eq_Abs_star)
    44 apply (simp add: powhr hypreal_zero_num hypreal_mult hypreal_less, ultra)
    44 apply (simp add: powhr hypreal_zero_num hypreal_mult hypreal_less, ultra)
    45 apply (simp add: powr_mult) 
    45 apply (simp add: powr_mult) 
    46 done
    46 done
    47 
    47 
    48 lemma powhr_gt_zero [simp]: "0 < x powhr a"
    48 lemma powhr_gt_zero [simp]: "0 < x powhr a"
    49 apply (cases a, cases x)
    49 apply (rule_tac z=a in eq_Abs_star, rule_tac z=x in eq_Abs_star)
    50 apply (simp add: hypreal_zero_def powhr hypreal_less hypreal_zero_num)
    50 apply (simp add: hypreal_zero_def powhr hypreal_less hypreal_zero_num)
    51 done
    51 done
    52 
    52 
    53 lemma powhr_not_zero [simp]: "x powhr a \<noteq> 0"
    53 lemma powhr_not_zero [simp]: "x powhr a \<noteq> 0"
    54 by (rule powhr_gt_zero [THEN hypreal_not_refl2, THEN not_sym])
    54 by (rule powhr_gt_zero [THEN hypreal_not_refl2, THEN not_sym])
    55 
    55 
    56 lemma hypreal_divide: 
    56 lemma hypreal_divide: 
    57      "(Abs_hypreal(hyprel `` {X}))/(Abs_hypreal(hyprel `` {Y})) =  
    57      "(Abs_star(starrel `` {X}))/(Abs_star(starrel `` {Y})) =  
    58       (Abs_hypreal(hyprel `` {%n. (X n)/(Y n)}))"
    58       (Abs_star(starrel `` {%n. (X n::real)/(Y n)}))"
    59 by (simp add: divide_inverse hypreal_zero_num hypreal_inverse hypreal_mult) 
    59 by (simp add: divide_inverse hypreal_zero_num hypreal_inverse hypreal_mult) 
    60 
    60 
    61 lemma powhr_divide:
    61 lemma powhr_divide:
    62      "[| 0 < x; 0 < y |] ==> (x / y) powhr a = (x powhr a)/(y powhr a)"
    62      "[| 0 < x; 0 < y |] ==> (x / y) powhr a = (x powhr a)/(y powhr a)"
    63 apply (cases x, cases y, cases a)
    63 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star, rule_tac z=a in eq_Abs_star)
    64 apply (simp add: powhr hypreal_divide hypreal_zero_num hypreal_less, ultra)
    64 apply (simp add: powhr hypreal_divide hypreal_zero_num hypreal_less, ultra)
    65 apply (simp add: powr_divide)
    65 apply (simp add: powr_divide)
    66 done
    66 done
    67 
    67 
    68 lemma powhr_add: "x powhr (a + b) = (x powhr a) * (x powhr b)"
    68 lemma powhr_add: "x powhr (a + b) = (x powhr a) * (x powhr b)"
    69 apply (cases x, cases b, cases a)
    69 apply (rule_tac z=x in eq_Abs_star, rule_tac z=b in eq_Abs_star, rule_tac z=a in eq_Abs_star)
    70 apply (simp add: powhr hypreal_add hypreal_mult powr_add)
    70 apply (simp add: powhr hypreal_add hypreal_mult powr_add)
    71 done
    71 done
    72 
    72 
    73 lemma powhr_powhr: "(x powhr a) powhr b = x powhr (a * b)"
    73 lemma powhr_powhr: "(x powhr a) powhr b = x powhr (a * b)"
    74 apply (cases x, cases b, cases a)
    74 apply (rule_tac z=x in eq_Abs_star, rule_tac z=b in eq_Abs_star, rule_tac z=a in eq_Abs_star)
    75 apply (simp add: powhr hypreal_mult powr_powr)
    75 apply (simp add: powhr hypreal_mult powr_powr)
    76 done
    76 done
    77 
    77 
    78 lemma powhr_powhr_swap: "(x powhr a) powhr b = (x powhr b) powhr a"
    78 lemma powhr_powhr_swap: "(x powhr a) powhr b = (x powhr b) powhr a"
    79 apply (cases x, cases b, cases a)
    79 apply (rule_tac z=x in eq_Abs_star, rule_tac z=b in eq_Abs_star, rule_tac z=a in eq_Abs_star)
    80 apply (simp add: powhr powr_powr_swap)
    80 apply (simp add: powhr powr_powr_swap)
    81 done
    81 done
    82 
    82 
    83 lemma powhr_minus: "x powhr (-a) = inverse (x powhr a)"
    83 lemma powhr_minus: "x powhr (-a) = inverse (x powhr a)"
    84 apply (cases x, cases a)
    84 apply (rule_tac z=x in eq_Abs_star, rule_tac z=a in eq_Abs_star)
    85 apply (simp add: powhr hypreal_minus hypreal_inverse hypreal_less powr_minus)
    85 apply (simp add: powhr hypreal_minus hypreal_inverse hypreal_less powr_minus)
    86 done
    86 done
    87 
    87 
    88 lemma powhr_minus_divide: "x powhr (-a) = 1/(x powhr a)"
    88 lemma powhr_minus_divide: "x powhr (-a) = 1/(x powhr a)"
    89 by (simp add: divide_inverse powhr_minus)
    89 by (simp add: divide_inverse powhr_minus)
    90 
    90 
    91 lemma powhr_less_mono: "[| a < b; 1 < x |] ==> x powhr a < x powhr b"
    91 lemma powhr_less_mono: "[| a < b; 1 < x |] ==> x powhr a < x powhr b"
    92 apply (cases x, cases a, cases b)
    92 apply (rule_tac z=x in eq_Abs_star, rule_tac z=a in eq_Abs_star, rule_tac z=b in eq_Abs_star)
    93 apply (simp add: powhr hypreal_one_num hypreal_less, ultra)
    93 apply (simp add: powhr hypreal_one_num hypreal_less, ultra)
    94 done
    94 done
    95 
    95 
    96 lemma powhr_less_cancel: "[| x powhr a < x powhr b; 1 < x |] ==> a < b"
    96 lemma powhr_less_cancel: "[| x powhr a < x powhr b; 1 < x |] ==> a < b"
    97 apply (cases x, cases a, cases b)
    97 apply (rule_tac z=x in eq_Abs_star, rule_tac z=a in eq_Abs_star, rule_tac z=b in eq_Abs_star)
    98 apply (simp add: powhr hypreal_one_num hypreal_less, ultra)
    98 apply (simp add: powhr hypreal_one_num hypreal_less, ultra)
    99 done
    99 done
   100 
   100 
   101 lemma powhr_less_cancel_iff [simp]:
   101 lemma powhr_less_cancel_iff [simp]:
   102      "1 < x ==> (x powhr a < x powhr b) = (a < b)"
   102      "1 < x ==> (x powhr a < x powhr b) = (a < b)"
   105 lemma powhr_le_cancel_iff [simp]:
   105 lemma powhr_le_cancel_iff [simp]:
   106      "1 < x ==> (x powhr a \<le> x powhr b) = (a \<le> b)"
   106      "1 < x ==> (x powhr a \<le> x powhr b) = (a \<le> b)"
   107 by (simp add: linorder_not_less [symmetric])
   107 by (simp add: linorder_not_less [symmetric])
   108 
   108 
   109 lemma hlog: 
   109 lemma hlog: 
   110      "hlog (Abs_hypreal(hyprel `` {X})) (Abs_hypreal(hyprel `` {Y})) =  
   110      "hlog (Abs_star(starrel `` {X})) (Abs_star(starrel `` {Y})) =  
   111       Abs_hypreal(hyprel `` {%n. log (X n) (Y n)})"
   111       Abs_star(starrel `` {%n. log (X n) (Y n)})"
   112 apply (simp add: hlog_def)
   112 apply (simp add: hlog_def)
   113 apply (rule arg_cong [where f=Abs_hypreal], auto, ultra)
   113 apply (rule arg_cong [where f=Abs_star], auto, ultra)
   114 done
   114 done
   115 
   115 
   116 lemma hlog_starfun_ln: "( *f* ln) x = hlog (( *f* exp) 1) x"
   116 lemma hlog_starfun_ln: "( *f* ln) x = hlog (( *f* exp) 1) x"
   117 apply (cases x)
   117 apply (rule_tac z=x in eq_Abs_star)
   118 apply (simp add: starfun hlog log_ln hypreal_one_num)
   118 apply (simp add: starfun hlog log_ln hypreal_one_num)
   119 done
   119 done
   120 
   120 
   121 lemma powhr_hlog_cancel [simp]:
   121 lemma powhr_hlog_cancel [simp]:
   122      "[| 0 < a; a \<noteq> 1; 0 < x |] ==> a powhr (hlog a x) = x"
   122      "[| 0 < a; a \<noteq> 1; 0 < x |] ==> a powhr (hlog a x) = x"
   123 apply (cases x, cases a)
   123 apply (rule_tac z=x in eq_Abs_star, rule_tac z=a in eq_Abs_star)
   124 apply (simp add: hlog powhr hypreal_zero_num hypreal_less hypreal_one_num, ultra)
   124 apply (simp add: hlog powhr hypreal_zero_num hypreal_less hypreal_one_num, ultra)
   125 done
   125 done
   126 
   126 
   127 lemma hlog_powhr_cancel [simp]:
   127 lemma hlog_powhr_cancel [simp]:
   128      "[| 0 < a; a \<noteq> 1 |] ==> hlog a (a powhr y) = y"
   128      "[| 0 < a; a \<noteq> 1 |] ==> hlog a (a powhr y) = y"
   129 apply (cases y, cases a)
   129 apply (rule_tac z=y in eq_Abs_star, rule_tac z=a in eq_Abs_star)
   130 apply (simp add: hlog powhr hypreal_zero_num hypreal_less hypreal_one_num, ultra)
   130 apply (simp add: hlog powhr hypreal_zero_num hypreal_less hypreal_one_num, ultra)
   131 apply (auto intro: log_powr_cancel) 
   131 apply (auto intro: log_powr_cancel) 
   132 done
   132 done
   133 
   133 
   134 lemma hlog_mult:
   134 lemma hlog_mult:
   135      "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y  |]  
   135      "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y  |]  
   136       ==> hlog a (x * y) = hlog a x + hlog a y"
   136       ==> hlog a (x * y) = hlog a x + hlog a y"
   137 apply (cases x, cases y, cases a)
   137 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star, rule_tac z=a in eq_Abs_star)
   138 apply (simp add: hlog powhr hypreal_zero_num hypreal_one_num hypreal_less hypreal_add hypreal_mult, ultra)
   138 apply (simp add: hlog powhr hypreal_zero_num hypreal_one_num hypreal_less hypreal_add hypreal_mult, ultra)
   139 apply (simp add: log_mult)
   139 apply (simp add: log_mult)
   140 done
   140 done
   141 
   141 
   142 lemma hlog_as_starfun:
   142 lemma hlog_as_starfun:
   143      "[| 0 < a; a \<noteq> 1 |] ==> hlog a x = ( *f* ln) x / ( *f* ln) a"
   143      "[| 0 < a; a \<noteq> 1 |] ==> hlog a x = ( *f* ln) x / ( *f* ln) a"
   144 apply (cases x, cases a)
   144 apply (rule_tac z=x in eq_Abs_star, rule_tac z=a in eq_Abs_star)
   145 apply (simp add: hlog starfun hypreal_zero_num hypreal_one_num hypreal_divide log_def)
   145 apply (simp add: hlog starfun hypreal_zero_num hypreal_one_num hypreal_divide log_def)
   146 done
   146 done
   147 
   147 
   148 lemma hlog_eq_div_starfun_ln_mult_hlog:
   148 lemma hlog_eq_div_starfun_ln_mult_hlog:
   149      "[| 0 < a; a \<noteq> 1; 0 < b; b \<noteq> 1; 0 < x |]  
   149      "[| 0 < a; a \<noteq> 1; 0 < b; b \<noteq> 1; 0 < x |]  
   150       ==> hlog a x = (( *f* ln) b/( *f*ln) a) * hlog b x"
   150       ==> hlog a x = (( *f* ln) b/( *f*ln) a) * hlog b x"
   151 apply (cases x, cases a, cases b)
   151 apply (rule_tac z=x in eq_Abs_star, rule_tac z=a in eq_Abs_star, rule_tac z=b in eq_Abs_star)
   152 apply (simp add: hlog starfun hypreal_zero_num hypreal_one_num hypreal_less hypreal_divide hypreal_mult, ultra)
   152 apply (simp add: hlog starfun hypreal_zero_num hypreal_one_num hypreal_less hypreal_divide hypreal_mult, ultra)
   153 apply (auto dest: log_eq_div_ln_mult_log) 
   153 apply (auto dest: log_eq_div_ln_mult_log) 
   154 done
   154 done
   155 
   155 
   156 lemma powhr_as_starfun: "x powhr a = ( *f* exp) (a * ( *f* ln) x)"
   156 lemma powhr_as_starfun: "x powhr a = ( *f* exp) (a * ( *f* ln) x)"
   157 apply (cases a, cases x)
   157 apply (rule_tac z=a in eq_Abs_star, rule_tac z=x in eq_Abs_star)
   158 apply (simp add: powhr starfun hypreal_mult powr_def)
   158 apply (simp add: powhr starfun hypreal_mult powr_def)
   159 done
   159 done
   160 
   160 
   161 lemma HInfinite_powhr:
   161 lemma HInfinite_powhr:
   162      "[| x : HInfinite; 0 < x; a : HFinite - Infinitesimal;  
   162      "[| x : HInfinite; 0 < x; a : HFinite - Infinitesimal;  
   178 lemma hlog_HInfinite_as_starfun:
   178 lemma hlog_HInfinite_as_starfun:
   179      "[| a : HInfinite; 0 < a |] ==> hlog a x = ( *f* ln) x / ( *f* ln) a"
   179      "[| a : HInfinite; 0 < a |] ==> hlog a x = ( *f* ln) x / ( *f* ln) a"
   180 by (rule hlog_as_starfun, auto)
   180 by (rule hlog_as_starfun, auto)
   181 
   181 
   182 lemma hlog_one [simp]: "hlog a 1 = 0"
   182 lemma hlog_one [simp]: "hlog a 1 = 0"
   183 apply (cases a)
   183 apply (rule_tac z=a in eq_Abs_star)
   184 apply (simp add: hypreal_one_num hypreal_zero_num hlog)
   184 apply (simp add: hypreal_one_num hypreal_zero_num hlog)
   185 done
   185 done
   186 
   186 
   187 lemma hlog_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> hlog a a = 1"
   187 lemma hlog_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> hlog a a = 1"
   188 apply (cases a)
   188 apply (rule_tac z=a in eq_Abs_star)
   189 apply (simp add: hypreal_one_num hypreal_zero_num hlog hypreal_less, ultra)
   189 apply (simp add: hypreal_one_num hypreal_zero_num hlog hypreal_less, ultra)
   190 apply (auto intro: log_eq_one) 
   190 apply (auto intro: log_eq_one) 
   191 done
   191 done
   192 
   192 
   193 lemma hlog_inverse:
   193 lemma hlog_inverse:
   200      "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y|] ==> hlog a (x/y) = hlog a x - hlog a y"
   200      "[| 0 < a; a \<noteq> 1; 0 < x; 0 < y|] ==> hlog a (x/y) = hlog a x - hlog a y"
   201 by (simp add: hlog_mult hlog_inverse divide_inverse)
   201 by (simp add: hlog_mult hlog_inverse divide_inverse)
   202 
   202 
   203 lemma hlog_less_cancel_iff [simp]:
   203 lemma hlog_less_cancel_iff [simp]:
   204      "[| 1 < a; 0 < x; 0 < y |] ==> (hlog a x < hlog a y) = (x < y)"
   204      "[| 1 < a; 0 < x; 0 < y |] ==> (hlog a x < hlog a y) = (x < y)"
   205 apply (cases a, cases x, cases y)
   205 apply (rule_tac z=a in eq_Abs_star, rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star)
   206 apply (auto simp add: hlog hypreal_less hypreal_zero_num hypreal_one_num, ultra+)
   206 apply (auto simp add: hlog hypreal_less hypreal_zero_num hypreal_one_num, ultra+)
   207 done
   207 done
   208 
   208 
   209 lemma hlog_le_cancel_iff [simp]:
   209 lemma hlog_le_cancel_iff [simp]:
   210      "[| 1 < a; 0 < x; 0 < y |] ==> (hlog a x \<le> hlog a y) = (x \<le> y)"
   210      "[| 1 < a; 0 < x; 0 < y |] ==> (hlog a x \<le> hlog a y) = (x \<le> y)"