src/HOL/Nonstandard_Analysis/StarDef.thy
changeset 64270 bf474d719011
parent 64242 93c6f0da5c70
child 64290 fb5c74a58796
equal deleted inserted replaced
64266:4699d3b3173e 64270:bf474d719011
    76 text \<open>This introduction rule starts each transfer proof.\<close>
    76 text \<open>This introduction rule starts each transfer proof.\<close>
    77 lemma transfer_start:
    77 lemma transfer_start:
    78   "P \<equiv> eventually (\<lambda>n. Q) \<U> \<Longrightarrow> Trueprop P \<equiv> Trueprop Q"
    78   "P \<equiv> eventually (\<lambda>n. Q) \<U> \<Longrightarrow> Trueprop P \<equiv> Trueprop Q"
    79   by (simp add: FreeUltrafilterNat.proper)
    79   by (simp add: FreeUltrafilterNat.proper)
    80 
    80 
       
    81 text \<open>Standard principles that play a central role in the transfer tactic.\<close>
       
    82 definition
       
    83   Ifun :: "('a \<Rightarrow> 'b) star \<Rightarrow> 'a star \<Rightarrow> 'b star" ("_ \<star> _" [300,301] 300) where
       
    84   "Ifun f \<equiv> \<lambda>x. Abs_star
       
    85        (\<Union>F\<in>Rep_star f. \<Union>X\<in>Rep_star x. starrel``{\<lambda>n. F n (X n)})"
       
    86 
       
    87 lemma Ifun_congruent2:
       
    88   "congruent2 starrel starrel (\<lambda>F X. starrel``{\<lambda>n. F n (X n)})"
       
    89 by (auto simp add: congruent2_def equiv_starrel_iff elim!: eventually_rev_mp)
       
    90 
       
    91 lemma Ifun_star_n: "star_n F \<star> star_n X = star_n (\<lambda>n. F n (X n))"
       
    92 by (simp add: Ifun_def star_n_def Abs_star_inverse starrel_in_star
       
    93     UN_equiv_class2 [OF equiv_starrel equiv_starrel Ifun_congruent2])
       
    94 
       
    95 lemma transfer_Ifun:
       
    96   "\<lbrakk>f \<equiv> star_n F; x \<equiv> star_n X\<rbrakk> \<Longrightarrow> f \<star> x \<equiv> star_n (\<lambda>n. F n (X n))"
       
    97 by (simp only: Ifun_star_n)
       
    98 
       
    99 definition
       
   100   star_of :: "'a \<Rightarrow> 'a star" where
       
   101   "star_of x == star_n (\<lambda>n. x)"
       
   102 
    81 text \<open>Initialize transfer tactic.\<close>
   103 text \<open>Initialize transfer tactic.\<close>
    82 ML_file "transfer.ML"
   104 ML_file "transfer.ML"
    83 
   105 
    84 method_setup transfer = \<open>
   106 method_setup transfer = \<open>
    85   Attrib.thms >> (fn ths => fn ctxt =>
   107   Attrib.thms >> (fn ths => fn ctxt =>
   153 
   175 
   154 
   176 
   155 subsection \<open>Standard elements\<close>
   177 subsection \<open>Standard elements\<close>
   156 
   178 
   157 definition
   179 definition
   158   star_of :: "'a \<Rightarrow> 'a star" where
       
   159   "star_of x == star_n (\<lambda>n. x)"
       
   160 
       
   161 definition
       
   162   Standard :: "'a star set" where
   180   Standard :: "'a star set" where
   163   "Standard = range star_of"
   181   "Standard = range star_of"
   164 
   182 
   165 text \<open>Transfer tactic should remove occurrences of @{term star_of}\<close>
   183 text \<open>Transfer tactic should remove occurrences of @{term star_of}\<close>
   166 setup \<open>Transfer_Principle.add_const @{const_name star_of}\<close>
   184 setup \<open>Transfer_Principle.add_const @{const_name star_of}\<close>
   167 
   185 
   168 declare star_of_def [transfer_intro]
       
   169 
       
   170 lemma star_of_inject: "(star_of x = star_of y) = (x = y)"
   186 lemma star_of_inject: "(star_of x = star_of y) = (x = y)"
   171 by (transfer, rule refl)
   187 by (transfer, rule refl)
   172 
   188 
   173 lemma Standard_star_of [simp]: "star_of x \<in> Standard"
   189 lemma Standard_star_of [simp]: "star_of x \<in> Standard"
   174 by (simp add: Standard_def)
   190 by (simp add: Standard_def)
   175 
   191 
   176 
       
   177 subsection \<open>Internal functions\<close>
   192 subsection \<open>Internal functions\<close>
   178 
       
   179 definition
       
   180   Ifun :: "('a \<Rightarrow> 'b) star \<Rightarrow> 'a star \<Rightarrow> 'b star" ("_ \<star> _" [300,301] 300) where
       
   181   "Ifun f \<equiv> \<lambda>x. Abs_star
       
   182        (\<Union>F\<in>Rep_star f. \<Union>X\<in>Rep_star x. starrel``{\<lambda>n. F n (X n)})"
       
   183 
       
   184 lemma Ifun_congruent2:
       
   185   "congruent2 starrel starrel (\<lambda>F X. starrel``{\<lambda>n. F n (X n)})"
       
   186 by (auto simp add: congruent2_def equiv_starrel_iff elim!: eventually_rev_mp)
       
   187 
       
   188 lemma Ifun_star_n: "star_n F \<star> star_n X = star_n (\<lambda>n. F n (X n))"
       
   189 by (simp add: Ifun_def star_n_def Abs_star_inverse starrel_in_star
       
   190     UN_equiv_class2 [OF equiv_starrel equiv_starrel Ifun_congruent2])
       
   191 
   193 
   192 text \<open>Transfer tactic should remove occurrences of @{term Ifun}\<close>
   194 text \<open>Transfer tactic should remove occurrences of @{term Ifun}\<close>
   193 setup \<open>Transfer_Principle.add_const @{const_name Ifun}\<close>
   195 setup \<open>Transfer_Principle.add_const @{const_name Ifun}\<close>
   194 
       
   195 lemma transfer_Ifun [transfer_intro]:
       
   196   "\<lbrakk>f \<equiv> star_n F; x \<equiv> star_n X\<rbrakk> \<Longrightarrow> f \<star> x \<equiv> star_n (\<lambda>n. F n (X n))"
       
   197 by (simp only: Ifun_star_n)
       
   198 
   196 
   199 lemma Ifun_star_of [simp]: "star_of f \<star> star_of x = star_of (f x)"
   197 lemma Ifun_star_of [simp]: "star_of f \<star> star_of x = star_of (f x)"
   200 by (transfer, rule refl)
   198 by (transfer, rule refl)
   201 
   199 
   202 lemma Standard_Ifun [simp]:
   200 lemma Standard_Ifun [simp]: