src/HOL/Nonstandard_Analysis/Star.thy
author wenzelm
Thu, 15 Feb 2018 12:11:00 +0100
changeset 67613 ce654b0e6d69
parent 64435 c93b0e6131c3
child 70218 e48c0b5897a6
permissions -rw-r--r--
more symbols;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62479
716336f19aa9 clarified session;
wenzelm
parents: 61982
diff changeset
     1
(*  Title:      HOL/Nonstandard_Analysis/Star.thy
716336f19aa9 clarified session;
wenzelm
parents: 61982
diff changeset
     2
    Author:     Jacques D. Fleuriot
716336f19aa9 clarified session;
wenzelm
parents: 61982
diff changeset
     3
    Copyright:  1998  University of Cambridge
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     4
    Conversion to Isar and new proofs by Lawrence C Paulson, 2003/4
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     5
*)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     6
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
     7
section \<open>Star-Transforms in Non-Standard Analysis\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     8
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     9
theory Star
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    10
  imports NSA
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    11
begin
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    12
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    13
definition  \<comment> \<open>internal sets\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    14
  starset_n :: "(nat \<Rightarrow> 'a set) \<Rightarrow> 'a star set"  ("*sn* _" [80] 80)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    15
  where "*sn* As = Iset (star_n As)"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    16
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    17
definition InternalSets :: "'a star set set"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    18
  where "InternalSets = {X. \<exists>As. X = *sn* As}"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    19
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    20
definition  \<comment> \<open>nonstandard extension of function\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    21
  is_starext :: "('a star \<Rightarrow> 'a star) \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> bool"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    22
  where "is_starext F f \<longleftrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    23
    (\<forall>x y. \<exists>X \<in> Rep_star x. \<exists>Y \<in> Rep_star y. y = F x \<longleftrightarrow> eventually (\<lambda>n. Y n = f(X n)) \<U>)"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    24
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    25
definition  \<comment> \<open>internal functions\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    26
  starfun_n :: "(nat \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> 'a star \<Rightarrow> 'b star"  ("*fn* _" [80] 80)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    27
  where "*fn* F = Ifun (star_n F)"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    28
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    29
definition InternalFuns :: "('a star => 'b star) set"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    30
  where "InternalFuns = {X. \<exists>F. X = *fn* F}"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    31
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    32
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    33
subsection \<open>Preamble - Pulling \<open>\<exists>\<close> over \<open>\<forall>\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    34
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    35
text \<open>This proof does not need AC and was suggested by the
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    36
   referee for the JCM Paper: let \<open>f x\<close> be least \<open>y\<close> such
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    37
   that \<open>Q x y\<close>.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    38
