(* Collecting stuff to move here *) theory Tmp_Move imports Complex_Bounded_Operators.Complex_Bounded_Linear_Function "HOL-Types_To_Sets.T2_Spaces" begin declare [[show_sorts=false]] \ \\<^theory>\HOL-Types_To_Sets.T2_Spaces\ leaves @{attribute show_sorts} enabled.\ unbundle lattice_syntax subsection \Retrieving axioms\ attribute_setup axiom = \Scan.lift Parse.name >> (fn name => Thm.rule_attribute [] (fn context => fn _ => Thm.axiom (Context.theory_of context) name))\ \ \Retrieves an axiom by name. E.g., write @{thm [source] [[axiom HOL.refl]]}. The fully qualified name is required.\ subsection \\csubspace.with\\ unoverload_definition complex_vector.subspace_def lemma csubspace_with_parametric[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(T ===> (T ===> T ===> T) ===> ((=) ===> T ===> T) ===> rel_set T ===> (=)) csubspace.with csubspace.with" unfolding csubspace.with_def apply transfer_prover_start apply transfer_step+ by simp lemma csubspace_nonempty: \csubspace V \ V \ {}\ using complex_vector.subspace_0 by auto subsection \\is_ortho_set.with\\ unoverload_definition is_ortho_set_def lemma is_ortho_set_with_parametric[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> (=)) ===> T ===> rel_set T ===> (=)) is_ortho_set.with is_ortho_set.with" unfolding is_ortho_set.with_def by transfer_prover subsection \\class.semigroup_add\\ definition \semigroup_add_on A plus \ (\a\A. \b\A. \c\A. plus (plus a b) c = plus a (plus b c))\ for A plus lemma semigroup_add_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> T) ===> (=)) (semigroup_add_on (Collect (Domainp T))) class.semigroup_add" unfolding class.semigroup_add_def apply transfer_prover_start apply transfer_step+ by (simp add: semigroup_add_on_def[abs_def]) lemma semigroup_add_on_typeclass[simp]: \semigroup_add_on V (+)\ for V :: \_::semigroup_add set\ by (auto simp: semigroup_add_on_def ordered_field_class.sign_simps) subsection \\class.ab_semigroup_add\\ definition \ab_semigroup_add_on A plus \ semigroup_add_on A plus \ (\a\A. \b\A. plus a b = plus b a)\ for A plus lemma ab_semigroup_add_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> T) ===> (=)) (ab_semigroup_add_on (Collect (Domainp T))) class.ab_semigroup_add" unfolding class.ab_semigroup_add_def class.ab_semigroup_add_axioms_def apply transfer_prover_start apply transfer_step+ by (simp add: ab_semigroup_add_on_def[abs_def]) lemma ab_semigroup_add_on_typeclass[simp]: \ab_semigroup_add_on V (+)\ for V :: \_::ab_semigroup_add set\ by (auto simp: ab_semigroup_add_on_def Groups.add_ac) subsection \\class.comm_monoid_add\\ definition \comm_monoid_add_on A plus zero \ ab_semigroup_add_on A plus \ (\a\A. plus zero a = a)\ for A plus zero lemma comm_monoid_add_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> T) ===> T ===> (=)) (comm_monoid_add_on (Collect (Domainp T))) class.comm_monoid_add" unfolding class.comm_monoid_add_def class.comm_monoid_add_axioms_def apply transfer_prover_start apply transfer_step+ by (simp add: comm_monoid_add_on_def[abs_def]) lemma comm_monoid_add_on_typeclass[simp]: \comm_monoid_add_on V (+) 0\ for V :: \_::comm_monoid_add set\ by (auto simp: comm_monoid_add_on_def) subsection \\class.ab_group_add\\ definition \ab_group_add_on A plus zero minus uminus \ comm_monoid_add_on A plus zero \ (\a\A. plus (uminus a) a = zero) \ (\a\A. \b\A. minus a b = plus a (uminus b))\ for A plus zero minus uminus lemma ab_group_add_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> T) ===> T ===> (T ===> T ===> T) ===> (T ===> T) ===> (=)) (ab_group_add_on (Collect (Domainp T))) class.ab_group_add" unfolding class.ab_group_add_def class.ab_group_add_axioms_def apply transfer_prover_start apply transfer_step+ by (simp add: ab_group_add_on_def[abs_def]) lemma ab_group_add_on_typeclass[simp]: \ab_group_add_on V (+) 0 (-) uminus\ for V :: \_::ab_group_add set\ by (auto simp: ab_group_add_on_def) subsection \\class.scaleC\\ definition \scaleC_on A scaleR scaleC \ (\r. \a\A. scaleR r a = scaleC (complex_of_real r) a)\ for scaleR scaleC lemma scaleC_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(((=) ===> T ===> T) ===> ((=) ===> T ===> T) ===> (=)) (scaleC_on (Collect (Domainp T))) class.scaleC" unfolding class.scaleC_def fun_eq_iff thm ext apply transfer_prover_start apply transfer_step+ by (simp add: scaleC_on_def[abs_def]) lemma scaleC_on_typeclass[simp]: \scaleC_on V (*\<^sub>R) (*\<^sub>C)\ by (auto simp: scaleC_on_def scaleR_scaleC) subsection \\class.complex_vector\\ definition \complex_vector_on A scaleR scaleC plus zero minus uminus \ scaleC_on A scaleR scaleC \ ab_group_add_on A plus zero minus uminus \ (\a. \x\A. \y\A. scaleC a (plus x y) = plus (scaleC a x) (scaleC a y)) \ (\a. \b. \x\A. scaleC (a + b) x = plus (scaleC a x) (scaleC b x)) \ (\a. \b. \x\A. scaleC a (scaleC b x) = scaleC (a * b) x) \ (\x\A. scaleC 1 x = x)\ for A scaleR scaleC plus zero minus uminus lemma complex_vector_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(((=) ===> T ===> T) ===> ((=) ===> T ===> T) ===> (T ===> T ===> T) ===> T ===> (T ===> T ===> T) ===> (T ===> T) ===> (=)) (complex_vector_on (Collect (Domainp T))) class.complex_vector" unfolding class.complex_vector_def class.complex_vector_axioms_def apply transfer_prover_start apply transfer_step+ by (simp add: complex_vector_on_def[abs_def]) lemma complex_vector_on_typeclass[simp]: \complex_vector_on V (*\<^sub>R) (*\<^sub>C) (+) 0 (-) uminus\ for V :: \_::complex_vector set\ by (auto simp add: complex_vector_on_def complex_vector.vector_space_assms) subsection \class.open_uniformity\ definition \open_uniformity_on A open uniformity \ (\U\A. open U = (\x\U. \\<^sub>F (x', y) in uniformity. x' = x \ y \ U))\ for A "open" uniformity lemma class_open_uniformity_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((rel_set T ===> (=)) ===> rel_filter (rel_prod T T) ===> (=)) (open_uniformity_on (Collect (Domainp T))) class.open_uniformity" unfolding class.open_uniformity_def apply transfer_prover_start apply transfer_step+ apply (auto intro!: ext simp: open_uniformity_on_def) by blast+ lemma open_uniformity_on_typeclass[simp]: fixes V :: \_::open_uniformity set\ assumes \closed V\ shows \open_uniformity_on V (openin (top_of_set V)) (uniformity_on V)\ proof (unfold open_uniformity_on_def, intro allI impI iffI) fix U assume \U \ V\ assume \openin (top_of_set V) U\ then obtain T where \U = T \ V\ and \open T\ by (metis Int_ac(3) openin_open) with open_uniformity have *: \\\<^sub>F (x', y) in uniformity. x' = x \ y \ T\ if \x \ T\ for x using that by blast have \\\<^sub>F (x', y) in uniformity_on V. x' = x \ y \ U\ if \x \ U\ for x apply (rule eventually_inf_principal[THEN iffD2]) using *[of x] apply (rule eventually_rev_mp) using \U = T \ V\ that by (auto intro!: always_eventually) then show \\x\U. \\<^sub>F (x', y) in uniformity_on V. x' = x \ y \ U\ by blast next fix U assume \U \ V\ assume asm: \\x\U. \\<^sub>F (x', y) in uniformity_on V. x' = x \ y \ U\ from asm[rule_format] have \\\<^sub>F (x', y) in uniformity. x' \ V \ y \ V \ x' = x \ y \ U \ -V\ if \x \ U\ for x unfolding eventually_inf_principal apply (rule eventually_rev_mp) using that by (auto intro!: always_eventually) then have xU: \\\<^sub>F (x', y) in uniformity. x' = x \ y \ U \ -V\ if \x \ U\ for x apply (rule eventually_rev_mp) using that \U \ V\ by (auto intro!: always_eventually) have \open (-V)\ using assms by auto with open_uniformity have \\\<^sub>F (x', y) in uniformity. x' = x \ y \ -V\ if \x \ -V\ for x using that by blast then have xV: \\\<^sub>F (x', y) in uniformity. x' = x \ y \ U \ -V\ if \x \ -V\ for x apply (rule eventually_rev_mp) apply (rule that) apply (rule always_eventually) by auto have \\\<^sub>F (x', y) in uniformity. x' = x \ y \ U \ -V\ if \x \ U \ -V\ for x using xV[of x] xU[of x] that by auto then have \open (U \ -V)\ using open_uniformity by blast then show \openin (top_of_set V) U\ using \U \ V\ by (auto intro!: exI simp: openin_open) qed subsection \\class.uniformity_dist\\ lemma top_filter_parametric': assumes \Domainp r = S\ assumes \right_total r\ shows \rel_filter r (principal (Collect S)) \\ proof (rule rel_filter.intros) define Z where \Z = principal {(x,y). r x y}\ show \\\<^sub>F (x, y) in Z. r x y\ by (simp add: eventually_principal Z_def) show \map_filter_on {(x, y). r x y} fst Z = principal (Collect S)\ using \Domainp r = S\ by (auto simp add: filter_eq_iff eventually_principal Z_def eventually_map_filter_on) show \map_filter_on {(x, y). r x y} snd Z = \\ apply (auto simp add: filter_eq_iff eventually_principal Z_def eventually_map_filter_on) by (metis assms(2) right_totalE) qed lemma Domainp_rel_filter: assumes \Domainp r = S\ shows \Domainp (rel_filter r) F \ (F \ principal (Collect S))\ proof (intro iffI, elim Domainp.cases, hypsubst) fix G assume \rel_filter r F G\ then obtain Z where rZ: \\\<^sub>F (x, y) in Z. r x y\ and ZF: "map_filter_on {(x, y). r x y} fst Z = F" and "map_filter_on {(x, y). r x y} snd Z = G" using rel_filter.simps by blast show \F \ principal (Collect S)\ using rZ apply (auto simp flip: ZF assms intro!: filter_leI simp: eventually_principal eventually_map_filter_on) by (smt (verit, best) DomainPI case_prod_beta eventually_elim2) next assume asm: \F \ principal (Collect S)\ define Z where \Z = inf (filtercomap fst F) (principal {(x, y). r x y})\ have rZ: \\\<^sub>F (x, y) in Z. r x y\ by (simp add: Z_def eventually_inf_principal) moreover have \(\\<^sub>F x in Z. P (fst x) \ (case x of (x, xa) \ r x xa)) = eventually P F\ for P using asm apply (auto simp add: le_principal Z_def eventually_inf_principal eventually_filtercomap) by (smt (verit, del_insts) DomainpE assms eventually_elim2) then have \map_filter_on {(x, y). r x y} fst Z = F\ by (simp add: filter_eq_iff eventually_map_filter_on rZ) ultimately show \Domainp (rel_filter r) F\ by (auto simp: Domainp_iff intro!: exI rel_filter.intros) qed lemma Inf_filter_parametric'[transfer_rule]: includes lifting_syntax fixes r :: \'rep \ 'abs \ bool\ assumes \Domainp r = S\ assumes [transfer_rule]: \bi_unique r\ \right_total r\ shows \(rel_set (rel_filter r) ===> rel_filter r) (\M. inf (Inf M) (principal (Collect S))) Inf\ proof (rule rel_funI) fix Fs Gs assume asm[transfer_rule]: \rel_set (rel_filter r) Fs Gs\ show \rel_filter r (inf (Inf Fs) (principal (Collect S))) (Inf Gs)\ proof (cases \Fs = {}\) case True then have \Gs = {}\ by (metis asm empty_iff equals0I rel_setD2) show ?thesis using assms by (simp add: True \Gs = {}\ top_filter_parametric') next case False then have \Gs \ {}\ by (metis asm ex_in_conv rel_setD1) have dom: \Domainp (rel_filter r) F = (F \ principal (Collect S))\ for F by (simp add: Domainp_rel_filter assms(1)) have 1: \(rel_filter r) (Sup {F. Ball Fs ((\) F) \ Domainp (rel_filter r) F}) (Inf Gs)\ (is \(rel_filter r) ?I _\) unfolding Inf_filter_def[abs_def] by transfer_prover have \F \ principal (Collect S)\ if \F \ Fs\ for F by (meson DomainPI asm dom rel_setD1 that) have \?I = (inf (Inf Fs) (principal (Collect S)))\ unfolding dom Inf_filter_def apply auto apply (rule antisym) apply auto apply (simp add: Collect_mono_iff Sup_subset_mono) apply (metis (no_types, lifting) Sup_least mem_Collect_eq) by (smt (verit, del_insts) Collect_mono False Sup_subset_mono \\Fa. Fa \ Fs \ Fa \ principal (Collect S)\ bot.extremum_unique dual_order.refl inf.bounded_iff order_trans subsetI) show ?thesis using "1" \Sup {F. Ball Fs ((\) F) \ Domainp (rel_filter r) F} = inf (Inf Fs) (principal (Collect S))\ by fastforce qed qed definition \uniformity_dist_on A dist uniformity \ uniformity = (\e\{0<..}. principal {(x, y)\A\A. dist x y < e})\ for dist uniformity lemma class_uniformity_dist_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> (=)) ===> rel_filter (rel_prod T T) ===> (=)) (uniformity_dist_on (Collect (Domainp T))) class.uniformity_dist" unfolding class.uniformity_dist_def apply transfer_prover_start apply transfer_step+ apply (intro ext) apply (simp add: case_prod_unfold pred_prod_beta uniformity_dist_on_def flip: INF_inf_const2) apply (rule arg_cong[where f=\\\. _ = (INF x\_. principal (\ x))\]) by (auto intro!: ext simp: prod.Domainp_rel) lemma uniformity_dist_on_typeclass[simp]: \uniformity_dist_on V dist (uniformity_on V)\ for V :: \_::uniformity_dist set\ apply (auto simp add: uniformity_dist_on_def uniformity_dist simp flip: INF_inf_const2) apply (subst asm_rl[of \\x. Restr {(xa, y). dist xa y < x} V = {(xa, y). xa \ V \ y \ V \ dist xa y < x}\, rule_format]) by auto subsection \\class.sgn_div_norm\\ definition \sgn_div_norm_on A sgn norm scaleR \ (\x\A. sgn x = scaleR (inverse (norm x)) x)\ for A sgn norm scaleR lemma sgn_div_norm_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T) ===> (T ===> (=)) ===> ((=) ===> T ===> T) ===> (=)) (sgn_div_norm_on (Collect (Domainp T))) class.sgn_div_norm" unfolding class.sgn_div_norm_def apply transfer_prover_start apply transfer_step+ by (simp add: sgn_div_norm_on_def[abs_def]) lemma sgn_div_norm_on_typeclass[simp]: \sgn_div_norm_on V sgn norm (*\<^sub>R)\ for V :: \_::sgn_div_norm set\ by (auto simp add: sgn_div_norm_on_def sgn_div_norm) subsection \\class.dist_norm\\ definition \dist_norm_on A minus dist norm \ (\x\A. \y\A. dist x y = norm (minus x y))\ for A minus dist norm lemma dist_norm_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> T) ===> (T ===> T ===> (=)) ===> (T ===> (=)) ===> (=)) (dist_norm_on (Collect (Domainp T))) class.dist_norm" unfolding class.dist_norm_def apply transfer_prover_start apply transfer_step+ by (simp add: dist_norm_on_def[abs_def]) lemma dist_norm_on_typeclass[simp]: \dist_norm_on V (-) dist norm\ for V :: \_::dist_norm set\ by (auto simp add: dist_norm_on_def dist_norm) subsection \\class.complex_inner\\ definition \complex_inner_on A scaleR scaleC plusa zeroa minus uminus dist norm sgn uniformity open cinner \ (complex_vector_on A scaleR scaleC plusa zeroa minus uminus \ dist_norm_on A minus dist norm \ sgn_div_norm_on A sgn norm scaleR) \ uniformity_dist_on A dist uniformity \ open_uniformity_on A open uniformity \ ((\x\A. \y\A. cinner x y = cnj (cinner y x)) \ (\x\A. \y\A. \z\A. cinner (plusa x y) z = cinner x z + cinner y z) \ (\r. \x\A. \y\A. cinner (scaleC r x) y = cnj r * cinner x y)) \ (\x\A. 0 \ cinner x x) \ (\x\A. (cinner x x = 0) = (x = zeroa)) \ (\x\A. norm x = sqrt (cmod (cinner x x)))\ for A scaleR scaleC plusa zeroa minus uminus dist norm sgn uniformity "open" cinner lemma complex_inner_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(((=) ===> T ===> T) ===> ((=) ===> T ===> T) ===> (T ===> T ===> T) ===> T ===> (T ===> T ===> T) ===> (T ===> T) ===> (T ===> T ===> (=)) ===> (T ===> (=)) ===> (T ===> T) ===> rel_filter (rel_prod T T) ===> (rel_set T ===> (=)) ===> (T ===> T ===> (=)) ===> (=)) (complex_inner_on (Collect (Domainp T))) class.complex_inner" unfolding class.complex_inner_def class.complex_inner_axioms_def apply transfer_prover_start apply transfer_step+ by (simp add: complex_inner_on_def[abs_def]) lemma complex_inner_on_typeclass[simp]: fixes V :: \_::complex_inner set\ assumes \closed V\ shows \complex_inner_on V (*\<^sub>R) (*\<^sub>C) (+) 0 (-) uminus dist norm sgn (uniformity_on V) (openin (top_of_set V)) (\\<^sub>C)\ apply (auto simp: assms complex_inner_on_def cinner_simps) using norm_eq_sqrt_cinner by blast subsection \\class.metric_space\\ definition \metric_space_on A dist uniformity open \ uniformity_dist_on A dist uniformity \ open_uniformity_on A open uniformity \ (\x\A. (\y\A. (dist x y = 0) \ (x = y))) \ (\x\A. (\y\A. (\z\A. dist x y \ dist x z + dist y z)))\ for A dist uniformity "open" lemma class_metric_space_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> (=)) ===> rel_filter (rel_prod T T) ===> (rel_set T ===> (=)) ===> (=)) (metric_space_on (Collect (Domainp T))) class.metric_space" unfolding class.metric_space_def class.metric_space_axioms_def apply transfer_prover_start apply transfer_step+ by (simp add: metric_space_on_def[abs_def]) lemma metric_space_on_typeclass[simp]: fixes V :: \_::metric_space set\ assumes \closed V\ shows \metric_space_on V dist (uniformity_on V) (openin (top_of_set V))\ by (auto simp: assms metric_space_on_def class.metric_space_axioms_def dist_triangle2) subsection \\topological_space.nhds\\ definition \nhds_on A open a = (\ (principal ` {S. S \ A \ open S \ a \ S})) \ principal A\ for A "open" a lemma nhds_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((rel_set T ===> (=)) ===> T ===> rel_filter T) (nhds_on (Collect (Domainp T))) topological_space.nhds" unfolding [[axiom Topological_Spaces.topological_space.nhds_def_raw]] apply transfer_prover_start apply transfer_step+ apply (intro ext) apply (simp add: nhds_on_def[abs_def]) apply (simp add: case_prod_unfold pred_prod_beta uniformity_dist_on_def flip: ) by (smt (verit) Collect_cong mem_Collect_eq subset_eq) lemma nhds_on_topology[simp]: \nhds_on (topspace T) (openin T) x = nhdsin T x\ if \x \ topspace T\ using that apply (auto intro!: ext simp add: nhds_on_def[abs_def] nhdsin_def[abs_def]) apply (subst INF_inf_const2[symmetric]) using openin_subset by (auto intro!: INF_cong) subsection \\filterlim\\ (* TODO: duplicated with Misc_Tensor_Product *) lemma filterlim_parametric[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: \bi_unique S\ shows \((R ===> S) ===> rel_filter S ===> rel_filter R ===> (=)) filterlim filterlim\ using filtermap_parametric[transfer_rule] le_filter_parametric[transfer_rule] apply fail? unfolding filterlim_def by transfer_prover subsection \\topological_space.convergent\\ definition \convergent_on A open X = (\L\A. filterlim X (nhds_on A open L) sequentially)\ for A "open" X lemma convergent_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((rel_set T ===> (=)) ===> ((=) ===> T) ===> (=)) (convergent_on (Collect (Domainp T))) topological_space.convergent" unfolding [[axiom Topological_Spaces.topological_space.convergent_def_raw]] apply transfer_prover_start apply transfer_step+ by (simp add: convergent_on_def[abs_def]) (* TODO: Duplicated with Misc_Tensor_Product *) lemma filterlim_nhdsin_iff_limitin: \l \ topspace T \ filterlim f (nhdsin T l) F \ limitin T f l F\ unfolding limitin_def filterlim_def eventually_filtermap le_filter_def eventually_nhdsin apply safe apply simp apply meson by (metis (mono_tags, lifting) eventually_mono) lemma convergent_on_topology[simp]: \convergent_on (topspace T) (openin T) f \ (\l. limitin T f l sequentially)\ by (auto simp: convergent_on_def simp flip: filterlim_nhdsin_iff_limitin) lemma convergent_on_typeclass[simp]: \convergent_on V (openin (top_of_set V)) f \ (\l. limitin (top_of_set V) f l sequentially)\ by (simp add: flip: convergent_on_topology) subsection \\uniform_space.cauchy_filter\\ lemma cauchy_filter_parametric[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(rel_filter (rel_prod T T) ===> rel_filter T ===> (=)) uniform_space.cauchy_filter uniform_space.cauchy_filter" unfolding [[axiom Topological_Spaces.uniform_space.cauchy_filter_def_raw]] by transfer_prover subsection \\uniform_space.Cauchy\\ lemma Cauchy_parametric[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(rel_filter (rel_prod T T) ===> ((=) ===> T) ===> (=)) uniform_space.Cauchy uniform_space.Cauchy" unfolding [[axiom Topological_Spaces.uniform_space.Cauchy_uniform_raw]] using filtermap_parametric[transfer_rule] apply fail? by transfer_prover subsection \\class.complete_space\\ definition \complete_space_on A dist uniformity open \ metric_space_on A dist uniformity open \ (\X. (\n. X n \ A) \ uniform_space.Cauchy uniformity X \ convergent_on A open X)\ for A dist uniformity "open" lemma complete_space_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> (=)) ===> rel_filter (rel_prod T T) ===> (rel_set T ===> (=)) ===> (=)) (complete_space_on (Collect (Domainp T))) class.complete_space" unfolding class.complete_space_def class.complete_space_axioms_def apply transfer_prover_start apply transfer_step+ by (simp add: complete_space_on_def[abs_def]) lemma complete_space_as_set[simp]: \complete (space_as_set V)\ for V :: \_::cbanach ccsubspace\ by (simp add: complete_eq_closed) lemma complete_space_on_typeclass[simp]: fixes V :: \_::uniform_space set\ assumes \complete V\ shows \complete_space_on V dist (uniformity_on V) (openin (top_of_set V))\ proof - have \\l. limitin (top_of_set V) X l sequentially\ if XV: \\n. X n \ V\ and cauchy: \uniform_space.Cauchy (uniformity_on V) X\ for X proof - from cauchy have \uniform_space.cauchy_filter (uniformity_on V) (filtermap X sequentially)\ by (simp add: [[axiom Topological_Spaces.uniform_space.Cauchy_uniform_raw]]) then have \cauchy_filter (filtermap X sequentially)\ by (auto simp: cauchy_filter_def [[axiom Topological_Spaces.uniform_space.cauchy_filter_def_raw]]) then have \Cauchy X\ by (simp add: Cauchy_uniform) with \complete V\ XV obtain l where l: \X \ l\ \l \ V\ apply atomize_elim by (meson completeE) with XV l show ?thesis by (auto intro!: exI[of _ l] simp: convergent_def limitin_subtopology) qed then show ?thesis by (auto simp: complete_space_on_def complete_imp_closed assms) qed subsection \\class.chilbert_space\\ definition \chilbert_space_on A scaleR scaleC plus zero minus uminus dist norm sgn uniformity open cinner \ complex_inner_on A scaleR scaleC plus zero minus uminus dist norm sgn uniformity open cinner \ complete_space_on A dist uniformity open\ for A scaleR scaleC plus zero minus uminus dist norm sgn uniformity "open" cinner lemma class_chilbert_space_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(((=) ===> T ===> T) ===> ((=) ===> T ===> T) ===> (T ===> T ===> T) ===> T ===> (T ===> T ===> T) ===> (T ===> T) ===> (T ===> T ===> (=)) ===> (T ===> (=)) ===> (T ===> T) ===> rel_filter (rel_prod T T) ===> (rel_set T ===> (=)) ===> (T ===> T ===> (=)) ===> (=)) (chilbert_space_on (Collect (Domainp T))) class.chilbert_space" unfolding class.chilbert_space_def apply transfer_prover_start apply transfer_step+ by (simp add: chilbert_space_on_def[abs_def]) lemma chilbert_space_on_typeclass[simp]: fixes V :: \_::complex_inner set\ assumes \complete V\ shows \chilbert_space_on V (*\<^sub>R) (*\<^sub>C) (+) 0 (-) uminus dist norm sgn (uniformity_on V) (openin (top_of_set V)) (\\<^sub>C)\ by (auto simp: chilbert_space_on_def assms complete_imp_closed) subsection \\hull\\ definition \hull_on A S s = \ {x. (S x \ s \ x) \ x \ A} \ A\ lemma hull_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((rel_set T ===> (=)) ===> rel_set T ===> rel_set T) (hull_on (Collect (Domainp T))) (hull)" unfolding hull_def apply transfer_prover_start apply transfer_step+ apply (intro ext) by (auto simp: hull_on_def) subsection \\cspan.with\\ unoverload_definition complex_vector.span_def definition \cspan_on A zero plus scaleC = hull_on A (csubspace.with zero plus scaleC)\ for A zero plus scaleC lemma cspan_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "(T ===> (T ===> T ===> T) ===> ((=) ===> T ===> T) ===> rel_set T ===> rel_set T) (cspan_on (Collect (Domainp T))) cspan.with" unfolding cspan.with_def apply transfer_prover_start apply transfer_step+ by (auto intro!: ext simp: cspan_on_def) lemma cspan_on_typeclass: \cspan_on V 0 (+) (*\<^sub>C) B = cspan B \ V\ if \csubspace V\ and \B \ V\ proof - have \\ {x. (csubspace x \ B \ x) \ x \ V} \ cspan B\ apply (rule Inf_lower2[where u=\cspan B \ V\]) by (auto simp: complex_vector.subspace_inter that complex_vector.span_clauses) moreover have \cspan B \ V \ \ {x. (csubspace x \ B \ x) \ x \ V}\ apply (rule Inf_greatest) using complex_vector.span_minimal by blast ultimately show ?thesis unfolding cspan_on_def hull_on_def csubspace.with[symmetric] by auto qed subsubsection \\<^const>\closure\\ unoverload_definition closure_def[unfolded islimpt_def] definition closure_on_with where \closure_on_with A opn S = S \ {x\A. \T\A. x \ T \ opn T \ (\y\S. y \ T \ y \ x)}\ lemma closure_with_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((rel_set T ===> (=)) ===> rel_set T ===> rel_set T) (closure_on_with (Collect (Domainp T))) closure.with" unfolding closure.with_def closure_on_with_def apply transfer_prover_start apply transfer_step+ unfolding Pow_def Ball_Collect[symmetric] Ball_def Bex_def mem_Collect_eq by blast lemma closure_on_with_typeclass[simp]: \closure_on_with X (openin (top_of_set X)) S = (X \ closure (X \ S)) \ S\ proof - have \closure_on_with X (openin (top_of_set X)) S = (top_of_set X) closure_of S \ S\ apply (simp add: closure_on_with_def closure_of_def) apply safe apply (meson openin_imp_subset) by auto also have \\ = (X \ closure (X \ S)) \ S\ by (simp add: closure_of_subtopology) finally show ?thesis by - qed subsection \\is_onb.with\\ lemma is_onb_def_no_ccsubspace: \is_onb E \ is_ortho_set E \ (\b\E. norm b = 1) \ closure (cspan E) = UNIV\ unfolding is_onb_def apply transfer by simp unoverload_definition is_onb_def_no_ccsubspace definition \is_onb_on A cinner zero norm open plus scaleC E \ is_ortho_set.with cinner zero E \ (\b\E. norm b = 1) \ closure_on_with A open (cspan_on A zero plus scaleC E) = A\ for A cinner zero norm "open" plus scaleC E lemma is_onb_with_transfer[transfer_rule]: includes lifting_syntax assumes [transfer_rule]: "right_total T" "bi_unique T" shows "((T ===> T ===> (=)) ===> T ===> (T ===> (=)) ===> (rel_set T ===> (=)) ===> (T ===> T ===> T) ===> ((=) ===> T ===> T) ===> rel_set T ===> (=)) (is_onb_on (Collect (Domainp T))) is_onb.with" using right_total_UNIV_transfer[transfer_rule] apply fail? unfolding is_onb.with_def apply transfer_prover_start apply transfer_step+ by (simp add: is_onb_on_def[abs_def]) subsection \Transferring a theorem\ (* The original theorem: *) print_statement orthonormal_basis_exists lemma orthonormal_subspace_basis_exists: fixes S :: \'a::chilbert_space set\ assumes \is_ortho_set S\ and norm: \\x. x\S \ norm x = 1\ and \S \ space_as_set V\ shows \\B. B \ S \ is_ortho_set B \ (\x\B. norm x = 1) \ ccspan B = V\ proof - { assume "\(Rep :: 't \ 'a) Abs. type_definition Rep Abs (space_as_set V)" then interpret T: local_typedef \space_as_set V\ \TYPE('t)\ by unfold_locales note orthonormal_basis_exists[unfolded is_onb.with is_ortho_set.with] note this[unoverload_type 'a] note this[where 'a='t] note this[untransferred] note this[where plus=plus and scaleC=scaleC and scaleR=scaleR and zero=0 and minus=minus and uminus=uminus and sgn=sgn and S=S and norm=norm and cinner=cinner and dist=dist and ?open=\openin (top_of_set (space_as_set V))\ and uniformity=\uniformity_on (space_as_set V)\] note this[simplified Domainp_rel_filter prod.Domainp_rel T.Domainp_cr_S] } note * = this[cancel_type_definition] have 1: \uniformity_on (space_as_set V) \ principal (Collect (pred_prod (\x. x \ space_as_set V) (\x. x \ space_as_set V)))\ by (auto simp: uniformity_dist intro!: le_infI2) have \\B\{A. \x\A. x \ space_as_set V}. S \ B \ is_onb_on {x. x \ space_as_set V} (\\<^sub>C) 0 norm (openin (top_of_set (space_as_set V))) (+) (*\<^sub>C) B\ apply (rule * ) using \S \ space_as_set V\ \is_ortho_set S\ by (auto simp add: simp flip: is_ortho_set.with intro!: complex_vector.subspace_scale real_vector.subspace_scale csubspace_is_subspace csubspace_nonempty complex_vector.subspace_add complex_vector.subspace_diff complex_vector.subspace_neg sgn_in_spaceI 1 norm) then obtain B where \B \ space_as_set V\ and \S \ B\ and is_onb: \is_onb_on (space_as_set V) (\\<^sub>C) 0 norm (openin (top_of_set (space_as_set V))) (+) (*\<^sub>C) B\ by auto from \B \ space_as_set V\ have [simp]: \cspan B \ space_as_set V = cspan B\ by (smt (verit) basic_trans_rules(8) ccspan.rep_eq ccspan_leqI ccspan_superset complex_vector.span_span inf_absorb1 less_eq_ccsubspace.rep_eq) then have [simp]: \space_as_set V \ cspan B = cspan B\ by blast from \B \ space_as_set V\ have [simp]: \space_as_set V \ closure (cspan B) = closure (cspan B)\ by (metis Int_absorb1 ccspan.rep_eq ccspan_leqI less_eq_ccsubspace.rep_eq) have [simp]: \closure X \ X = closure X\ for X :: \'z::topological_space set\ using closure_subset by blast from is_onb have \is_ortho_set B\ by (auto simp: is_onb_on_def is_ortho_set.with) moreover from is_onb have \norm x = 1\ if \x \ B\ for x by (auto simp: is_onb_on_def that) moreover from is_onb have \closure (cspan B) = space_as_set V\ by (simp add: is_onb_on_def \B \ space_as_set V\ cspan_on_typeclass closure_on_with_typeclass) then have \ccspan B = V\ by (simp add: ccspan.abs_eq space_as_set_inverse) ultimately show ?thesis using \S \ B\ by auto qed end