lemma no_choice: "\<forall>x. \<exists>y. Q x y \<Longrightarrow> \<exists>f :: 'a \<Rightarrow> nat. \<forall>x. Q x (f x)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    39
  by (rule exI [where x = "\<lambda>x. LEAST y. Q x y"]) (blast intro: LeastI)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    40
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    41
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    42
subsection \<open>Properties of the Star-transform Applied to Sets of Reals\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    43
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    44
lemma STAR_star_of_image_subset: "star_of ` A \<subseteq> *s* A"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    45
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    46
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    47
lemma STAR_hypreal_of_real_Int: "*s* X \<inter> \<real> = hypreal_of_real ` X"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    48
  by (auto simp add: SReal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    49
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    50
lemma STAR_star_of_Int: "*s* X \<inter> Standard = star_of ` X"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    51
  by (auto simp add: Standard_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    52
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    53
lemma lemma_not_hyprealA: "x \<notin> hypreal_of_real ` A \<Longrightarrow> \<forall>y \<in> A. x \<noteq> hypreal_of_real y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    54
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    55
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    56
lemma lemma_not_starA: "x \<notin> star_of ` A \<Longrightarrow> \<forall>y \<in> A. x \<noteq> star_of y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    57
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    58
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    59
lemma lemma_Compl_eq: "- {n. X n = xa} = {n. X n \<noteq> xa}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    60
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    61
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    62
lemma STAR_real_seq_to_hypreal: "\<forall>n. (X n) \<notin> M \<Longrightarrow> star_n X \<notin> *s* M"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    63
  by (simp add: starset_def star_of_def Iset_star_n FreeUltrafilterNat.proper)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    64
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    65
lemma STAR_singleton: "*s* {x} = {star_of x}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    66
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    67
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    68
lemma STAR_not_mem: "x \<notin> F \<Longrightarrow> star_of x \<notin> *s* F"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    69
  by transfer
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    70
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    71
lemma STAR_subset_closed: "x \<in> *s* A \<Longrightarrow> A \<subseteq> B \<Longrightarrow> x \<in> *s* B"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    72
  by (erule rev_subsetD) simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    73
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    74
text \<open>Nonstandard extension of a set (defined using a constant
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    75
   sequence) as a special case of an internal set.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    76
lemma starset_n_starset: "\<forall>n. As n = A \<Longrightarrow> *sn* As = *s* A"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    77
  by (drule fun_eq_iff [THEN iffD2]) (simp add: starset_n_def starset_def star_of_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    78
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    79
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    80
subsection \<open>Theorems about nonstandard extensions of functions\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    81
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    82
text \<open>Nonstandard extension of a function (defined using a
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    83
  constant sequence) as a special case of an internal function.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    84
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    85
lemma starfun_n_starfun: "\<forall>n. F n = f \<Longrightarrow> *fn* F = *f* f"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    86
  apply (drule fun_eq_iff [THEN iffD2])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    87
  apply (simp add: starfun_n_def starfun_def star_of_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    88
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    89
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    90
text \<open>Prove that \<open>abs\<close> for hypreal is a nonstandard extension of abs for real w/o
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    91
  use of congruence property (proved after this for general
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    92
  nonstandard extensions of real valued functions).
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    93
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    94
  Proof now Uses the ultrafilter tactic!\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    95
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    96
lemma hrabs_is_starext_rabs: "is_starext abs abs"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    97
  apply (simp add: is_starext_def, safe)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    98
  apply (rule_tac x=x in star_cases)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    99
  apply (rule_tac x=y in star_cases)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   100
  apply (unfold star_n_def, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   101
  apply (rule bexI, rule_tac [2] lemma_starrel_refl)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   102
  apply (rule bexI, rule_tac [2] lemma_starrel_refl)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   103
  apply (fold star_n_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   104
  apply (unfold star_abs_def starfun_def star_of_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   105
  apply (simp add: Ifun_star_n star_n_eq_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   106
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   107
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   108
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   109
text \<open>Nonstandard extension of functions.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   110
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   111
lemma starfun: "( *f* f) (star_n X) = star_n (\<lambda>n. f (X n))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   112
  by (rule starfun_star_n)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   113
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   114
lemma starfun_if_eq: "\<And>w. w \<noteq> star_of x \<Longrightarrow> ( *f* (\<lambda>z. if z = x then a else g z)) w = ( *f* g) w"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   115
  by transfer simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   116
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   117
text \<open>Multiplication: \<open>( *f) x ( *g) = *(f x g)\<close>\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   118
lemma starfun_mult: "\<And>x. ( *f* f) x * ( *f* g) x = ( *f* (\<lambda>x. f x * g x)) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   119
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   120
declare starfun_mult [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   121
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   122
text \<open>Addition: \<open>( *f) + ( *g) = *(f + g)\<close>\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   123
lemma starfun_add: "\<And>x. ( *f* f) x + ( *f* g) x = ( *f* (\<lambda>x. f x + g x)) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   124
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   125
declare starfun_add [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   126
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   127
text \<open>Subtraction: \<open>( *f) + -( *g) = *(f + -g)\<close>\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   128
lemma starfun_minus: "\<And>x. - ( *f* f) x = ( *f* (\<lambda>x. - f x)) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   129
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   130
declare starfun_minus [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   131
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   132
(*FIXME: delete*)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   133
lemma starfun_add_minus: "\<And>x. ( *f* f) x + -( *f* g) x = ( *f* (\<lambda>x. f x + -g x)) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   134
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   135
declare starfun_add_minus [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   136
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   137
lemma starfun_diff: "\<And>x. ( *f* f) x  - ( *f* g) x = ( *f* (\<lambda>x. f x - g x)) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   138
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   139
declare starfun_diff [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   140
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   141
text \<open>Composition: \<open>( *f) \<circ> ( *g) = *(f \<circ> g)\<close>\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   142
lemma starfun_o2: "(\<lambda>x. ( *f* f) (( *f* g) x)) = *f* (\<lambda>x. f (g x))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   143
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   144
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   145
lemma starfun_o: "( *f* f) \<circ> ( *f* g) = ( *f* (f \<circ> g))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   146
  by (transfer o_def) (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   147
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   148
text \<open>NS extension of constant function.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   149
lemma starfun_const_fun [simp]: "\<And>x. ( *f* (\<lambda>x. k)) x = star_of k"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   150
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   151
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   152
text \<open>The NS extension of the identity function.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   153
lemma starfun_Id [simp]: "\<And>x. ( *f* (\<lambda>x. x)) x = x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   154
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   155
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   156
text \<open>This is trivial, given \<open>starfun_Id\<close>.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   157
lemma starfun_Idfun_approx: "x \<approx> star_of a \<Longrightarrow> ( *f* (\<lambda>x. x)) x \<approx> star_of a"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   158
  by (simp only: starfun_Id)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   159
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   160
text \<open>The Star-function is a (nonstandard) extension of the function.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   161
lemma is_starext_starfun: "is_starext ( *f* f) f"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   162
  apply (auto simp: is_starext_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   163
  apply (rule_tac x = x in star_cases)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   164
  apply (rule_tac x = y in star_cases)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   165
  apply (auto intro!: bexI [OF _ Rep_star_star_n] simp: starfun star_n_eq_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   166
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   167
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   168
text \<open>Any nonstandard extension is in fact the Star-function.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   169
lemma is_starfun_starext: "is_starext F f \<Longrightarrow> F = *f* f"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   170
  apply (simp add: is_starext_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   171
  apply (rule ext)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   172
  apply (rule_tac x = x in star_cases)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   173
  apply (drule_tac x = x in spec)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   174
  apply (drule_tac x = "( *f* f) x" in spec)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   175
  apply (auto simp add: starfun_star_n)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   176
  apply (simp add: star_n_eq_iff [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   177
  apply (simp add: starfun_star_n [of f, symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   178
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   179
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   180
lemma is_starext_starfun_iff: "is_starext F f \<longleftrightarrow> F = *f* f"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   181
  by (blast intro: is_starfun_starext is_starext_starfun)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   182
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   183
text \<open>Extented function has same solution as its standard version
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   184
  for real arguments. i.e they are the same for all real arguments.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   185
lemma starfun_eq: "( *f* f) (star_of a) = star_of (f a)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   186
  by (rule starfun_star_of)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   187
61982
3af5a06577c7 more symbols;
wenzelm
parents: 61975
diff changeset
   188
lemma starfun_approx: "( *f* f) (star_of a) \<approx> star_of (f a)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   189
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   190
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   191
text \<open>Useful for NS definition of derivatives.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   192
lemma starfun_lambda_cancel: "\<And>x'. ( *f* (\<lambda>h. f (x + h))) x'  = ( *f* f) (star_of x + x')"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   193
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   194
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   195
lemma starfun_lambda_cancel2: "( *f* (\<lambda>h. f (g (x + h)))) x' = ( *f* (f \<circ> g)) (star_of x + x')"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   196
  unfolding o_def by (rule starfun_lambda_cancel)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   197
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   198
lemma starfun_mult_HFinite_approx:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   199
  "( *f* f) x \<approx> l \<Longrightarrow> ( *f* g) x \<approx> m \<Longrightarrow> l \<in> HFinite \<Longrightarrow> m \<in> HFinite \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   200
    ( *f* (\<lambda>x. f x * g x)) x \<approx> l * m"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   201
  for l m :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   202
  apply (drule (3) approx_mult_HFinite)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   203
  apply (auto intro: approx_HFinite [OF _ approx_sym])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   204
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   205
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   206
lemma starfun_add_approx: "( *f* f) x \<approx> l \<Longrightarrow> ( *f* g) x \<approx> m \<Longrightarrow> ( *f* (%x. f x + g x)) x \<approx> l + m"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   207
  by (auto intro: approx_add)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   208
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   209
text \<open>Examples: \<open>hrabs\<close> is nonstandard extension of \<open>rabs\<close>,
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   210
  \<open>inverse\<close> is nonstandard extension of \<open>inverse\<close>.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   211
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   212
text \<open>Can be proved easily using theorem \<open>starfun\<close> and
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   213
  properties of ultrafilter as for inverse below we
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   214
  use the theorem we proved above instead.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   215
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   216
lemma starfun_rabs_hrabs: "*f* abs = abs"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   217
  by (simp only: star_abs_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   218
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   219
lemma starfun_inverse_inverse [simp]: "( *f* inverse) x = inverse x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   220
  by (simp only: star_inverse_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   221
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   222
lemma starfun_inverse: "\<And>x. inverse (( *f* f) x) = ( *f* (\<lambda>x. inverse (f x))) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   223
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   224
declare starfun_inverse [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   225
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   226
lemma starfun_divide: "\<And>x. ( *f* f) x / ( *f* g) x = ( *f* (\<lambda>x. f x / g x)) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   227
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   228
declare starfun_divide [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   229
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   230
lemma starfun_inverse2: "\<And>x. inverse (( *f* f) x) = ( *f* (\<lambda>x. inverse (f x))) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   231
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   232
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   233
text \<open>General lemma/theorem needed for proofs in elementary topology of the reals.\<close>
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 64435
diff changeset
   234
lemma starfun_mem_starset: "\<And>x. ( *f* f) x \<in> *s* A \<Longrightarrow> x \<in> *s* {x. f x \<in> A}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   235
  by transfer simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   236
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   237
text \<open>Alternative definition for \<open>hrabs\<close> with \<open>rabs\<close> function applied
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   238
  entrywise to equivalence class representative.
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   239
  This is easily proved using @{thm [source] starfun} and ns extension thm.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   240
lemma hypreal_hrabs: "\<bar>star_n X\<bar> = star_n (\<lambda>n. \<bar>X n\<bar>)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   241
  by (simp only: starfun_rabs_hrabs [symmetric] starfun)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   242
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   243
text \<open>Nonstandard extension of set through nonstandard extension
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   244
   of \<open>rabs\<close> function i.e. \<open>hrabs\<close>. A more general result should be
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   245
   where we replace \<open>rabs\<close> by some arbitrary function \<open>f\<close> and \<open>hrabs\<close>
61975
b4b11391c676 isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   246
   by its NS extenson. See second NS set extension below.\<close>
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   247
lemma STAR_rabs_add_minus: "*s* {x. \<bar>x + - y\<bar> < r} = {x. \<bar>x + -star_of y\<bar> < star_of r}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   248
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   249
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   250
lemma STAR_starfun_rabs_add_minus:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   251
  "*s* {x. \<bar>f x + - y\<bar> < r} = {x. \<bar>( *f* f) x + -star_of y\<bar> < star_of r}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   252
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   253
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   254
text \<open>Another characterization of Infinitesimal and one of \<open>\<approx>\<close> relation.
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   255
  In this theory since \<open>hypreal_hrabs\<close> proved here. Maybe move both theorems??\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   256
lemma Infinitesimal_FreeUltrafilterNat_iff2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   257
  "star_n X \<in> Infinitesimal \<longleftrightarrow> (\<forall>m. eventually (\<lambda>n. norm (X n) < inverse (real (Suc m))) \<U>)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   258
  by (simp add: Infinitesimal_hypreal_of_nat_iff star_of_def hnorm_def
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   259
      star_of_nat_def starfun_star_n star_n_inverse star_n_less)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   260
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   261
lemma HNatInfinite_inverse_Infinitesimal [simp]:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   262
  "n \<in> HNatInfinite \<Longrightarrow> inverse (hypreal_of_hypnat n) \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   263
  apply (cases n)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   264
  apply (auto simp: of_hypnat_def starfun_star_n star_n_inverse
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   265
    HNatInfinite_FreeUltrafilterNat_iff Infinitesimal_FreeUltrafilterNat_iff2)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   266
  apply (drule_tac x = "Suc m" in spec)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   267
  apply (auto elim!: eventually_mono)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   268
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   269
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   270
lemma approx_FreeUltrafilterNat_iff:
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   271
  "star_n X \<approx> star_n Y \<longleftrightarrow> (\<forall>r>0. eventually (\<lambda>n. norm (X n - Y n) < r) \<U>)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   272
  apply (subst approx_minus_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   273
  apply (rule mem_infmal_iff [THEN subst])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   274
  apply (simp add: star_n_diff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   275
  apply (simp add: Infinitesimal_FreeUltrafilterNat_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   276
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   277
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   278
lemma approx_FreeUltrafilterNat_iff2:
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   279
  "star_n X \<approx> star_n Y \<longleftrightarrow> (\<forall>m. eventually (\<lambda>n. norm (X n - Y n) < inverse (real (Suc m))) \<U>)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   280
  apply (subst approx_minus_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   281
  apply (rule mem_infmal_iff [THEN subst])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   282
  apply (simp add: star_n_diff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   283
  apply (simp add: Infinitesimal_FreeUltrafilterNat_iff2)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   284
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   285
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   286
lemma inj_starfun: "inj starfun"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   287
  apply (rule inj_onI)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   288
  apply (rule ext, rule ccontr)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   289
  apply (drule_tac x = "star_n (\<lambda>n. xa)" in fun_cong)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   290
  apply (auto simp add: starfun star_n_eq_iff FreeUltrafilterNat.proper)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   291
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   292
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   293
end