diff --git a/thys/Complex_Bounded_Operators/Cblinfun_Code.thy b/thys/Complex_Bounded_Operators/Cblinfun_Code.thy --- a/thys/Complex_Bounded_Operators/Cblinfun_Code.thy +++ b/thys/Complex_Bounded_Operators/Cblinfun_Code.thy @@ -1,659 +1,661 @@ section \\Cblinfun_Code\ -- Support for code generation\ text \This theory provides support for code generation involving on complex vector spaces and bounded operators (e.g., types \cblinfun\ and \ell2\). To fully support code generation, in addition to importing this theory, one need to activate support for code generation (import theory \Jordan_Normal_Form.Matrix_Impl\) and for real and complex numbers (import theory \Real_Impl.Real_Impl\ for support of reals of the form \a + b * sqrt c\ or \Algebraic_Numbers.Real_Factorization\ (much slower) for support of algebraic reals; support of complex numbers comes "for free"). The builtin support for real and complex numbers (in \Complex_Main\) is not sufficient because it does not support the computation of square-roots which are used in the setup below. It is also recommended to import \HOL-Library.Code_Target_Numeral\ for faster support of nats and integers.\ theory Cblinfun_Code imports Cblinfun_Matrix Containers.Set_Impl Jordan_Normal_Form.Matrix_Kernel begin no_notation "Lattice.meet" (infixl "\\" 70) no_notation "Lattice.join" (infixl "\\" 65) hide_const (open) Coset.kernel hide_const (open) Matrix_Kernel.kernel hide_const (open) Order.bottom Order.top +unbundle lattice_syntax unbundle jnf_notation unbundle cblinfun_notation subsection \Code equations for cblinfun operators\ text \In this subsection, we define the code for all operations involving only operators (no combinations of operators/vectors/subspaces)\ text \The following lemma registers cblinfun as an abstract datatype with constructor \<^const>\cblinfun_of_mat\. That means that in generated code, all cblinfun operators will be represented as \<^term>\cblinfun_of_mat X\ where X is a matrix. In code equations for operations involving operators (e.g., +), we can then write the equation directly in terms of matrices by writing, e.g., \<^term>\mat_of_cblinfun (A+B)\ in the lhs, and in the rhs we define the matrix that corresponds to the sum of A,B. In the rhs, we can access the matrices corresponding to A,B by writing \<^term>\mat_of_cblinfun B\. (See, e.g., lemma \cblinfun_of_mat_plusOp\ below). See @{cite "code-generation-tutorial"} for more information on @{theory_text \[code abstype]\}.\ declare mat_of_cblinfun_inverse [code abstype] text \This lemma defines addition. By writing \<^term>\mat_of_cblinfun (M + N)\ on the left hand side, we get access to the\ declare mat_of_cblinfun_plus[code] \ \Code equation for addition of cblinfuns\ declare mat_of_cblinfun_id[code] \ \Code equation for computing the identity operator\ declare mat_of_cblinfun_1[code] \ \Code equation for computing the one-dimensional identity\ declare mat_of_cblinfun_zero[code] \ \Code equation for computing the zero operator\ declare mat_of_cblinfun_uminus[code] \ \Code equation for computing the unary minus on cblinfun's\ declare mat_of_cblinfun_minus[code] \ \Code equation for computing the difference of cblinfun's\ declare mat_of_cblinfun_classical_operator[code] \ \Code equation for computing the "classical operator"\ declare mat_of_cblinfun_compose[code] \ \Code equation for computing the composition/product of cblinfun's\ declare mat_of_cblinfun_scaleC[code] \ \Code equation for multiplication with complex scalar\ declare mat_of_cblinfun_scaleR[code] \ \Code equation for multiplication with real scalar\ declare mat_of_cblinfun_adj[code] \ \Code equation for computing the adj\ text \This instantiation defines a code equation for equality tests for cblinfun.\ instantiation cblinfun :: (onb_enum,onb_enum) equal begin definition [code]: "equal_cblinfun M N \ mat_of_cblinfun M = mat_of_cblinfun N" for M N :: "'a \\<^sub>C\<^sub>L 'b" instance apply intro_classes unfolding equal_cblinfun_def using mat_of_cblinfun_inj injD by fastforce end subsection \Vectors\ text \In this section, we define code for operations on vectors. As with operators above, we do this by using an isomorphism between finite vectors (i.e., types T of sort \complex_vector\) and the type \<^typ>\complex vec\ from \<^session>\Jordan_Normal_Form\. We have developed such an isomorphism in theory \Cblinfun_Matrix\ for any type T of sort \onb_enum\ (i.e., any type with a finite canonical orthonormal basis) as was done above for bounded operators. Unfortunately, we cannot declare code equations for a type class, code equations must be related to a specific type constructor. So we give code definition only for vectors of type \<^typ>\'a ell2\ (where \<^typ>\'a\ must be of sort \enum\ to make make sure that \<^typ>\'a ell2\ is finite dimensional). The isomorphism between \<^typ>\'a ell2\ is given by the constants \ell2_of_vec\ and \vec_of_ell2\ which are copies of the more general \<^const>\basis_enum_of_vec\ and \<^const>\vec_of_basis_enum\ but with a more restricted type to be usable in our code equations. \ definition ell2_of_vec :: "complex vec \ 'a::enum ell2" where "ell2_of_vec = basis_enum_of_vec" definition vec_of_ell2 :: "'a::enum ell2 \ complex vec" where "vec_of_ell2 = vec_of_basis_enum" text \The following theorem registers the isomorphism \ell2_of_vec\/\vec_of_ell2\ for code generation. From now on, code for operations on \<^typ>\_ ell2\ can be expressed by declarations such as \<^term>\vec_of_ell2 (f a b) = g (vec_of_ell2 a) (vec_of_ell2 b)\ if the operation f on \<^typ>\_ ell2\ corresponds to the operation g on \<^typ>\complex vec\.\ lemma vec_of_ell2_inverse [code abstype]: "ell2_of_vec (vec_of_ell2 B) = B" unfolding ell2_of_vec_def vec_of_ell2_def by (rule vec_of_basis_enum_inverse) text \This instantiation defines a code equation for equality tests for ell2.\ instantiation ell2 :: (enum) equal begin definition [code]: "equal_ell2 M N \ vec_of_ell2 M = vec_of_ell2 N" for M N :: "'a::enum ell2" instance apply intro_classes unfolding equal_ell2_def by (metis vec_of_ell2_inverse) end lemma vec_of_ell2_zero[code]: \ \Code equation for computing the zero vector\ "vec_of_ell2 (0::'a::enum ell2) = zero_vec (CARD('a))" by (simp add: vec_of_ell2_def vec_of_basis_enum_zero) lemma vec_of_ell2_ket[code]: \ \Code equation for computing a standard basis vector\ "vec_of_ell2 (ket i) = unit_vec (CARD('a)) (enum_idx i)" for i::"'a::enum" using vec_of_ell2_def vec_of_basis_enum_ket by metis lemma vec_of_ell2_timesScalarVec[code]: \ \Code equation for multiplying a vector with a complex scalar\ "vec_of_ell2 (scaleC a \) = smult_vec a (vec_of_ell2 \)" for \ :: "'a::enum ell2" by (simp add: vec_of_ell2_def vec_of_basis_enum_scaleC) lemma vec_of_ell2_scaleR[code]: \ \Code equation for multiplying a vector with a real scalar\ "vec_of_ell2 (scaleR a \) = smult_vec (complex_of_real a) (vec_of_ell2 \)" for \ :: "'a::enum ell2" by (simp add: vec_of_ell2_def vec_of_basis_enum_scaleR) lemma ell2_of_vec_plus[code]: \ \Code equation for adding vectors\ "vec_of_ell2 (x + y) = (vec_of_ell2 x) + (vec_of_ell2 y)" for x y :: "'a::enum ell2" by (simp add: vec_of_ell2_def vec_of_basis_enum_add) lemma ell2_of_vec_minus[code]: \ \Code equation for subtracting vectors\ "vec_of_ell2 (x - y) = (vec_of_ell2 x) - (vec_of_ell2 y)" for x y :: "'a::enum ell2" by (simp add: vec_of_ell2_def vec_of_basis_enum_minus) lemma ell2_of_vec_uminus[code]: \ \Code equation for negating a vector\ "vec_of_ell2 (- y) = - (vec_of_ell2 y)" for y :: "'a::enum ell2" by (simp add: vec_of_ell2_def vec_of_basis_enum_uminus) lemma cinner_ell2_code' [code]: "cinner \ \ = cscalar_prod (vec_of_ell2 \) (vec_of_ell2 \)" \ \Code equation for the inner product of vectors\ by (simp add: cscalar_prod_vec_of_basis_enum vec_of_ell2_def) lemma norm_ell2_code [code]: \ \Code equation for the norm of a vector\ "norm \ = (let \' = vec_of_ell2 \ in sqrt (\ i \ {0 ..< dim_vec \'}. let z = vec_index \' i in (Re z)\<^sup>2 + (Im z)\<^sup>2))" by (simp add: norm_ell2_vec_of_basis_enum vec_of_ell2_def) lemma times_ell2_code'[code]: \ \Code equation for the product in the algebra of one-dimensional vectors\ fixes \ \ :: "'a::{CARD_1,enum} ell2" shows "vec_of_ell2 (\ * \) = vec_of_list [vec_index (vec_of_ell2 \) 0 * vec_index (vec_of_ell2 \) 0]" by (simp add: vec_of_ell2_def vec_of_basis_enum_times) lemma divide_ell2_code'[code]: \ \Code equation for the product in the algebra of one-dimensional vectors\ fixes \ \ :: "'a::{CARD_1,enum} ell2" shows "vec_of_ell2 (\ / \) = vec_of_list [vec_index (vec_of_ell2 \) 0 / vec_index (vec_of_ell2 \) 0]" by (simp add: vec_of_ell2_def vec_of_basis_enum_divide) lemma inverse_ell2_code'[code]: \ \Code equation for the product in the algebra of one-dimensional vectors\ fixes \ :: "'a::{CARD_1,enum} ell2" shows "vec_of_ell2 (inverse \) = vec_of_list [inverse (vec_index (vec_of_ell2 \) 0)]" by (simp add: vec_of_ell2_def vec_of_basis_enum_to_inverse) lemma one_ell2_code'[code]: \ \Code equation for the unit in the algebra of one-dimensional vectors\ "vec_of_ell2 (1 :: 'a::{CARD_1,enum} ell2) = vec_of_list [1]" by (simp add: vec_of_ell2_def vec_of_basis_enum_1) subsection \Vector/Matrix\ text \We proceed to give code equations for operations involving both operators (cblinfun) and vectors. As explained above, we have to restrict the equations to vectors of type \<^typ>\'a ell2\ even though the theory is available for any type of class \<^class>\onb_enum\. As a consequence, we run into an addition technicality now. For example, to define a code equation for applying an operator to a vector, we might try to give the following lemma: \<^theory_text>\lemma cblinfun_apply_code[code]: "vec_of_ell2 (M *\<^sub>V x) = (mult_mat_vec (mat_of_cblinfun M) (vec_of_ell2 x))" by (simp add: mat_of_cblinfun_cblinfun_apply vec_of_ell2_def)\ Unfortunately, this does not work, Isabelle produces the warning "Projection as head in equation", most likely due to the fact that the type of \<^term>\(*\<^sub>V)\ in the equation is less general than the type of \<^term>\(*\<^sub>V)\ (it is restricted to @{type ell2}). We overcome this problem by defining a constant \cblinfun_apply_code\ which is equal to \<^term>\(*\<^sub>V)\ but has a more restricted type. We then instruct the code generation to replace occurrences of \<^term>\(*\<^sub>V)\ by \cblinfun_apply_code\ (where possible), and we add code generation for \cblinfun_apply_code\ instead of \<^term>\(*\<^sub>V)\. \ definition cblinfun_apply_code :: "'a ell2 \\<^sub>C\<^sub>L 'b ell2 \ 'a ell2 \ 'b ell2" where [code del, code_abbrev]: "cblinfun_apply_code = (*\<^sub>V)" \ \@{attribute code_abbrev} instructs the code generation to replace the rhs \<^term>\(*\<^sub>V)\ by the lhs \<^term>\cblinfun_apply_code\ before starting the actual code generation.\ lemma cblinfun_apply_code[code]: \ \Code equation for \<^term>\cblinfun_apply_code\, i.e., for applying an operator to an \<^type>\ell2\ vector\ "vec_of_ell2 (cblinfun_apply_code M x) = (mult_mat_vec (mat_of_cblinfun M) (vec_of_ell2 x))" by (simp add: cblinfun_apply_code_def mat_of_cblinfun_cblinfun_apply vec_of_ell2_def) text \For the constant \<^term>\vector_to_cblinfun\ (canonical isomorphism from vectors to operators), we have the same problem and define a constant \vector_to_cblinfun_code\ with more restricted type\ definition vector_to_cblinfun_code :: "'a ell2 \ 'b::one_dim \\<^sub>C\<^sub>L 'a ell2" where [code del,code_abbrev]: "vector_to_cblinfun_code = vector_to_cblinfun" \ \@{attribute code_abbrev} instructs the code generation to replace the rhs \<^term>\vector_to_cblinfun\ by the lhs \<^term>\vector_to_cblinfun_code\ before starting the actual code generation.\ lemma vector_to_cblinfun_code[code]: \ \Code equation for translating a vector into an operation (single-column matrix)\ "mat_of_cblinfun (vector_to_cblinfun_code \) = mat_of_cols (CARD('a)) [vec_of_ell2 \]" for \::"'a::enum ell2" by (simp add: mat_of_cblinfun_vector_to_cblinfun vec_of_ell2_def vector_to_cblinfun_code_def) subsection \Subspaces\ text \In this section, we define code equations for handling subspaces, i.e., values of type \<^typ>\'a ccsubspace\. We choose to computationally represent a subspace by a list of vectors that span the subspace. That is, if \<^term>\vecs\ are vectors (type \<^typ>\complex vec\), \SPAN vecs\ is defined to be their span. Then the code generation can simply represent all subspaces in this form, and we need to define the operations on subspaces in terms of list of vectors (e.g., the closed union of two subspaces would be computed as the concatenation of the two lists, to give one of the simplest examples). To support this, \SPAN\ is declared as a "\code_datatype\". (Not as an abstract datatype like \<^term>\cblinfun_of_mat\/\<^term>\mat_of_cblinfun\ because that would require \SPAN\ to be injective.) Then all code equations for different operations need to be formulated as functions of values of the form \SPAN x\. (E.g., \SPAN x + SPAN y = SPAN (\)\.)\ definition [code del]: "SPAN x = (let n = length (canonical_basis :: 'a::onb_enum list) in ccspan (basis_enum_of_vec ` Set.filter (\v. dim_vec v = n) (set x)) :: 'a ccsubspace)" \ \The SPAN of vectors x, as a \<^type>\ccsubspace\. We filter out vectors of the wrong dimension because \SPAN\ needs to have well-defined behavior even in cases that would not actually occur in an execution.\ code_datatype SPAN text \We first declare code equations for \<^term>\Proj\, i.e., for turning a subspace into a projector. This means, we would need a code equation of the form \mat_of_cblinfun (Proj (SPAN S)) = \\. However, this equation is not accepted by the code generation for reasons we do not understand. But if we define an auxiliary constant \mat_of_cblinfun_Proj_code\ that stands for \mat_of_cblinfun (Proj _)\, define a code equation for \mat_of_cblinfun_Proj_code\, and then define a code equation for \mat_of_cblinfun (Proj S)\ in terms of \mat_of_cblinfun_Proj_code\, Isabelle accepts the code equations.\ definition "mat_of_cblinfun_Proj_code S = mat_of_cblinfun (Proj S)" declare mat_of_cblinfun_Proj_code_def[symmetric, code] lemma mat_of_cblinfun_Proj_code_code[code]: \ \Code equation for computing a projector onto a set S of vectors. We first make the vectors S into an orthonormal basis using the Gram-Schmidt procedure and then compute the projector as the sum of the "butterflies" \x * x*\ of the vectors \x\S\ (done by \<^term>\mk_projector_orthog\).\ "mat_of_cblinfun_Proj_code (SPAN S :: 'a::onb_enum ccsubspace) = (let d = length (canonical_basis :: 'a list) in mk_projector_orthog d (gram_schmidt0 d (filter (\v. dim_vec v = d) S)))" proof - have *: "map_option vec_of_basis_enum (if dim_vec x = length (canonical_basis :: 'a list) then Some (basis_enum_of_vec x :: 'a) else None) = (if dim_vec x = length (canonical_basis :: 'a list) then Some x else None)" for x by auto show ?thesis unfolding SPAN_def mat_of_cblinfun_Proj_code_def using mat_of_cblinfun_Proj_ccspan[where S = "map basis_enum_of_vec (filter (\v. dim_vec v = (length (canonical_basis :: 'a list))) S) :: 'a list"] apply (simp only: Let_def map_filter_map_filter filter_set image_set map_map_filter o_def) unfolding * by (simp add: map_filter_map_filter[symmetric]) qed lemma top_ccsubspace_code[code]: \ \Code equation for \<^term>\top\, the subspace containing everything. Top is represented as the span of the standard basis vectors.\ "(top::'a ccsubspace) = (let n = length (canonical_basis :: 'a::onb_enum list) in SPAN (unit_vecs n))" unfolding SPAN_def apply (simp only: index_unit_vec Let_def map_filter_map_filter filter_set image_set map_map_filter map_filter_map o_def unit_vecs_def) apply (simp add: basis_enum_of_vec_unit_vec) apply (subst nth_image) by (auto simp: ) lemma bot_as_span[code]: \ \Code equation for \<^term>\bot\, the subspace containing everything. Top is represented as the span of the standard basis vectors.\ "(bot::'a::onb_enum ccsubspace) = SPAN []" unfolding SPAN_def by (auto simp: Set.filter_def) lemma sup_spans[code]: \ \Code equation for the join (lub) of two subspaces (union of the generating lists)\ "SPAN A \ SPAN B = SPAN (A @ B)" unfolding SPAN_def by (auto simp: ccspan_union image_Un filter_Un Let_def) text \We do not need an equation for \<^term>\(+)\ because \<^term>\(+)\ is defined in terms of \<^term>\(\)\ (for \<^type>\ccsubspace\), thus the code generation automatically computes \<^term>\(+)\ in terms of the code for \<^term>\(\)\\ definition [code del,code_abbrev]: "Span_code (S::'a::enum ell2 set) = (ccspan S)" \ \A copy of \<^term>\ccspan\ with restricted type. For analogous reasons as \<^term>\cblinfun_apply_code\, see there for explanations\ lemma span_Set_Monad[code]: "Span_code (Set_Monad l) = (SPAN (map vec_of_ell2 l))" \ \Code equation for the span of a finite set. (\<^term>\Set_Monad\ is a datatype constructor that represents sets as lists in the computation.)\ apply (simp add: Span_code_def SPAN_def Let_def) apply (subst Set_filter_unchanged) apply (auto simp add: vec_of_ell2_def)[1] by (metis (no_types, lifting) ell2_of_vec_def image_image map_idI set_map vec_of_ell2_inverse) text \This instantiation defines a code equation for equality tests for \<^type>\ccsubspace\. The actual code for equality tests is given below (lemma \equal_ccsubspace_code\).\ instantiation ccsubspace :: (onb_enum) equal begin definition [code del]: "equal_ccsubspace (A::'a ccsubspace) B = (A=B)" instance apply intro_classes unfolding equal_ccsubspace_def by simp end lemma leq_ccsubspace_code[code]: \ \Code equation for deciding inclusion of one space in another. Uses the constant \<^term>\is_subspace_of_vec_list\ which implements the actual computation by checking for each generator of A whether it is in the span of B (by orthogonal projection onto an orthonormal basis of B which is computed using Gram-Schmidt).\ "SPAN A \ (SPAN B :: 'a::onb_enum ccsubspace) \ (let d = length (canonical_basis :: 'a list) in is_subspace_of_vec_list d (filter (\v. dim_vec v = d) A) (filter (\v. dim_vec v = d) B))" proof - define d A' B' where "d = length (canonical_basis :: 'a list)" and "A' = filter (\v. dim_vec v = d) A" and "B' = filter (\v. dim_vec v = d) B" show ?thesis unfolding SPAN_def d_def[symmetric] filter_set Let_def A'_def[symmetric] B'_def[symmetric] image_set apply (subst ccspan_leq_using_vec) unfolding d_def[symmetric] map_map o_def apply (subst map_cong[where xs=A', OF refl]) apply (rule basis_enum_of_vec_inverse) apply (simp add: A'_def d_def) apply (subst map_cong[where xs=B', OF refl]) apply (rule basis_enum_of_vec_inverse) by (simp_all add: B'_def d_def) qed lemma equal_ccsubspace_code[code]: \ \Code equation for equality test. By checking mutual inclusion (for which we have code by the preceding code equation).\ "HOL.equal (A::_ ccsubspace) B = (A\B \ B\A)" unfolding equal_ccsubspace_def by auto lemma apply_cblinfun_code[code]: \ \Code equation for applying an operator \<^term>\A\ to a subspace. Simply by multiplying each generator with \<^term>\A\\ "A *\<^sub>S SPAN S = (let d = length (canonical_basis :: 'a list) in SPAN (map (mult_mat_vec (mat_of_cblinfun A)) (filter (\v. dim_vec v = d) S)))" for A::"'a::onb_enum \\<^sub>C\<^sub>L'b::onb_enum" proof - define dA dB S' where "dA = length (canonical_basis :: 'a list)" and "dB = length (canonical_basis :: 'b list)" and "S' = filter (\v. dim_vec v = dA) S" have "cblinfun_image A (SPAN S) = A *\<^sub>S ccspan (set (map basis_enum_of_vec S'))" unfolding SPAN_def dA_def[symmetric] Let_def S'_def filter_set by simp also have "\ = ccspan ((\x. basis_enum_of_vec (mat_of_cblinfun A *\<^sub>v vec_of_basis_enum (basis_enum_of_vec x :: 'a))) ` set S')" apply (subst cblinfun_apply_ccspan_using_vec) by (simp add: image_image) also have "\ = ccspan ((\x. basis_enum_of_vec (mat_of_cblinfun A *\<^sub>v x)) ` set S')" apply (subst image_cong[OF refl]) apply (subst basis_enum_of_vec_inverse) by (auto simp add: S'_def dA_def) also have "\ = SPAN (map (mult_mat_vec (mat_of_cblinfun A)) S')" unfolding SPAN_def dB_def[symmetric] Let_def filter_set apply (subst filter_True) by (simp_all add: dB_def mat_of_cblinfun_def image_image) finally show ?thesis unfolding dA_def[symmetric] S'_def[symmetric] Let_def by simp qed definition [code del, code_abbrev]: "range_cblinfun_code A = A *\<^sub>S top" \ \A new constant for the special case of applying an operator to the subspace \<^term>\top\ (i.e., for computing the range of the operator). We do this to be able to give more specialized code for this specific situation. (The generic code for \<^term>\(*\<^sub>S)\ would work but is less efficient because it involves repeated matrix multiplications. @{attribute code_abbrev} makes sure occurrences of \<^term>\A *\<^sub>S top\ are replaced before starting the actual code generation.\ lemma range_cblinfun_code[code]: \ \Code equation for computing the range of an operator \<^term>\A\. Returns the columns of the matrix representation of \<^term>\A\.\ fixes A :: "'a::onb_enum \\<^sub>C\<^sub>L 'b::onb_enum" shows "range_cblinfun_code A = SPAN (cols (mat_of_cblinfun A))" proof - define dA dB where "dA = length (canonical_basis :: 'a list)" and "dB = length (canonical_basis :: 'b list)" have carrier_A: "mat_of_cblinfun A \ carrier_mat dB dA" unfolding mat_of_cblinfun_def dA_def dB_def by simp have "range_cblinfun_code A = A *\<^sub>S SPAN (unit_vecs dA)" unfolding range_cblinfun_code_def by (metis dA_def top_ccsubspace_code) also have "\ = SPAN (map (\i. mat_of_cblinfun A *\<^sub>v unit_vec dA i) [0.. = SPAN (map (\x. mat_of_cblinfun A *\<^sub>v col (1\<^sub>m dA) x) [0.. = SPAN (map (col (mat_of_cblinfun A * 1\<^sub>m dA)) [0.. = SPAN (cols (mat_of_cblinfun A))" unfolding cols_def dA_def[symmetric] apply (subst right_mult_one_mat[OF carrier_A]) using carrier_A by blast finally show ?thesis by - qed lemma uminus_Span_code[code]: "- X = range_cblinfun_code (id_cblinfun - Proj X)" \ \Code equation for the orthogonal complement of a subspace \<^term>\X\. Computed as the range of one minus the projector on \<^term>\X\\ unfolding range_cblinfun_code_def by (metis Proj_ortho_compl Proj_range) lemma kernel_code[code]: \ \Computes the kernel of an operator \<^term>\A\. This is implemented using the existing functions for transforming a matrix into row echelon form (\<^term>\gauss_jordan_single\) and for computing a basis of the kernel of such a matrix (\<^term>\find_base_vectors\)\ "kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))" for A::"('a::onb_enum,'b::onb_enum) cblinfun" proof - define dA dB Am Ag base where "dA = length (canonical_basis :: 'a list)" and "dB = length (canonical_basis :: 'b list)" and "Am = mat_of_cblinfun A" and "Ag = gauss_jordan_single Am" and "base = find_base_vectors Ag" interpret complex_vec_space dA. have Am_carrier: "Am \ carrier_mat dB dA" unfolding Am_def mat_of_cblinfun_def dA_def dB_def by simp have row_echelon: "row_echelon_form Ag" unfolding Ag_def using Am_carrier refl by (rule gauss_jordan_single) have Ag_carrier: "Ag \ carrier_mat dB dA" unfolding Ag_def using Am_carrier refl by (rule gauss_jordan_single(2)) have base_carrier: "set base \ carrier_vec dA" unfolding base_def using find_base_vectors(1)[OF row_echelon Ag_carrier] using Ag_carrier mat_kernel_def by blast interpret k: kernel dB dA Ag apply standard using Ag_carrier by simp have basis_base: "kernel.basis dA Ag (set base)" using row_echelon Ag_carrier unfolding base_def by (rule find_base_vectors(3)) have "space_as_set (SPAN base) = space_as_set (ccspan (basis_enum_of_vec ` set base :: 'a set))" unfolding SPAN_def dA_def[symmetric] Let_def filter_set apply (subst filter_True) using base_carrier by auto also have "\ = cspan (basis_enum_of_vec ` set base)" apply transfer apply (subst closure_finite_cspan) by simp_all also have "\ = basis_enum_of_vec ` span (set base)" apply (subst basis_enum_of_vec_span) using base_carrier dA_def by auto also have "\ = basis_enum_of_vec ` mat_kernel Ag" using basis_base k.Ker.basis_def k.span_same by auto also have "\ = basis_enum_of_vec ` {v \ carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}" apply (rule arg_cong[where f="\x. basis_enum_of_vec ` x"]) unfolding mat_kernel_def using Ag_carrier by simp also have "\ = basis_enum_of_vec ` {v \ carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB}" using gauss_jordan_single(1)[OF Am_carrier Ag_def[symmetric]] by auto also have "\ = {w. A *\<^sub>V w = 0}" proof - have "basis_enum_of_vec ` {v \ carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \ carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = 0}" apply (rule arg_cong[where f="\t. basis_enum_of_vec ` t"]) apply (rule Collect_cong) apply (simp add: Am_def) by (metis Am_carrier Am_def carrier_matD(2) carrier_vecD dB_def mat_carrier mat_of_cblinfun_def mat_of_cblinfun_cblinfun_apply vec_of_basis_enum_inverse basis_enum_of_vec_inverse vec_of_basis_enum_zero) also have "\ = {w \ basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = 0}" apply (subst Compr_image_eq[symmetric]) by simp also have "\ = {w. A *\<^sub>V w = 0}" apply auto by (metis (no_types, lifting) Am_carrier Am_def carrier_matD(2) carrier_vec_dim_vec dim_vec_of_basis_enum' image_iff mat_carrier mat_of_cblinfun_def vec_of_basis_enum_inverse) finally show ?thesis by - qed also have "\ = space_as_set (kernel A)" apply transfer by auto finally have "SPAN base = kernel A" by (simp add: space_as_set_inject) then show ?thesis by (simp add: base_def Ag_def Am_def) qed lemma inf_ccsubspace_code[code]: \ \Code equation for intersection of subspaces. Reduced to orthogonal complement and sum of subspaces for which we already have code equations.\ "(A::'a::onb_enum ccsubspace) \ B = - (- A \ - B)" by (subst ortho_involution[symmetric], subst compl_inf, simp) lemma Sup_ccsubspace_code[code]: \ \Supremum (sum) of a set of subspaces. Implemented by repeated pairwise sum.\ "Sup (Set_Monad l :: 'a::onb_enum ccsubspace set) = fold sup l bot" unfolding Set_Monad_def by (simp add: Sup_set_fold) lemma Inf_ccsubspace_code[code]: \ \Infimum (intersection) of a set of subspaces. Implemented by the orthogonal complement of the supremum.\ "Inf (Set_Monad l :: 'a::onb_enum ccsubspace set) = - Sup (Set_Monad (map uminus l))" unfolding Set_Monad_def apply (induction l) by auto subsection \Miscellanea\ text \This is a hack to circumvent a bug in the code generation. The automatically generated code for the class \<^class>\uniformity\ has a type that is different from what the generated code later assumes, leading to compilation errors (in ML at least) in any expression involving \<^typ>\_ ell2\ (even if the constant \<^const>\uniformity\ is not actually used). The fragment below circumvents this by forcing Isabelle to use the right type. (The logically useless fragment "\let x = ((=)::'a\_\_)\" achieves this.)\ lemma uniformity_ell2_code[code]: "(uniformity :: ('a ell2 * _) filter) = Filter.abstract_filter (%_. Code.abort STR ''no uniformity'' (%_. let x = ((=)::'a\_\_) in uniformity))" by simp text \Code equation for \<^term>\UNIV\. It is now implemented via type class \<^class>\enum\ (which provides a list of all values).\ declare [[code drop: UNIV]] declare enum_class.UNIV_enum[code] text \Setup for code generation involving sets of \<^type>\ell2\/\<^type>\ccsubspace\. This configures to use lists for representing sets in code.\ derive (eq) ceq ccsubspace derive (no) ccompare ccsubspace derive (monad) set_impl ccsubspace derive (eq) ceq ell2 derive (no) ccompare ell2 derive (monad) set_impl ell2 +unbundle no_lattice_syntax unbundle no_jnf_notation unbundle no_cblinfun_notation end diff --git a/thys/Complex_Bounded_Operators/Cblinfun_Code_Examples.thy b/thys/Complex_Bounded_Operators/Cblinfun_Code_Examples.thy --- a/thys/Complex_Bounded_Operators/Cblinfun_Code_Examples.thy +++ b/thys/Complex_Bounded_Operators/Cblinfun_Code_Examples.thy @@ -1,119 +1,120 @@ section \\Cblinfun_Code_Examples\ -- Examples and test cases for code generation\ theory Cblinfun_Code_Examples imports "Complex_Bounded_Operators.Extra_Pretty_Code_Examples" Jordan_Normal_Form.Matrix_Impl "HOL-Library.Code_Target_Numeral" Cblinfun_Code begin hide_const (open) Order.bottom Order.top no_notation Lattice.join (infixl "\\" 65) no_notation Lattice.meet (infixl "\\" 70) +unbundle lattice_syntax unbundle cblinfun_notation section \Examples\ subsection \Operators\ value "id_cblinfun :: bool ell2 \\<^sub>C\<^sub>L bool ell2" value "1 :: unit ell2 \\<^sub>C\<^sub>L unit ell2" value "id_cblinfun + id_cblinfun :: bool ell2 \\<^sub>C\<^sub>L bool ell2" value "0 :: (bool ell2 \\<^sub>C\<^sub>L Enum.finite_3 ell2)" value "- id_cblinfun :: bool ell2 \\<^sub>C\<^sub>L bool ell2" value "id_cblinfun - id_cblinfun :: bool ell2 \\<^sub>C\<^sub>L bool ell2" value "classical_operator (\b. Some (\ b))" value "id_cblinfun = (0 :: bool ell2 \\<^sub>C\<^sub>L bool ell2)" value "2 *\<^sub>R id_cblinfun :: bool ell2 \\<^sub>C\<^sub>L bool ell2" value "imaginary_unit *\<^sub>C id_cblinfun :: bool ell2 \\<^sub>C\<^sub>L bool ell2" value "id_cblinfun o\<^sub>C\<^sub>L 0 :: bool ell2 \\<^sub>C\<^sub>L bool ell2" value "id_cblinfun* :: bool ell2 \\<^sub>C\<^sub>L bool ell2" subsection \Vectors\ value "0 :: bool ell2" value "1 :: unit ell2" value "ket False" value "2 *\<^sub>C ket False" value "2 *\<^sub>R ket False" value "ket True + ket False" value "ket True - ket True" value "ket True = ket True" value "- ket True" value "cinner (ket True) (ket True)" value "norm (ket True)" value "ket () * ket ()" value "1 :: unit ell2" value "(1::unit ell2) * (1::unit ell2)" subsection \Vector/Matrix\ value "id_cblinfun *\<^sub>V ket True" value \vector_to_cblinfun (ket True) :: unit ell2 \\<^sub>C\<^sub>L _\ subsection \Subspaces\ value "ccspan {ket False}" value "Proj (ccspan {ket False})" value "top :: bool ell2 ccsubspace" value "bot :: bool ell2 ccsubspace" value "0 :: bool ell2 ccsubspace" value "ccspan {ket False} \ ccspan {ket True}" value "ccspan {ket False} + ccspan {ket True}" value "ccspan {ket False} \ ccspan {ket True}" value "id_cblinfun *\<^sub>S ccspan {ket False}" value "id_cblinfun *\<^sub>S (top :: bool ell2 ccsubspace)" (* Special case, using range_cblinfun_code for efficiency *) value "- ccspan {ket False}" value "ccspan {ket False, ket True} = top" value "ccspan {ket False} \ ccspan {ket True}" value "cblinfun_image id_cblinfun (ccspan {ket True})" value "kernel id_cblinfun :: bool ell2 ccsubspace" value "eigenspace 1 id_cblinfun :: bool ell2 ccsubspace" value "Inf {ccspan {ket False}, top}" value "Sup {ccspan {ket False}, top}" end diff --git a/thys/Complex_Bounded_Operators/Complex_Bounded_Linear_Function.thy b/thys/Complex_Bounded_Operators/Complex_Bounded_Linear_Function.thy --- a/thys/Complex_Bounded_Operators/Complex_Bounded_Linear_Function.thy +++ b/thys/Complex_Bounded_Operators/Complex_Bounded_Linear_Function.thy @@ -1,2981 +1,2984 @@ section \\Complex_Bounded_Linear_Function\ -- Complex bounded linear functions (bounded operators)\ (* Authors: Dominique Unruh, University of Tartu, unruh@ut.ee Jose Manuel Rodriguez Caballero, University of Tartu, jose.manuel.rodriguez.caballero@ut.ee *) theory Complex_Bounded_Linear_Function imports Complex_Inner_Product One_Dimensional_Spaces Banach_Steinhaus.Banach_Steinhaus "HOL-Types_To_Sets.Types_To_Sets" Complex_Bounded_Linear_Function0 begin +unbundle lattice_syntax + subsection \Misc basic facts and declarations\ notation cblinfun_apply (infixr "*\<^sub>V" 70) lemma id_cblinfun_apply[simp]: "id_cblinfun *\<^sub>V \ = \" apply transfer by simp lemma isCont_cblinfun_apply[simp]: "isCont ((*\<^sub>V) A) \" apply transfer by (simp add: clinear_continuous_at) declare cblinfun.scaleC_left[simp] lemma cblinfun_apply_clinear[simp]: \clinear (cblinfun_apply A)\ using bounded_clinear.axioms(1) cblinfun_apply by blast lemma cblinfun_cinner_eqI: fixes A B :: \'a::chilbert_space \\<^sub>C\<^sub>L 'a\ assumes \\\. cinner \ (A *\<^sub>V \) = cinner \ (B *\<^sub>V \)\ shows \A = B\ proof - define C where \C = A - B\ have C0[simp]: \cinner \ (C \) = 0\ for \ by (simp add: C_def assms cblinfun.diff_left cinner_diff_right) { fix f g \ have \0 = cinner (f + \ *\<^sub>C g) (C *\<^sub>V (f + \ *\<^sub>C g))\ by (simp add: cinner_diff_right minus_cblinfun.rep_eq) also have \\ = \ *\<^sub>C cinner f (C g) + cnj \ *\<^sub>C cinner g (C f)\ by (smt (z3) C0 add.commute add.right_neutral cblinfun.add_right cblinfun.scaleC_right cblinfun_cinner_right.rep_eq cinner_add_left cinner_scaleC_left complex_scaleC_def) finally have \\ *\<^sub>C cinner f (C g) = - cnj \ *\<^sub>C cinner g (C f)\ by (simp add: eq_neg_iff_add_eq_0) } then have \cinner f (C g) = 0\ for f g by (metis complex_cnj_i complex_cnj_one complex_vector.scale_cancel_right complex_vector.scale_left_imp_eq equation_minus_iff i_squared mult_eq_0_iff one_neq_neg_one) then have \C g = 0\ for g using cinner_eq_zero_iff by blast then have \C = 0\ by (simp add: cblinfun_eqI) then show \A = B\ using C_def by auto qed lemma id_cblinfun_not_0[simp]: \(id_cblinfun :: 'a::{complex_normed_vector, not_singleton} \\<^sub>C\<^sub>L _) \ 0\ by (metis (full_types) Extra_General.UNIV_not_singleton cblinfun.zero_left cblinfun_id_cblinfun_apply ex_norm1 norm_zero one_neq_zero) lemma cblinfun_norm_geqI: assumes \norm (f *\<^sub>V x) / norm x \ K\ shows \norm f \ K\ using assms apply transfer by (smt (z3) bounded_clinear.bounded_linear le_onorm) (* This lemma is proven in Complex_Bounded_Linear_Function0 but we add the [simp] only here because we try to keep Complex_Bounded_Linear_Function0 as close to Bounded_Linear_Function as possible. *) declare scaleC_conv_of_complex[simp] lemma cblinfun_eq_0_on_span: fixes S::\'a::complex_normed_vector set\ assumes "x \ cspan S" and "\s. s\S \ F *\<^sub>V s = 0" shows \F *\<^sub>V x = 0\ apply (rule complex_vector.linear_eq_0_on_span[where f=F]) using bounded_clinear.axioms(1) cblinfun_apply assms by auto lemma cblinfun_eq_on_span: fixes S::\'a::complex_normed_vector set\ assumes "x \ cspan S" and "\s. s\S \ F *\<^sub>V s = G *\<^sub>V s" shows \F *\<^sub>V x = G *\<^sub>V x\ apply (rule complex_vector.linear_eq_on_span[where f=F]) using bounded_clinear.axioms(1) cblinfun_apply assms by auto lemma cblinfun_eq_0_on_UNIV_span: fixes basis::\'a::complex_normed_vector set\ assumes "cspan basis = UNIV" and "\s. s\basis \ F *\<^sub>V s = 0" shows \F = 0\ by (metis cblinfun_eq_0_on_span UNIV_I assms cblinfun.zero_left cblinfun_eqI) lemma cblinfun_eq_on_UNIV_span: fixes basis::"'a::complex_normed_vector set" and \::"'a \ 'b::complex_normed_vector" assumes "cspan basis = UNIV" and "\s. s\basis \ F *\<^sub>V s = G *\<^sub>V s" shows \F = G\ proof- have "F - G = 0" apply (rule cblinfun_eq_0_on_UNIV_span[where basis=basis]) using assms by (auto simp add: cblinfun.diff_left) thus ?thesis by simp qed lemma cblinfun_eq_on_canonical_basis: fixes f g::"'a::{basis_enum,complex_normed_vector} \\<^sub>C\<^sub>L 'b::complex_normed_vector" defines "basis == set (canonical_basis::'a list)" assumes "\u. u \ basis \ f *\<^sub>V u = g *\<^sub>V u" shows "f = g" apply (rule cblinfun_eq_on_UNIV_span[where basis=basis]) using assms is_generator_set is_cindependent_set by auto lemma cblinfun_eq_0_on_canonical_basis: fixes f ::"'a::{basis_enum,complex_normed_vector} \\<^sub>C\<^sub>L 'b::complex_normed_vector" defines "basis == set (canonical_basis::'a list)" assumes "\u. u \ basis \ f *\<^sub>V u = 0" shows "f = 0" by (simp add: assms cblinfun_eq_on_canonical_basis) lemma cinner_canonical_basis_eq_0: defines "basisA == set (canonical_basis::'a::onb_enum list)" and "basisB == set (canonical_basis::'b::onb_enum list)" assumes "\u v. u\basisA \ v\basisB \ \v, F *\<^sub>V u\ = 0" shows "F = 0" proof- have "F *\<^sub>V u = 0" if "u\basisA" for u proof- have "\v. v\basisB \ \v, F *\<^sub>V u\ = 0" by (simp add: assms(3) that) moreover have "(\v. v\basisB \ \v, x\ = 0) \ x = 0" for x proof- assume r1: "\v. v\basisB \ \v, x\ = 0" have "\v, x\ = 0" for v proof- have "cspan basisB = UNIV" using basisB_def is_generator_set by auto hence "v \ cspan basisB" by (smt iso_tuple_UNIV_I) hence "\t s. v = (\a\t. s a *\<^sub>C a) \ finite t \ t \ basisB" using complex_vector.span_explicit by (smt mem_Collect_eq) then obtain t s where b1: "v = (\a\t. s a *\<^sub>C a)" and b2: "finite t" and b3: "t \ basisB" by blast have "\v, x\ = \(\a\t. s a *\<^sub>C a), x\" by (simp add: b1) also have "\ = (\a\t. \s a *\<^sub>C a, x\)" using cinner_sum_left by blast also have "\ = (\a\t. cnj (s a) * \a, x\)" by auto also have "\ = 0" using b3 r1 subsetD by force finally show ?thesis by simp qed thus ?thesis by (simp add: \\v. \v, x\ = 0\ cinner_extensionality) qed ultimately show ?thesis by simp qed thus ?thesis using basisA_def cblinfun_eq_0_on_canonical_basis by auto qed lemma cinner_canonical_basis_eq: defines "basisA == set (canonical_basis::'a::onb_enum list)" and "basisB == set (canonical_basis::'b::onb_enum list)" assumes "\u v. u\basisA \ v\basisB \ \v, F *\<^sub>V u\ = \v, G *\<^sub>V u\" shows "F = G" proof- define H where "H = F - G" have "\u v. u\basisA \ v\basisB \ \v, H *\<^sub>V u\ = 0" unfolding H_def by (simp add: assms(3) cinner_diff_right minus_cblinfun.rep_eq) hence "H = 0" by (simp add: basisA_def basisB_def cinner_canonical_basis_eq_0) thus ?thesis unfolding H_def by simp qed lemma cinner_canonical_basis_eq': defines "basisA == set (canonical_basis::'a::onb_enum list)" and "basisB == set (canonical_basis::'b::onb_enum list)" assumes "\u v. u\basisA \ v\basisB \ \F *\<^sub>V u, v\ = \G *\<^sub>V u, v\" shows "F = G" using cinner_canonical_basis_eq assms by (metis cinner_commute') lemma cblinfun_norm_approx_witness: fixes A :: \'a::{not_singleton,complex_normed_vector} \\<^sub>C\<^sub>L 'b::complex_normed_vector\ assumes \\ > 0\ shows \\\. norm (A *\<^sub>V \) \ norm A - \ \ norm \ = 1\ proof (transfer fixing: \) fix A :: \'a \ 'b\ assume [simp]: \bounded_clinear A\ have \\y\{norm (A x) |x. norm x = 1}. y > \ {norm (A x) |x. norm x = 1} - \\ apply (rule Sup_real_close) using assms by (auto simp: ex_norm1 bounded_clinear.bounded_linear bdd_above_norm_f) also have \\ {norm (A x) |x. norm x = 1} = onorm A\ by (simp add: Complex_Vector_Spaces0.bounded_clinear.bounded_linear onorm_sphere) finally show \\\. onorm A - \ \ norm (A \) \ norm \ = 1\ by force qed lemma cblinfun_norm_approx_witness_mult: fixes A :: \'a::{not_singleton,complex_normed_vector} \\<^sub>C\<^sub>L 'b::complex_normed_vector\ assumes \\ < 1\ shows \\\. norm (A *\<^sub>V \) \ norm A * \ \ norm \ = 1\ proof (cases \norm A = 0\) case True then show ?thesis apply auto by (simp add: ex_norm1) next case False then have \(1 - \) * norm A > 0\ using assms by fastforce then obtain \ where geq: \norm (A *\<^sub>V \) \ norm A - ((1 - \) * norm A)\ and \norm \ = 1\ using cblinfun_norm_approx_witness by blast have \norm A * \ = norm A - (1 - \) * norm A\ by (simp add: mult.commute right_diff_distrib') also have \\ \ norm (A *\<^sub>V \)\ by (rule geq) finally show ?thesis using \norm \ = 1\ by auto qed lemma cblinfun_to_CARD_1_0[simp]: \(A :: _ \\<^sub>C\<^sub>L _::CARD_1) = 0\ apply (rule cblinfun_eqI) by auto lemma cblinfun_from_CARD_1_0[simp]: \(A :: _::CARD_1 \\<^sub>C\<^sub>L _) = 0\ apply (rule cblinfun_eqI) apply (subst CARD_1_vec_0) by auto lemma cblinfun_cspan_UNIV: fixes basis :: \('a::{complex_normed_vector,cfinite_dim} \\<^sub>C\<^sub>L 'b::complex_normed_vector) set\ and basisA :: \'a set\ and basisB :: \'b set\ assumes \cspan basisA = UNIV\ and \cspan basisB = UNIV\ assumes basis: \\a b. a\basisA \ b\basisB \ \F\basis. \a'\basisA. F *\<^sub>V a' = (if a'=a then b else 0)\ shows \cspan basis = UNIV\ proof - obtain basisA' where \basisA' \ basisA\ and \cindependent basisA'\ and \cspan basisA' = UNIV\ by (metis assms(1) complex_vector.maximal_independent_subset complex_vector.span_eq top_greatest) then have [simp]: \finite basisA'\ by (simp add: cindependent_cfinite_dim_finite) have basis': \\a b. a\basisA' \ b\basisB \ \F\basis. \a'\basisA'. F *\<^sub>V a' = (if a'=a then b else 0)\ using basis \basisA' \ basisA\ by fastforce obtain F where F: \F a b \ basis \ F a b *\<^sub>V a' = (if a'=a then b else 0)\ if \a\basisA'\ \b\basisB\ \a'\basisA'\ for a b a' apply atomize_elim apply (intro choice allI) using basis' by metis then have F_apply: \F a b *\<^sub>V a' = (if a'=a then b else 0)\ if \a\basisA'\ \b\basisB\ \a'\basisA'\ for a b a' using that by auto have F_basis: \F a b \ basis\ if \a\basisA'\ \b\basisB\ for a b using that F by auto have b_span: \\G\cspan {F a b|b. b\basisB}. \a'\basisA'. G *\<^sub>V a' = (if a'=a then b else 0)\ if \a\basisA'\ for a b proof - from \cspan basisB = UNIV\ obtain r t where \finite t\ and \t \ basisB\ and b_lincom: \b = (\a\t. r a *\<^sub>C a)\ unfolding complex_vector.span_alt apply atomize_elim by blast define G where \G = (\i\t. r i *\<^sub>C F a i)\ have \G \ cspan {F a b|b. b\basisB}\ using \finite t\ \t \ basisB\ unfolding G_def by (smt (verit, ccfv_threshold) complex_vector.span_base complex_vector.span_scale complex_vector.span_sum mem_Collect_eq subset_eq) moreover have \G *\<^sub>V a' = (if a'=a then b else 0)\ if \a'\basisA'\ for a' apply (cases \a'=a\) using \t \ basisB\ \a\basisA'\ \a'\basisA'\ by (auto simp: b_lincom G_def cblinfun.sum_left F_apply intro!: sum.neutral sum.cong) ultimately show ?thesis by blast qed have a_span: \cspan (\a\basisA'. cspan {F a b|b. b\basisB}) = UNIV\ proof (intro equalityI subset_UNIV subsetI, rename_tac H) fix H obtain G where G: \G a b \ cspan {F a b|b. b\basisB} \ G a b *\<^sub>V a' = (if a'=a then b else 0)\ if \a\basisA'\ and \a'\basisA'\ for a b a' apply atomize_elim apply (intro choice allI) using b_span by blast then have G_cspan: \G a b \ cspan {F a b|b. b\basisB}\ if \a\basisA'\ for a b using that by auto from G have G: \G a b *\<^sub>V a' = (if a'=a then b else 0)\ if \a\basisA'\ and \a'\basisA'\ for a b a' using that by auto define H' where \H' = (\a\basisA'. G a (H *\<^sub>V a))\ have \H' \ cspan (\a\basisA'. cspan {F a b|b. b\basisB})\ unfolding H'_def using G_cspan by (smt (verit, del_insts) UN_iff complex_vector.span_clauses(1) complex_vector.span_sum) moreover have \H' = H\ using \cspan basisA' = UNIV\ apply (rule cblinfun_eq_on_UNIV_span) apply (auto simp: H'_def cblinfun.sum_left) apply (subst sum_single) by (auto simp: G) ultimately show \H \ cspan (\a\basisA'. cspan {F a b |b. b \ basisB})\ by simp qed moreover have \cspan basis \ cspan (\a\basisA'. cspan {F a b|b. b\basisB})\ using F_basis by (smt (z3) UN_subset_iff complex_vector.span_alt complex_vector.span_minimal complex_vector.subspace_span mem_Collect_eq subset_iff) ultimately show \cspan basis = UNIV\ by auto qed instance cblinfun :: (\{cfinite_dim,complex_normed_vector}\, \{cfinite_dim,complex_normed_vector}\) cfinite_dim proof intro_classes obtain basisA :: \'a set\ where [simp]: \cspan basisA = UNIV\ \cindependent basisA\ \finite basisA\ using finite_basis by blast obtain basisB :: \'b set\ where [simp]: \cspan basisB = UNIV\ \cindependent basisB\ \finite basisB\ using finite_basis by blast define f where \f a b = cconstruct basisA (\x. if x=a then b else 0)\ for a :: 'a and b :: 'b have f_a: \f a b a = b\ if \a : basisA\ for a b by (simp add: complex_vector.construct_basis f_def that) have f_not_a: \f a b c = 0\ if \a : basisA\ and \c : basisA\ and \a \ c\for a b c using that by (simp add: complex_vector.construct_basis f_def) define F where \F a b = CBlinfun (f a b)\ for a b have \clinear (f a b)\ for a b by (auto intro: complex_vector.linear_construct simp: f_def) then have \bounded_clinear (f a b)\ for a b by auto then have F_apply: \cblinfun_apply (F a b) = f a b\ for a b by (simp add: F_def bounded_clinear_CBlinfun_apply) define basis where \basis = {F a b| a b. a\basisA \ b\basisB}\ have \cspan basis = UNIV\ apply (rule cblinfun_cspan_UNIV[where basisA=basisA and basisB=basisB]) apply (auto simp: basis_def) by (metis F_apply f_a f_not_a) moreover have \finite basis\ unfolding basis_def apply (rule finite_image_set2) by auto ultimately show \\S :: ('a \\<^sub>C\<^sub>L 'b) set. finite S \ cspan S = UNIV\ by auto qed subsection \Relationship to real bounded operators (\<^typ>\_ \\<^sub>L _\)\ instantiation blinfun :: (real_normed_vector, complex_normed_vector) "complex_normed_vector" begin lift_definition scaleC_blinfun :: \complex \ ('a::real_normed_vector, 'b::complex_normed_vector) blinfun \ ('a, 'b) blinfun\ is \\ c::complex. \ f::'a\'b. (\ x. c *\<^sub>C (f x) )\ proof fix c::complex and f :: \'a\'b\ and b1::'a and b2::'a assume \bounded_linear f\ show \c *\<^sub>C f (b1 + b2) = c *\<^sub>C f b1 + c *\<^sub>C f b2\ by (simp add: \bounded_linear f\ linear_simps scaleC_add_right) fix c::complex and f :: \'a\'b\ and b::'a and r::real assume \bounded_linear f\ show \c *\<^sub>C f (r *\<^sub>R b) = r *\<^sub>R (c *\<^sub>C f b)\ by (simp add: \bounded_linear f\ linear_simps(5) scaleR_scaleC) fix c::complex and f :: \'a\'b\ assume \bounded_linear f\ have \\ K. \ x. norm (f x) \ norm x * K\ using \bounded_linear f\ by (simp add: bounded_linear.bounded) then obtain K where \\ x. norm (f x) \ norm x * K\ by blast have \cmod c \ 0\ by simp hence \\ x. (cmod c) * norm (f x) \ (cmod c) * norm x * K\ using \\ x. norm (f x) \ norm x * K\ by (metis ordered_comm_semiring_class.comm_mult_left_mono vector_space_over_itself.scale_scale) moreover have \norm (c *\<^sub>C f x) = (cmod c) * norm (f x)\ for x by simp ultimately show \\K. \x. norm (c *\<^sub>C f x) \ norm x * K\ by (metis ab_semigroup_mult_class.mult_ac(1) mult.commute) qed instance proof have "r *\<^sub>R x = complex_of_real r *\<^sub>C x" for x :: "('a, 'b) blinfun" and r apply transfer by (simp add: scaleR_scaleC) thus "((*\<^sub>R) r::'a \\<^sub>L 'b \ _) = (*\<^sub>C) (complex_of_real r)" for r by auto show "a *\<^sub>C (x + y) = a *\<^sub>C x + a *\<^sub>C y" for a :: complex and x y :: "'a \\<^sub>L 'b" apply transfer by (simp add: scaleC_add_right) show "(a + b) *\<^sub>C x = a *\<^sub>C x + b *\<^sub>C x" for a b :: complex and x :: "'a \\<^sub>L 'b" apply transfer by (simp add: scaleC_add_left) show "a *\<^sub>C b *\<^sub>C x = (a * b) *\<^sub>C x" for a b :: complex and x :: "'a \\<^sub>L 'b" apply transfer by simp have \1 *\<^sub>C f x = f x\ for f :: \'a\'b\ and x by auto thus "1 *\<^sub>C x = x" for x :: "'a \\<^sub>L 'b" by (simp add: scaleC_blinfun.rep_eq blinfun_eqI) have \onorm (\x. a *\<^sub>C f x) = cmod a * onorm f\ if \bounded_linear f\ for f :: \'a \ 'b\ and a :: complex proof- have \cmod a \ 0\ by simp have \\ K::real. \ x. (\ ereal ((norm (f x)) / (norm x)) \) \ K\ using \bounded_linear f\ le_onorm by fastforce then obtain K::real where \\ x. (\ ereal ((norm (f x)) / (norm x)) \) \ K\ by blast hence \\ x. (cmod a) *(\ ereal ((norm (f x)) / (norm x)) \) \ (cmod a) * K\ using \cmod a \ 0\ by (metis abs_ereal.simps(1) abs_ereal_pos abs_pos ereal_mult_left_mono times_ereal.simps(1)) hence \\ x. (\ ereal ((cmod a) * (norm (f x)) / (norm x)) \) \ (cmod a) * K\ by simp hence \bdd_above {ereal (cmod a * (norm (f x)) / (norm x)) | x. True}\ by simp moreover have \{ereal (cmod a * (norm (f x)) / (norm x)) | x. True} \ {}\ by auto ultimately have p1: \(SUP x. \ereal (cmod a * (norm (f x)) / (norm x))\) \ cmod a * K\ using \\ x. \ ereal (cmod a * (norm (f x)) / (norm x)) \ \ cmod a * K\ Sup_least mem_Collect_eq by (simp add: SUP_le_iff) have p2: \\i. i \ UNIV \ 0 \ ereal (cmod a * norm (f i) / norm i)\ by simp hence \\SUP x. ereal (cmod a * (norm (f x)) / (norm x))\ \ (SUP x. \ereal (cmod a * (norm (f x)) / (norm x))\)\ using \bdd_above {ereal (cmod a * (norm (f x)) / (norm x)) | x. True}\ \{ereal (cmod a * (norm (f x)) / (norm x)) | x. True} \ {}\ by (metis (mono_tags, lifting) SUP_upper2 Sup.SUP_cong UNIV_I p2 abs_ereal_ge0 ereal_le_real) hence \\SUP x. ereal (cmod a * (norm (f x)) / (norm x))\ \ cmod a * K\ using \(SUP x. \ereal (cmod a * (norm (f x)) / (norm x))\) \ cmod a * K\ by simp hence \\ ( SUP i\UNIV::'a set. ereal ((\ x. (cmod a) * (norm (f x)) / norm x) i)) \ \ \\ by auto hence w2: \( SUP i\UNIV::'a set. ereal ((\ x. cmod a * (norm (f x)) / norm x) i)) = ereal ( Sup ((\ x. cmod a * (norm (f x)) / norm x) ` (UNIV::'a set) ))\ by (simp add: ereal_SUP) have \(UNIV::('a set)) \ {}\ by simp moreover have \\ i. i \ (UNIV::('a set)) \ (\ x. (norm (f x)) / norm x :: ereal) i \ 0\ by simp moreover have \cmod a \ 0\ by simp ultimately have \(SUP i\(UNIV::('a set)). ((cmod a)::ereal) * (\ x. (norm (f x)) / norm x :: ereal) i ) = ((cmod a)::ereal) * ( SUP i\(UNIV::('a set)). (\ x. (norm (f x)) / norm x :: ereal) i )\ by (simp add: Sup_ereal_mult_left') hence \(SUP x. ((cmod a)::ereal) * ( (norm (f x)) / norm x :: ereal) ) = ((cmod a)::ereal) * ( SUP x. ( (norm (f x)) / norm x :: ereal) )\ by simp hence z1: \real_of_ereal ( (SUP x. ((cmod a)::ereal) * ( (norm (f x)) / norm x :: ereal) ) ) = real_of_ereal ( ((cmod a)::ereal) * ( SUP x. ( (norm (f x)) / norm x :: ereal) ) )\ by simp have z2: \real_of_ereal (SUP x. ((cmod a)::ereal) * ( (norm (f x)) / norm x :: ereal) ) = (SUP x. cmod a * (norm (f x) / norm x))\ using w2 by auto have \real_of_ereal ( ((cmod a)::ereal) * ( SUP x. ( (norm (f x)) / norm x :: ereal) ) ) = (cmod a) * real_of_ereal ( SUP x. ( (norm (f x)) / norm x :: ereal) )\ by simp moreover have \real_of_ereal ( SUP x. ( (norm (f x)) / norm x :: ereal) ) = ( SUP x. ((norm (f x)) / norm x) )\ proof- have \\ ( SUP i\UNIV::'a set. ereal ((\ x. (norm (f x)) / norm x) i)) \ \ \\ proof- have \\ K::real. \ x. (\ ereal ((norm (f x)) / (norm x)) \) \ K\ using \bounded_linear f\ le_onorm by fastforce then obtain K::real where \\ x. (\ ereal ((norm (f x)) / (norm x)) \) \ K\ by blast hence \bdd_above {ereal ((norm (f x)) / (norm x)) | x. True}\ by simp moreover have \{ereal ((norm (f x)) / (norm x)) | x. True} \ {}\ by auto ultimately have \(SUP x. \ereal ((norm (f x)) / (norm x))\) \ K\ using \\ x. \ ereal ((norm (f x)) / (norm x)) \ \ K\ Sup_least mem_Collect_eq by (simp add: SUP_le_iff) hence \\SUP x. ereal ((norm (f x)) / (norm x))\ \ (SUP x. \ereal ((norm (f x)) / (norm x))\)\ using \bdd_above {ereal ((norm (f x)) / (norm x)) | x. True}\ \{ereal ((norm (f x)) / (norm x)) | x. True} \ {}\ by (metis (mono_tags, lifting) SUP_upper2 Sup.SUP_cong UNIV_I \\i. i \ UNIV \ 0 \ ereal (norm (f i) / norm i)\ abs_ereal_ge0 ereal_le_real) hence \\SUP x. ereal ((norm (f x)) / (norm x))\ \ K\ using \(SUP x. \ereal ((norm (f x)) / (norm x))\) \ K\ by simp thus ?thesis by auto qed hence \ ( SUP i\UNIV::'a set. ereal ((\ x. (norm (f x)) / norm x) i)) = ereal ( Sup ((\ x. (norm (f x)) / norm x) ` (UNIV::'a set) ))\ by (simp add: ereal_SUP) thus ?thesis by simp qed have z3: \real_of_ereal ( ((cmod a)::ereal) * ( SUP x. ( (norm (f x)) / norm x :: ereal) ) ) = cmod a * (SUP x. norm (f x) / norm x)\ by (simp add: \real_of_ereal (SUP x. ereal (norm (f x) / norm x)) = (SUP x. norm (f x) / norm x)\) hence w1: \(SUP x. cmod a * (norm (f x) / norm x)) = cmod a * (SUP x. norm (f x) / norm x)\ using z1 z2 by linarith have v1: \onorm (\x. a *\<^sub>C f x) = (SUP x. norm (a *\<^sub>C f x) / norm x)\ by (simp add: onorm_def) have v2: \(SUP x. norm (a *\<^sub>C f x) / norm x) = (SUP x. ((cmod a) * norm (f x)) / norm x)\ by simp have v3: \(SUP x. ((cmod a) * norm (f x)) / norm x) = (SUP x. (cmod a) * ((norm (f x)) / norm x))\ by simp have v4: \(SUP x. (cmod a) * ((norm (f x)) / norm x)) = (cmod a) * (SUP x. ((norm (f x)) / norm x))\ using w1 by blast show \onorm (\x. a *\<^sub>C f x) = cmod a * onorm f\ using v1 v2 v3 v4 by (metis (mono_tags, lifting) onorm_def) qed thus \norm (a *\<^sub>C x) = cmod a * norm x\ for a::complex and x::\('a, 'b) blinfun\ apply transfer by blast qed end (* We do not have clinear_blinfun_compose_right *) lemma clinear_blinfun_compose_left: \clinear (\x. blinfun_compose x y)\ by (auto intro!: clinearI simp: blinfun_eqI scaleC_blinfun.rep_eq bounded_bilinear.add_left bounded_bilinear_blinfun_compose) instantiation blinfun :: (real_normed_vector, cbanach) "cbanach" begin instance.. end lemma blinfun_compose_assoc: "(A o\<^sub>L B) o\<^sub>L C = A o\<^sub>L (B o\<^sub>L C)" by (simp add: blinfun_eqI) lift_definition blinfun_of_cblinfun::\'a::complex_normed_vector \\<^sub>C\<^sub>L 'b::complex_normed_vector \ 'a \\<^sub>L 'b\ is "id" apply transfer by (simp add: bounded_clinear.bounded_linear) lift_definition blinfun_cblinfun_eq :: \'a \\<^sub>L 'b \ 'a::complex_normed_vector \\<^sub>C\<^sub>L 'b::complex_normed_vector \ bool\ is "(=)" . lemma blinfun_cblinfun_eq_bi_unique[transfer_rule]: \bi_unique blinfun_cblinfun_eq\ unfolding bi_unique_def apply transfer by auto lemma blinfun_cblinfun_eq_right_total[transfer_rule]: \right_total blinfun_cblinfun_eq\ unfolding right_total_def apply transfer by (simp add: bounded_clinear.bounded_linear) named_theorems cblinfun_blinfun_transfer lemma cblinfun_blinfun_transfer_0[cblinfun_blinfun_transfer]: "blinfun_cblinfun_eq (0::(_,_) blinfun) (0::(_,_) cblinfun)" apply transfer by simp lemma cblinfun_blinfun_transfer_plus[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> blinfun_cblinfun_eq ===> blinfun_cblinfun_eq) (+) (+)" unfolding rel_fun_def apply transfer by auto lemma cblinfun_blinfun_transfer_minus[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> blinfun_cblinfun_eq ===> blinfun_cblinfun_eq) (-) (-)" unfolding rel_fun_def apply transfer by auto lemma cblinfun_blinfun_transfer_uminus[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> blinfun_cblinfun_eq) (uminus) (uminus)" unfolding rel_fun_def apply transfer by auto definition "real_complex_eq r c \ complex_of_real r = c" lemma bi_unique_real_complex_eq[transfer_rule]: \bi_unique real_complex_eq\ unfolding real_complex_eq_def bi_unique_def by auto lemma left_total_real_complex_eq[transfer_rule]: \left_total real_complex_eq\ unfolding real_complex_eq_def left_total_def by auto lemma cblinfun_blinfun_transfer_scaleC[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(real_complex_eq ===> blinfun_cblinfun_eq ===> blinfun_cblinfun_eq) (scaleR) (scaleC)" unfolding rel_fun_def apply transfer by (simp add: real_complex_eq_def scaleR_scaleC) lemma cblinfun_blinfun_transfer_CBlinfun[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(eq_onp bounded_clinear ===> blinfun_cblinfun_eq) Blinfun CBlinfun" unfolding rel_fun_def blinfun_cblinfun_eq.rep_eq eq_onp_def by (auto simp: CBlinfun_inverse Blinfun_inverse bounded_clinear.bounded_linear) lemma cblinfun_blinfun_transfer_norm[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> (=)) norm norm" unfolding rel_fun_def apply transfer by auto lemma cblinfun_blinfun_transfer_dist[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> blinfun_cblinfun_eq ===> (=)) dist dist" unfolding rel_fun_def dist_norm apply transfer by auto lemma cblinfun_blinfun_transfer_sgn[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> blinfun_cblinfun_eq) sgn sgn" unfolding rel_fun_def sgn_blinfun_def sgn_cblinfun_def apply transfer by (auto simp: scaleR_scaleC) lemma cblinfun_blinfun_transfer_Cauchy[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(((=) ===> blinfun_cblinfun_eq) ===> (=)) Cauchy Cauchy" proof - note cblinfun_blinfun_transfer[transfer_rule] show ?thesis unfolding Cauchy_def by transfer_prover qed lemma cblinfun_blinfun_transfer_tendsto[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(((=) ===> blinfun_cblinfun_eq) ===> blinfun_cblinfun_eq ===> (=) ===> (=)) tendsto tendsto" proof - note cblinfun_blinfun_transfer[transfer_rule] show ?thesis unfolding tendsto_iff by transfer_prover qed lemma cblinfun_blinfun_transfer_compose[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> blinfun_cblinfun_eq ===> blinfun_cblinfun_eq) (o\<^sub>L) (o\<^sub>C\<^sub>L)" unfolding rel_fun_def apply transfer by auto lemma cblinfun_blinfun_transfer_apply[cblinfun_blinfun_transfer]: includes lifting_syntax shows "(blinfun_cblinfun_eq ===> (=) ===> (=)) blinfun_apply cblinfun_apply" unfolding rel_fun_def apply transfer by auto lemma blinfun_of_cblinfun_inj: \blinfun_of_cblinfun f = blinfun_of_cblinfun g \ f = g\ by (metis cblinfun_apply_inject blinfun_of_cblinfun.rep_eq) lemma blinfun_of_cblinfun_inv: assumes "\c. \x. f *\<^sub>v (c *\<^sub>C x) = c *\<^sub>C (f *\<^sub>v x)" shows "\g. blinfun_of_cblinfun g = f" using assms proof transfer show "\g\Collect bounded_clinear. id g = f" if "bounded_linear f" and "\c x. f (c *\<^sub>C x) = c *\<^sub>C f x" for f :: "'a \ 'b" using that bounded_linear_bounded_clinear by auto qed lemma blinfun_of_cblinfun_zero: \blinfun_of_cblinfun 0 = 0\ apply transfer by simp lemma blinfun_of_cblinfun_uminus: \blinfun_of_cblinfun (- f) = - (blinfun_of_cblinfun f)\ apply transfer by auto lemma blinfun_of_cblinfun_minus: \blinfun_of_cblinfun (f - g) = blinfun_of_cblinfun f - blinfun_of_cblinfun g\ apply transfer by auto lemma blinfun_of_cblinfun_scaleC: \blinfun_of_cblinfun (c *\<^sub>C f) = c *\<^sub>C (blinfun_of_cblinfun f)\ apply transfer by auto lemma blinfun_of_cblinfun_scaleR: \blinfun_of_cblinfun (c *\<^sub>R f) = c *\<^sub>R (blinfun_of_cblinfun f)\ apply transfer by auto lemma blinfun_of_cblinfun_norm: fixes f::\'a::complex_normed_vector \\<^sub>C\<^sub>L 'b::complex_normed_vector\ shows \norm f = norm (blinfun_of_cblinfun f)\ apply transfer by auto subsection \Composition\ lemma blinfun_of_cblinfun_cblinfun_compose: fixes f::\'b::complex_normed_vector \\<^sub>C\<^sub>L 'c::complex_normed_vector\ and g::\'a::complex_normed_vector \\<^sub>C\<^sub>L 'b\ shows \blinfun_of_cblinfun (f o\<^sub>C\<^sub>L g) = (blinfun_of_cblinfun f) o\<^sub>L (blinfun_of_cblinfun g)\ apply transfer by auto lemma cblinfun_compose_assoc: shows "(A o\<^sub>C\<^sub>L B) o\<^sub>C\<^sub>L C = A o\<^sub>C\<^sub>L (B o\<^sub>C\<^sub>L C)" by (metis (no_types, lifting) cblinfun_apply_inject fun.map_comp cblinfun_compose.rep_eq) lemma cblinfun_compose_zero_right[simp]: "U o\<^sub>C\<^sub>L 0 = 0" using bounded_cbilinear.zero_right bounded_cbilinear_cblinfun_compose by blast lemma cblinfun_compose_zero_left[simp]: "0 o\<^sub>C\<^sub>L U = 0" using bounded_cbilinear.zero_left bounded_cbilinear_cblinfun_compose by blast lemma cblinfun_compose_scaleC_left[simp]: fixes A::"'b::complex_normed_vector \\<^sub>C\<^sub>L 'c::complex_normed_vector" and B::"'a::complex_normed_vector \\<^sub>C\<^sub>L 'b" shows \(a *\<^sub>C A) o\<^sub>C\<^sub>L B = a *\<^sub>C (A o\<^sub>C\<^sub>L B)\ by (simp add: bounded_cbilinear.scaleC_left bounded_cbilinear_cblinfun_compose) lemma cblinfun_compose_scaleR_left[simp]: fixes A::"'b::complex_normed_vector \\<^sub>C\<^sub>L 'c::complex_normed_vector" and B::"'a::complex_normed_vector \\<^sub>C\<^sub>L 'b" shows \(a *\<^sub>R A) o\<^sub>C\<^sub>L B = a *\<^sub>R (A o\<^sub>C\<^sub>L B)\ by (simp add: scaleR_scaleC) lemma cblinfun_compose_scaleC_right[simp]: fixes A::"'b::complex_normed_vector \\<^sub>C\<^sub>L 'c::complex_normed_vector" and B::"'a::complex_normed_vector \\<^sub>C\<^sub>L 'b" shows \A o\<^sub>C\<^sub>L (a *\<^sub>C B) = a *\<^sub>C (A o\<^sub>C\<^sub>L B)\ apply transfer by (auto intro!: ext bounded_clinear.clinear complex_vector.linear_scale) lemma cblinfun_compose_scaleR_right[simp]: fixes A::"'b::complex_normed_vector \\<^sub>C\<^sub>L 'c::complex_normed_vector" and B::"'a::complex_normed_vector \\<^sub>C\<^sub>L 'b" shows \A o\<^sub>C\<^sub>L (a *\<^sub>R B) = a *\<^sub>R (A o\<^sub>C\<^sub>L B)\ by (simp add: scaleR_scaleC) lemma cblinfun_compose_id_right[simp]: shows "U o\<^sub>C\<^sub>L id_cblinfun = U" apply transfer by auto lemma cblinfun_compose_id_left[simp]: shows "id_cblinfun o\<^sub>C\<^sub>L U = U" apply transfer by auto lemma cblinfun_eq_on: fixes A B :: "'a::cbanach \\<^sub>C\<^sub>L'b::complex_normed_vector" assumes "\x. x \ G \ A *\<^sub>V x = B *\<^sub>V x" and \t \ closure (cspan G)\ shows "A *\<^sub>V t = B *\<^sub>V t" using assms apply transfer using bounded_clinear_eq_on by blast lemma cblinfun_eq_gen_eqI: fixes A B :: "'a::cbanach \\<^sub>C\<^sub>L'b::complex_normed_vector" assumes "\x. x \ G \ A *\<^sub>V x = B *\<^sub>V x" and \ccspan G = \\ shows "A = B" apply (rule cblinfun_eqI) apply (rule cblinfun_eq_on[where G=G]) using assms apply auto by (metis ccspan.rep_eq iso_tuple_UNIV_I top_ccsubspace.rep_eq) lemma cblinfun_compose_add_left: \(a + b) o\<^sub>C\<^sub>L c = (a o\<^sub>C\<^sub>L c) + (b o\<^sub>C\<^sub>L c)\ by (simp add: bounded_cbilinear.add_left bounded_cbilinear_cblinfun_compose) lemma cblinfun_compose_add_right: \a o\<^sub>C\<^sub>L (b + c) = (a o\<^sub>C\<^sub>L b) + (a o\<^sub>C\<^sub>L c)\ by (simp add: bounded_cbilinear.add_right bounded_cbilinear_cblinfun_compose) lemma cbilinear_cblinfun_compose[simp]: "cbilinear cblinfun_compose" by (auto intro!: clinearI simp add: cbilinear_def bounded_cbilinear.add_left bounded_cbilinear.add_right bounded_cbilinear_cblinfun_compose) subsection \Adjoint\ lift_definition adj :: "'a::chilbert_space \\<^sub>C\<^sub>L 'b::complex_inner \ 'b \\<^sub>C\<^sub>L 'a" ("_*" [99] 100) is cadjoint by (fact cadjoint_bounded_clinear) lemma id_cblinfun_adjoint[simp]: "id_cblinfun* = id_cblinfun" apply transfer using cadjoint_id by (metis eq_id_iff) lemma double_adj[simp]: "(A*)* = A" apply transfer using double_cadjoint by blast lemma adj_cblinfun_compose[simp]: fixes B::\'a::chilbert_space \\<^sub>C\<^sub>L 'b::chilbert_space\ and A::\'b \\<^sub>C\<^sub>L 'c::complex_inner\ shows "(A o\<^sub>C\<^sub>L B)* = (B*) o\<^sub>C\<^sub>L (A*)" proof transfer fix A :: \'b \ 'c\ and B :: \'a \ 'b\ assume \bounded_clinear A\ and \bounded_clinear B\ hence \bounded_clinear (A \ B)\ by (simp add: comp_bounded_clinear) have \\ (A \ B) u, v \ = \ u, (B\<^sup>\ \ A\<^sup>\) v \\ for u v by (metis (no_types, lifting) cadjoint_univ_prop \bounded_clinear A\ \bounded_clinear B\ cinner_commute' comp_def) thus \(A \ B)\<^sup>\ = B\<^sup>\ \ A\<^sup>\\ using \bounded_clinear (A \ B)\ by (metis cadjoint_eqI cinner_commute') qed lemma scaleC_adj[simp]: "(a *\<^sub>C A)* = (cnj a) *\<^sub>C (A*)" apply transfer by (simp add: Complex_Vector_Spaces0.bounded_clinear.bounded_linear bounded_clinear_def complex_vector.linear_scale scaleC_cadjoint) lemma scaleR_adj[simp]: "(a *\<^sub>R A)* = a *\<^sub>R (A*)" by (simp add: scaleR_scaleC) lemma adj_plus: \(A + B)* = (A*) + (B*)\ proof transfer fix A B::\'b \ 'a\ assume a1: \bounded_clinear A\ and a2: \bounded_clinear B\ define F where \F = (\x. (A\<^sup>\) x + (B\<^sup>\) x)\ define G where \G = (\x. A x + B x)\ have \bounded_clinear G\ unfolding G_def by (simp add: a1 a2 bounded_clinear_add) moreover have \\F u, v\ = \u, G v\\ for u v unfolding F_def G_def using cadjoint_univ_prop a1 a2 cinner_add_left by (simp add: cadjoint_univ_prop cinner_add_left cinner_add_right) ultimately have \F = G\<^sup>\ \ using cadjoint_eqI by blast thus \(\x. A x + B x)\<^sup>\ = (\x. (A\<^sup>\) x + (B\<^sup>\) x)\ unfolding F_def G_def by auto qed lemma cinner_sup_norm_cblinfun: fixes A :: \'a::{complex_normed_vector,not_singleton} \\<^sub>C\<^sub>L 'b::complex_inner\ shows \norm A = (SUP (\,\). cmod (cinner \ (A *\<^sub>V \)) / (norm \ * norm \))\ apply transfer apply (rule cinner_sup_onorm) by (simp add: bounded_clinear.bounded_linear) lemma cinner_adj_left: fixes G :: "'b::chilbert_space \\<^sub>C\<^sub>L 'a::complex_inner" shows \\G* *\<^sub>V x, y\ = \x, G *\<^sub>V y\\ apply transfer using cadjoint_univ_prop by blast lemma cinner_adj_right: fixes G :: "'b::chilbert_space \\<^sub>C\<^sub>L 'a::complex_inner" shows \\x, G* *\<^sub>V y\ = \G *\<^sub>V x, y\\ apply transfer using cadjoint_univ_prop' by blast lemma adj_0[simp]: \0* = 0\ by (metis add_cancel_right_left adj_plus) lemma norm_adj[simp]: \norm (A*) = norm A\ for A :: \'b::chilbert_space \\<^sub>C\<^sub>L 'c::complex_inner\ proof (cases \(\x y :: 'b. x \ y) \ (\x y :: 'c. x \ y)\) case True then have c1: \class.not_singleton TYPE('b)\ apply intro_classes by simp from True have c2: \class.not_singleton TYPE('c)\ apply intro_classes by simp have normA: \norm A = (SUP (\, \). cmod (\ \\<^sub>C (A *\<^sub>V \)) / (norm \ * norm \))\ apply (rule cinner_sup_norm_cblinfun[internalize_sort \'a::{complex_normed_vector,not_singleton}\]) apply (rule complex_normed_vector_axioms) by (rule c1) have normAadj: \norm (A*) = (SUP (\, \). cmod (\ \\<^sub>C (A* *\<^sub>V \)) / (norm \ * norm \))\ apply (rule cinner_sup_norm_cblinfun[internalize_sort \'a::{complex_normed_vector,not_singleton}\]) apply (rule complex_normed_vector_axioms) by (rule c2) have \norm (A*) = (SUP (\, \). cmod (\ \\<^sub>C (A *\<^sub>V \)) / (norm \ * norm \))\ unfolding normAadj apply (subst cinner_adj_right) apply (subst cinner_commute) apply (subst complex_mod_cnj) by rule also have \\ = Sup ((\(\, \). cmod (\ \\<^sub>C (A *\<^sub>V \)) / (norm \ * norm \)) ` prod.swap ` UNIV)\ by auto also have \\ = (SUP (\, \). cmod (\ \\<^sub>C (A *\<^sub>V \)) / (norm \ * norm \))\ apply (subst image_image) by auto also have \\ = norm A\ unfolding normA by (simp add: mult.commute) finally show ?thesis by - next case False then consider (b) \\x::'b. x = 0\ | (c) \\x::'c. x = 0\ by auto then have \A = 0\ apply (cases; transfer) apply (metis (full_types) bounded_clinear_def complex_vector.linear_0) by auto then show \norm (A*) = norm A\ by simp qed lemma antilinear_adj[simp]: \antilinear adj\ apply (rule antilinearI) by (auto simp add: adj_plus) lemma bounded_antilinear_adj[bounded_antilinear, simp]: \bounded_antilinear adj\ by (auto intro!: antilinearI exI[of _ 1] simp: bounded_antilinear_def bounded_antilinear_axioms_def adj_plus) lemma adjoint_eqI: fixes G:: \'b::chilbert_space \\<^sub>C\<^sub>L 'a::chilbert_space\ and F:: \'a \\<^sub>C\<^sub>L 'b\ assumes \\x y. \(cblinfun_apply F) x, y\ = \x, (cblinfun_apply G) y\\ shows \F = G*\ using assms apply transfer using cadjoint_eqI by auto lemma cinner_real_hermiteanI: \ \Prop. II.2.12 in @{cite conway2013course}\ assumes \\\. cinner \ (A *\<^sub>V \) \ \\ shows \A = A*\ proof - { fix g h :: 'a { fix \ :: complex have \cinner h (A h) + cnj \ *\<^sub>C cinner g (A h) + \ *\<^sub>C cinner h (A g) + (abs \)\<^sup>2 * cinner g (A g) = cinner (h + \ *\<^sub>C g) (A *\<^sub>V (h + \ *\<^sub>C g))\ (is \?sum4 = _\) apply (auto simp: cinner_add_right cinner_add_left cblinfun.add_right cblinfun.scaleC_right ring_class.ring_distribs) by (metis cnj_x_x mult.commute) also have \\ \ \\ using assms by auto finally have \?sum4 = cnj ?sum4\ using Reals_cnj_iff by fastforce then have \cnj \ *\<^sub>C cinner g (A h) + \ *\<^sub>C cinner h (A g) = \ *\<^sub>C cinner (A h) g + cnj \ *\<^sub>C cinner (A g) h\ using Reals_cnj_iff abs_complex_real assms by force also have \\ = \ *\<^sub>C cinner h (A* *\<^sub>V g) + cnj \ *\<^sub>C cinner g (A* *\<^sub>V h)\ by (simp add: cinner_adj_right) finally have \cnj \ *\<^sub>C cinner g (A h) + \ *\<^sub>C cinner h (A g) = \ *\<^sub>C cinner h (A* *\<^sub>V g) + cnj \ *\<^sub>C cinner g (A* *\<^sub>V h)\ by - } from this[where \2=1] this[where \2=\] have 1: \cinner g (A h) + cinner h (A g) = cinner h (A* *\<^sub>V g) + cinner g (A* *\<^sub>V h)\ and i: \- \ * cinner g (A h) + \ *\<^sub>C cinner h (A g) = \ *\<^sub>C cinner h (A* *\<^sub>V g) - \ *\<^sub>C cinner g (A* *\<^sub>V h)\ by auto from arg_cong2[OF 1 arg_cong[OF i, where f=\(*) (-\)\], where f=plus] have \cinner h (A g) = cinner h (A* *\<^sub>V g)\ by (auto simp: ring_class.ring_distribs) } then show "A = A*" by (simp add: adjoint_eqI cinner_adj_right) qed lemma norm_AAadj[simp]: \norm (A o\<^sub>C\<^sub>L A*) = (norm A)\<^sup>2\ for A :: \'a::chilbert_space \\<^sub>C\<^sub>L 'b::{complex_inner}\ proof (cases \class.not_singleton TYPE('b)\) case True then have [simp]: \class.not_singleton TYPE('b)\ by - have 1: \(norm A)\<^sup>2 * \ \ norm (A o\<^sub>C\<^sub>L A*)\ if \\ < 1\ and \\ \ 0\ for \ proof - obtain \ where \: \norm ((A*) *\<^sub>V \) \ norm (A*) * sqrt \\ and [simp]: \norm \ = 1\ apply atomize_elim apply (rule cblinfun_norm_approx_witness_mult[internalize_sort' 'a]) using \\ < 1\ by (auto intro: complex_normed_vector_class.complex_normed_vector_axioms) have \complex_of_real ((norm A)\<^sup>2 * \) = (norm (A*) * sqrt \)\<^sup>2\ by (simp add: ordered_field_class.sign_simps(23) that(2)) also have \\ \ (norm ((A* *\<^sub>V \)))\<^sup>2\ apply (rule complex_of_real_mono) using \ apply (rule power_mono) using \\ \ 0\ by auto also have \\ \ cinner (A* *\<^sub>V \) (A* *\<^sub>V \)\ by (auto simp flip: power2_norm_eq_cinner) also have \\ = cinner \ (A *\<^sub>V A* *\<^sub>V \)\ by (simp add: cinner_adj_left) also have \\ = cinner \ ((A o\<^sub>C\<^sub>L A*) *\<^sub>V \)\ by auto also have \\ \ norm (A o\<^sub>C\<^sub>L A*)\ using \norm \ = 1\ by (smt (verit, best) Im_complex_of_real Re_complex_of_real \(A* *\<^sub>V \) \\<^sub>C (A* *\<^sub>V \) = \ \\<^sub>C (A *\<^sub>V A* *\<^sub>V \)\ \\ \\<^sub>C (A *\<^sub>V A* *\<^sub>V \) = \ \\<^sub>C ((A o\<^sub>C\<^sub>L A*) *\<^sub>V \)\ cdot_square_norm cinner_ge_zero cmod_Re complex_inner_class.Cauchy_Schwarz_ineq2 less_eq_complex_def mult_cancel_left1 mult_cancel_right1 norm_cblinfun) finally show ?thesis by (auto simp: less_eq_complex_def) qed then have 1: \(norm A)\<^sup>2 \ norm (A o\<^sub>C\<^sub>L A*)\ by (metis field_le_mult_one_interval less_eq_real_def ordered_field_class.sign_simps(5)) have 2: \norm (A o\<^sub>C\<^sub>L A*) \ (norm A)\<^sup>2\ proof (rule norm_cblinfun_bound) show \0 \ (norm A)\<^sup>2\ by simp fix \ have \norm ((A o\<^sub>C\<^sub>L A*) *\<^sub>V \) = norm (A *\<^sub>V A* *\<^sub>V \)\ by auto also have \\ \ norm A * norm (A* *\<^sub>V \)\ by (simp add: norm_cblinfun) also have \\ \ norm A * norm (A*) * norm \\ by (metis mult.assoc norm_cblinfun norm_imp_pos_and_ge ordered_comm_semiring_class.comm_mult_left_mono) also have \\ = (norm A)\<^sup>2 * norm \\ by (simp add: power2_eq_square) finally show \norm ((A o\<^sub>C\<^sub>L A*) *\<^sub>V \) \ (norm A)\<^sup>2 * norm \\ by - qed from 1 2 show ?thesis by simp next case False then have [simp]: \class.CARD_1 TYPE('b)\ by (rule not_singleton_vs_CARD_1) have \A = 0\ apply (rule cblinfun_to_CARD_1_0[internalize_sort' 'b]) by (auto intro: complex_normed_vector_class.complex_normed_vector_axioms) then show ?thesis by auto qed subsection \Unitaries / isometries\ definition isometry::\'a::chilbert_space \\<^sub>C\<^sub>L 'b::complex_inner \ bool\ where \isometry U \ U* o\<^sub>C\<^sub>L U = id_cblinfun\ definition unitary::\'a::chilbert_space \\<^sub>C\<^sub>L 'b::complex_inner \ bool\ where \unitary U \ (U* o\<^sub>C\<^sub>L U = id_cblinfun) \ (U o\<^sub>C\<^sub>L U* = id_cblinfun)\ lemma unitary_twosided_isometry: "unitary U \ isometry U \ isometry (U*)" unfolding unitary_def isometry_def by simp lemma isometryD[simp]: "isometry U \ U* o\<^sub>C\<^sub>L U = id_cblinfun" unfolding isometry_def by simp (* Not [simp] because isometryD[simp] + unitary_isometry[simp] already have the same effect *) lemma unitaryD1: "unitary U \ U* o\<^sub>C\<^sub>L U = id_cblinfun" unfolding unitary_def by simp lemma unitaryD2[simp]: "unitary U \ U o\<^sub>C\<^sub>L U* = id_cblinfun" unfolding unitary_def by simp lemma unitary_isometry[simp]: "unitary U \ isometry U" unfolding unitary_def isometry_def by simp lemma unitary_adj[simp]: "unitary (U*) = unitary U" unfolding unitary_def by auto lemma isometry_cblinfun_compose[simp]: assumes "isometry A" and "isometry B" shows "isometry (A o\<^sub>C\<^sub>L B)" proof- have "B* o\<^sub>C\<^sub>L A* o\<^sub>C\<^sub>L (A o\<^sub>C\<^sub>L B) = id_cblinfun" if "A* o\<^sub>C\<^sub>L A = id_cblinfun" and "B* o\<^sub>C\<^sub>L B = id_cblinfun" using that by (smt (verit, del_insts) adjoint_eqI cblinfun_apply_cblinfun_compose cblinfun_id_cblinfun_apply) thus ?thesis using assms unfolding isometry_def by simp qed lemma unitary_cblinfun_compose[simp]: "unitary (A o\<^sub>C\<^sub>L B)" if "unitary A" and "unitary B" using that by (smt (z3) adj_cblinfun_compose cblinfun_compose_assoc cblinfun_compose_id_right double_adj isometryD isometry_cblinfun_compose unitary_def unitary_isometry) lemma unitary_surj: assumes "unitary U" shows "surj (cblinfun_apply U)" apply (rule surjI[where f=\cblinfun_apply (U*)\]) using assms unfolding unitary_def apply transfer using comp_eq_dest_lhs by force lemma unitary_id[simp]: "unitary id_cblinfun" by (simp add: unitary_def) lemma orthogonal_on_basis_is_isometry: assumes spanB: \ccspan B = \\ assumes orthoU: \\b c. b\B \ c\B \ cinner (U *\<^sub>V b) (U *\<^sub>V c) = cinner b c\ shows \isometry U\ proof - have [simp]: \b \ closure (cspan B)\ for b using spanB apply transfer by simp have *: \cinner (U* *\<^sub>V U *\<^sub>V \) \ = cinner \ \\ if \\\B\ and \\\B\ for \ \ by (simp add: cinner_adj_left orthoU that(1) that(2)) have *: \cinner (U* *\<^sub>V U *\<^sub>V \) \ = cinner \ \\ if \\\B\ for \ \ apply (rule bounded_clinear_eq_on[where t=\ and G=B]) using bounded_clinear_cinner_right *[OF that] by auto have \U* *\<^sub>V U *\<^sub>V \ = \\ if \\\B\ for \ apply (rule cinner_extensionality) apply (subst cinner_eq_flip) by (simp add: * that) then have \U* o\<^sub>C\<^sub>L U = id_cblinfun\ by (metis cblinfun_apply_cblinfun_compose cblinfun_eq_gen_eqI cblinfun_id_cblinfun_apply spanB) then show \isometry U\ using isometry_def by blast qed subsection \Images\ (* Closure is necessary. See email 47a3bb3d-3cc3-0934-36eb-3ef0f7b70a85@ut.ee *) lift_definition cblinfun_image :: \'a::complex_normed_vector \\<^sub>C\<^sub>L 'b::complex_normed_vector \ 'a ccsubspace \ 'b ccsubspace\ (infixr "*\<^sub>S" 70) is "\A S. closure (A ` S)" using bounded_clinear_def closed_closure closed_csubspace.intro by (simp add: bounded_clinear_def complex_vector.linear_subspace_image closure_is_closed_csubspace) lemma cblinfun_image_mono: assumes a1: "S \ T" shows "A *\<^sub>S S \ A *\<^sub>S T" using a1 by (simp add: cblinfun_image.rep_eq closure_mono image_mono less_eq_ccsubspace.rep_eq) lemma cblinfun_image_0[simp]: shows "U *\<^sub>S 0 = 0" thm zero_ccsubspace_def apply transfer by (simp add: bounded_clinear_def complex_vector.linear_0) lemma cblinfun_image_bot[simp]: "U *\<^sub>S bot = bot" using cblinfun_image_0 by auto lemma cblinfun_image_sup[simp]: fixes A B :: \'a::chilbert_space ccsubspace\ and U :: "'a \\<^sub>C\<^sub>L'b::chilbert_space" shows \U *\<^sub>S (sup A B) = sup (U *\<^sub>S A) (U *\<^sub>S B)\ apply transfer using bounded_clinear.bounded_linear closure_image_closed_sum by blast lemma scaleC_cblinfun_image[simp]: fixes A :: \'a::chilbert_space \\<^sub>C\<^sub>L 'b :: chilbert_space\ and S :: \'a ccsubspace\ and \ :: complex shows \(\ *\<^sub>C A) *\<^sub>S S = \ *\<^sub>C (A *\<^sub>S S)\ proof- have \closure ( ( ((*\<^sub>C) \) \ (cblinfun_apply A) ) ` space_as_set S) = ((*\<^sub>C) \) ` (closure (cblinfun_apply A ` space_as_set S))\ by (metis closure_scaleC image_comp) hence \(closure (cblinfun_apply (\ *\<^sub>C A) ` space_as_set S)) = ((*\<^sub>C) \) ` (closure (cblinfun_apply A ` space_as_set S))\ by (metis (mono_tags, lifting) comp_apply image_cong scaleC_cblinfun.rep_eq) hence \Abs_clinear_space (closure (cblinfun_apply (\ *\<^sub>C A) ` space_as_set S)) = \ *\<^sub>C Abs_clinear_space (closure (cblinfun_apply A ` space_as_set S))\ by (metis space_as_set_inverse cblinfun_image.rep_eq scaleC_ccsubspace.rep_eq) have x1: "Abs_clinear_space (closure ((*\<^sub>V) (\ *\<^sub>C A) ` space_as_set S)) = \ *\<^sub>C Abs_clinear_space (closure ((*\<^sub>V) A ` space_as_set S))" using \Abs_clinear_space (closure (cblinfun_apply (\ *\<^sub>C A) ` space_as_set S)) = \ *\<^sub>C Abs_clinear_space (closure (cblinfun_apply A ` space_as_set S))\ by blast show ?thesis unfolding cblinfun_image_def using x1 by force qed lemma cblinfun_image_id[simp]: "id_cblinfun *\<^sub>S \ = \" apply transfer by (simp add: closed_csubspace.closed) lemma cblinfun_compose_image: \(A o\<^sub>C\<^sub>L B) *\<^sub>S S = A *\<^sub>S (B *\<^sub>S S)\ apply transfer unfolding image_comp[symmetric] apply (rule closure_bounded_linear_image_subset_eq[symmetric]) by (simp add: bounded_clinear.bounded_linear) lemmas cblinfun_assoc_left = cblinfun_compose_assoc[symmetric] cblinfun_compose_image[symmetric] add.assoc[where ?'a="'a::chilbert_space \\<^sub>C\<^sub>L 'b::chilbert_space", symmetric] lemmas cblinfun_assoc_right = cblinfun_compose_assoc cblinfun_compose_image add.assoc[where ?'a="'a::chilbert_space \\<^sub>C\<^sub>L 'b::chilbert_space"] lemma cblinfun_image_INF_leq[simp]: fixes U :: "'b::complex_normed_vector \\<^sub>C\<^sub>L 'c::cbanach" and V :: "'a \ 'b ccsubspace" shows \U *\<^sub>S (INF i. V i) \ (INF i. U *\<^sub>S (V i))\ apply transfer by (simp add: INT_greatest Inter_lower closure_mono image_mono) lemma isometry_cblinfun_image_inf_distrib': fixes U::\'a::complex_normed_vector \\<^sub>C\<^sub>L 'b::cbanach\ and B C::"'a ccsubspace" shows "U *\<^sub>S (inf B C) \ inf (U *\<^sub>S B) (U *\<^sub>S C)" proof - define V where \V b = (if b then B else C)\ for b have \U *\<^sub>S (INF i. V i) \ (INF i. U *\<^sub>S (V i))\ by auto then show ?thesis unfolding V_def by (metis (mono_tags, lifting) INF_UNIV_bool_expand) qed lemma cblinfun_image_eq: fixes S :: "'a::cbanach ccsubspace" and A B :: "'a::cbanach \\<^sub>C\<^sub>L'b::cbanach" assumes "\x. x \ G \ A *\<^sub>V x = B *\<^sub>V x" and "ccspan G \ S" shows "A *\<^sub>S S = B *\<^sub>S S" proof (use assms in transfer) fix G :: "'a set" and A :: "'a \ 'b" and B :: "'a \ 'b" and S :: "'a set" assume a1: "bounded_clinear A" assume a2: "bounded_clinear B" assume a3: "\x. x \ G \ A x = B x" assume a4: "S \ closure (cspan G)" have "A ` closure S = B ` closure S" by (smt (verit, best) UnCI a1 a2 a3 a4 bounded_clinear_eq_on closure_Un closure_closure image_cong sup.absorb_iff1) then show "closure (A ` S) = closure (B ` S)" by (metis Complex_Vector_Spaces0.bounded_clinear.bounded_linear a1 a2 closure_bounded_linear_image_subset_eq) qed lemma cblinfun_fixes_range: assumes "A o\<^sub>C\<^sub>L B = B" and "\ \ space_as_set (B *\<^sub>S top)" shows "A *\<^sub>V \ = \" proof- define rangeB rangeB' where "rangeB = space_as_set (B *\<^sub>S top)" and "rangeB' = range (cblinfun_apply B)" from assms have "\ \ closure rangeB'" by (simp add: cblinfun_image.rep_eq rangeB'_def top_ccsubspace.rep_eq) then obtain \i where \i_lim: "\i \ \" and \i_B: "\i i \ rangeB'" for i using closure_sequential by blast have A_invariant: "A *\<^sub>V \i i = \i i" for i proof- from \i_B obtain \ where \: "\i i = B *\<^sub>V \" using rangeB'_def by blast hence "A *\<^sub>V \i i = (A o\<^sub>C\<^sub>L B) *\<^sub>V \" by (simp add: cblinfun_compose.rep_eq) also have "\ = B *\<^sub>V \" by (simp add: assms) also have "\ = \i i" by (simp add: \) finally show ?thesis. qed from \i_lim have "(\i. A *\<^sub>V (\i i)) \ A *\<^sub>V \" by (rule isCont_tendsto_compose[rotated], simp) with A_invariant have "(\i. \i i) \ A *\<^sub>V \" by auto with \i_lim show "A *\<^sub>V \ = \" using LIMSEQ_unique by blast qed lemma zero_cblinfun_image[simp]: "0 *\<^sub>S S = (0::_ ccsubspace)" apply transfer by (simp add: complex_vector.subspace_0 image_constant[where x=0]) lemma cblinfun_image_INF_eq_general: fixes V :: "'a \ 'b::chilbert_space ccsubspace" and U :: "'b \\<^sub>C\<^sub>L'c::chilbert_space" and Uinv :: "'c \\<^sub>C\<^sub>L'b" assumes UinvUUinv: "Uinv o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L Uinv = Uinv" and UUinvU: "U o\<^sub>C\<^sub>L Uinv o\<^sub>C\<^sub>L U = U" \ \Meaning: \<^term>\Uinv\ is a Pseudoinverse of \<^term>\U\\ and V: "\i. V i \ Uinv *\<^sub>S top" shows "U *\<^sub>S (INF i. V i) = (INF i. U *\<^sub>S V i)" proof (rule antisym) show "U *\<^sub>S (INF i. V i) \ (INF i. U *\<^sub>S V i)" by (rule cblinfun_image_INF_leq) next define rangeU rangeUinv where "rangeU = U *\<^sub>S top" and "rangeUinv = Uinv *\<^sub>S top" define INFUV INFV where INFUV_def: "INFUV = (INF i. U *\<^sub>S V i)" and INFV_def: "INFV = (INF i. V i)" from assms have "V i \ rangeUinv" for i unfolding rangeUinv_def by simp moreover have "(Uinv o\<^sub>C\<^sub>L U) *\<^sub>V \ = \" if "\ \ space_as_set rangeUinv" for \ using UinvUUinv cblinfun_fixes_range rangeUinv_def that by fastforce ultimately have "(Uinv o\<^sub>C\<^sub>L U) *\<^sub>V \ = \" if "\ \ space_as_set (V i)" for \ i using less_eq_ccsubspace.rep_eq that by blast hence d1: "(Uinv o\<^sub>C\<^sub>L U) *\<^sub>S (V i) = (V i)" for i proof transfer show "closure ((Uinv \ U) ` V i) = V i" if "pred_fun \ closed_csubspace V" and "bounded_clinear Uinv" and "bounded_clinear U" and "\\ i. \ \ V i \ (Uinv \ U) \ = \" for V :: "'a \ 'b set" and Uinv :: "'c \ 'b" and U :: "'b \ 'c" and i :: 'a using that proof auto show "x \ V i" if "\x. closed_csubspace (V x)" and "bounded_clinear Uinv" and "bounded_clinear U" and "\\ i. \ \ V i \ Uinv (U \) = \" and "x \ closure (V i)" for x :: 'b using that by (metis orthogonal_complement_of_closure closed_csubspace.subspace double_orthogonal_complement_id closure_is_closed_csubspace) show "x \ closure (V i)" if "\x. closed_csubspace (V x)" and "bounded_clinear Uinv" and "bounded_clinear U" and "\\ i. \ \ V i \ Uinv (U \) = \" and "x \ V i" for x :: 'b using that using setdist_eq_0_sing_1 setdist_sing_in_set by blast qed qed have "U *\<^sub>S V i \ rangeU" for i by (simp add: cblinfun_image_mono rangeU_def) hence "INFUV \ rangeU" unfolding INFUV_def by (meson INF_lower UNIV_I order_trans) moreover have "(U o\<^sub>C\<^sub>L Uinv) *\<^sub>V \ = \" if "\ \ space_as_set rangeU" for \ using UUinvU cblinfun_fixes_range rangeU_def that by fastforce ultimately have x: "(U o\<^sub>C\<^sub>L Uinv) *\<^sub>V \ = \" if "\ \ space_as_set INFUV" for \ by (simp add: in_mono less_eq_ccsubspace.rep_eq that) have "closure ((U \ Uinv) ` INFUV) = INFUV" if "closed_csubspace INFUV" and "bounded_clinear U" and "bounded_clinear Uinv" and "\\. \ \ INFUV \ (U \ Uinv) \ = \" for INFUV :: "'c set" and U :: "'b \ 'c" and Uinv :: "'c \ 'b" using that proof auto show "x \ INFUV" if "closed_csubspace INFUV" and "bounded_clinear U" and "bounded_clinear Uinv" and "\\. \ \ INFUV \ U (Uinv \) = \" and "x \ closure INFUV" for x :: 'c using that by (metis orthogonal_complement_of_closure closed_csubspace.subspace double_orthogonal_complement_id closure_is_closed_csubspace) show "x \ closure INFUV" if "closed_csubspace INFUV" and "bounded_clinear U" and "bounded_clinear Uinv" and "\\. \ \ INFUV \ U (Uinv \) = \" and "x \ INFUV" for x :: 'c using that using setdist_eq_0_sing_1 setdist_sing_in_set by (simp add: closed_csubspace.closed) qed hence "(U o\<^sub>C\<^sub>L Uinv) *\<^sub>S INFUV = INFUV" by (metis (mono_tags, opaque_lifting) x cblinfun_image.rep_eq cblinfun_image_id id_cblinfun_apply image_cong space_as_set_inject) hence "INFUV = U *\<^sub>S Uinv *\<^sub>S INFUV" by (simp add: cblinfun_compose_image) also have "\ \ U *\<^sub>S (INF i. Uinv *\<^sub>S U *\<^sub>S V i)" unfolding INFUV_def by (metis cblinfun_image_mono cblinfun_image_INF_leq) also have "\ = U *\<^sub>S INFV" using d1 by (metis (no_types, lifting) INFV_def cblinfun_assoc_left(2) image_cong) finally show "INFUV \ U *\<^sub>S INFV". qed lemma unitary_range[simp]: assumes "unitary U" shows "U *\<^sub>S top = top" using assms unfolding unitary_def apply transfer by (metis closure_UNIV comp_apply surj_def) lemma range_adjoint_isometry: assumes "isometry U" shows "U* *\<^sub>S top = top" proof- from assms have "top = U* *\<^sub>S U *\<^sub>S top" by (simp add: cblinfun_assoc_left(2)) also have "\ \ U* *\<^sub>S top" by (simp add: cblinfun_image_mono) finally show ?thesis using top.extremum_unique by blast qed lemma cblinfun_image_INF_eq[simp]: fixes V :: "'a \ 'b::chilbert_space ccsubspace" and U :: "'b \\<^sub>C\<^sub>L 'c::chilbert_space" assumes \isometry U\ shows "U *\<^sub>S (INF i. V i) = (INF i. U *\<^sub>S V i)" proof - from \isometry U\ have "U* o\<^sub>C\<^sub>L U o\<^sub>C\<^sub>L U* = U*" unfolding isometry_def by simp moreover from \isometry U\ have "U o\<^sub>C\<^sub>L U* o\<^sub>C\<^sub>L U = U" unfolding isometry_def by (simp add: cblinfun_compose_assoc) moreover have "V i \ U* *\<^sub>S top" for i by (simp add: range_adjoint_isometry assms) ultimately show ?thesis by (rule cblinfun_image_INF_eq_general) qed lemma isometry_cblinfun_image_inf_distrib[simp]: fixes U::\'a::chilbert_space \\<^sub>C\<^sub>L 'b::chilbert_space\ and X Y::"'a ccsubspace" assumes "isometry U" shows "U *\<^sub>S (inf X Y) = inf (U *\<^sub>S X) (U *\<^sub>S Y)" using cblinfun_image_INF_eq[where V="\b. if b then X else Y" and U=U] unfolding INF_UNIV_bool_expand using assms by auto lemma cblinfun_image_ccspan: shows "A *\<^sub>S ccspan G = ccspan ((*\<^sub>V) A ` G)" apply transfer by (simp add: bounded_clinear.bounded_linear bounded_clinear_def closure_bounded_linear_image_subset_eq complex_vector.linear_span_image) lemma cblinfun_apply_in_image[simp]: "A *\<^sub>V \ \ space_as_set (A *\<^sub>S \)" by (metis cblinfun_image.rep_eq closure_subset in_mono range_eqI top_ccsubspace.rep_eq) lemma cblinfun_plus_image_distr: \(A + B) *\<^sub>S S \ A *\<^sub>S S \ B *\<^sub>S S\ apply transfer by (smt (verit, ccfv_threshold) closed_closure closed_sum_def closure_minimal closure_subset image_subset_iff set_plus_intro subset_eq) lemma cblinfun_sum_image_distr: \(\i\I. A i) *\<^sub>S S \ (SUP i\I. A i *\<^sub>S S)\ proof (cases \finite I\) case True then show ?thesis proof induction case empty then show ?case by auto next case (insert x F) then show ?case apply auto by (smt (z3) cblinfun_plus_image_distr inf_sup_aci(6) le_iff_sup) qed next case False then show ?thesis by auto qed subsection \Sandwiches\ lift_definition sandwich :: \('a::chilbert_space \\<^sub>C\<^sub>L 'b::complex_inner) \ (('a \\<^sub>C\<^sub>L 'a) \\<^sub>C\<^sub>L ('b \\<^sub>C\<^sub>L 'b))\ is \\(A::'a\\<^sub>C\<^sub>L'b) B. A o\<^sub>C\<^sub>L B o\<^sub>C\<^sub>L A*\ proof fix A :: \'a \\<^sub>C\<^sub>L 'b\ and B B1 B2 :: \'a \\<^sub>C\<^sub>L 'a\ and c :: complex show \A o\<^sub>C\<^sub>L (B1 + B2) o\<^sub>C\<^sub>L A* = (A o\<^sub>C\<^sub>L B1 o\<^sub>C\<^sub>L A*) + (A o\<^sub>C\<^sub>L B2 o\<^sub>C\<^sub>L A*)\ by (simp add: cblinfun_compose_add_left cblinfun_compose_add_right) show \A o\<^sub>C\<^sub>L (c *\<^sub>C B) o\<^sub>C\<^sub>L A* = c *\<^sub>C (A o\<^sub>C\<^sub>L B o\<^sub>C\<^sub>L A*)\ by auto show \\K. \B. norm (A o\<^sub>C\<^sub>L B o\<^sub>C\<^sub>L A*) \ norm B * K\ proof (rule exI[of _ \norm A * norm (A*)\], rule allI) fix B have \norm (A o\<^sub>C\<^sub>L B o\<^sub>C\<^sub>L A*) \ norm (A o\<^sub>C\<^sub>L B) * norm (A*)\ using norm_cblinfun_compose by blast also have \\ \ (norm A * norm B) * norm (A*)\ by (simp add: mult_right_mono norm_cblinfun_compose) finally show \norm (A o\<^sub>C\<^sub>L B o\<^sub>C\<^sub>L A*) \ norm B * (norm A * norm (A*))\ by (simp add: mult.assoc vector_space_over_itself.scale_left_commute) qed qed lemma sandwich_0[simp]: \sandwich 0 = 0\ by (simp add: cblinfun_eqI sandwich.rep_eq) lemma sandwich_apply: \sandwich A *\<^sub>V B = A o\<^sub>C\<^sub>L B o\<^sub>C\<^sub>L A*\ apply (transfer fixing: A B) by auto lemma norm_sandwich: \norm (sandwich A) = (norm A)\<^sup>2\ for A :: \'a::{chilbert_space} \\<^sub>C\<^sub>L 'b::{complex_inner}\ proof - have main: \norm (sandwich A) = (norm A)\<^sup>2\ for A :: \'c::{chilbert_space,not_singleton} \\<^sub>C\<^sub>L 'd::{complex_inner}\ proof (rule norm_cblinfun_eqI) show \(norm A)\<^sup>2 \ norm (sandwich A *\<^sub>V id_cblinfun) / norm (id_cblinfun :: 'c \\<^sub>C\<^sub>L _)\ apply (auto simp: sandwich_apply) by - fix B have \norm (sandwich A *\<^sub>V B) \ norm (A o\<^sub>C\<^sub>L B) * norm (A*)\ using norm_cblinfun_compose by (auto simp: sandwich_apply simp del: norm_adj) also have \\ \ (norm A * norm B) * norm (A*)\ by (simp add: mult_right_mono norm_cblinfun_compose) also have \\ \ (norm A)\<^sup>2 * norm B\ by (simp add: power2_eq_square mult.assoc vector_space_over_itself.scale_left_commute) finally show \norm (sandwich A *\<^sub>V B) \ (norm A)\<^sup>2 * norm B\ by - show \0 \ (norm A)\<^sup>2\ by auto qed show ?thesis proof (cases \class.not_singleton TYPE('a)\) case True show ?thesis apply (rule main[internalize_sort' 'c2]) apply standard[1] using True by simp next case False have \A = 0\ apply (rule cblinfun_from_CARD_1_0[internalize_sort' 'a]) apply (rule not_singleton_vs_CARD_1) apply (rule False) by standard then show ?thesis by simp qed qed lemma sandwich_apply_adj: \sandwich A (B*) = (sandwich A B)*\ by (simp add: cblinfun_assoc_left(1) sandwich_apply) lemma sandwich_id[simp]: "sandwich id_cblinfun = id_cblinfun" apply (rule cblinfun_eqI) by (auto simp: sandwich_apply) subsection \Projectors\ lift_definition Proj :: "('a::chilbert_space) ccsubspace \ 'a \\<^sub>C\<^sub>L'a" is \projection\ by (rule projection_bounded_clinear) lemma Proj_range[simp]: "Proj S *\<^sub>S top = S" proof transfer fix S :: \'a set\ assume \closed_csubspace S\ then have "closure (range (projection S)) \ S" by (metis closed_csubspace.closed closed_csubspace.subspace closure_closed complex_vector.subspace_0 csubspace_is_convex dual_order.eq_iff insert_absorb insert_not_empty projection_image) moreover have "S \ closure (range (projection S))" using \closed_csubspace S\ by (metis closed_csubspace_def closure_subset csubspace_is_convex equals0D projection_image subset_iff) ultimately show \closure (range (projection S)) = S\ by auto qed lemma adj_Proj: \(Proj M)* = Proj M\ apply transfer by (simp add: projection_cadjoint) lemma Proj_idempotent[simp]: \Proj M o\<^sub>C\<^sub>L Proj M = Proj M\ proof - have u1: \(cblinfun_apply (Proj M)) = projection (space_as_set M)\ apply transfer by blast have \closed_csubspace (space_as_set M)\ using space_as_set by auto hence u2: \(projection (space_as_set M))\(projection (space_as_set M)) = (projection (space_as_set M))\ using projection_idem by fastforce have \(cblinfun_apply (Proj M)) \ (cblinfun_apply (Proj M)) = cblinfun_apply (Proj M)\ using u1 u2 by simp hence \cblinfun_apply ((Proj M) o\<^sub>C\<^sub>L (Proj M)) = cblinfun_apply (Proj M)\ by (simp add: cblinfun_compose.rep_eq) thus ?thesis using cblinfun_apply_inject by auto qed lift_definition is_Proj::\'a::chilbert_space \\<^sub>C\<^sub>L 'a \ bool\ is \\P. \M. closed_csubspace M \ is_projection_on P M\ . lemma Proj_on_own_range': fixes P :: \'a::chilbert_space \\<^sub>C\<^sub>L'a\ assumes \P o\<^sub>C\<^sub>L P = P\ and \P = P*\ shows \Proj (P *\<^sub>S top) = P\ proof- define M where "M = P *\<^sub>S top" have v3: "x \ (\x. x - P *\<^sub>V x) -` {0}" if "x \ range (cblinfun_apply P)" for x :: 'a proof- have v3_1: \cblinfun_apply P \ cblinfun_apply P = cblinfun_apply P\ by (metis \P o\<^sub>C\<^sub>L P = P\ cblinfun_compose.rep_eq) have \\t. P *\<^sub>V t = x\ using that by blast then obtain t where t_def: \P *\<^sub>V t = x\ by blast hence \x - P *\<^sub>V x = x - P *\<^sub>V (P *\<^sub>V t)\ by simp also have \\ = x - (P *\<^sub>V t)\ using v3_1 by (metis comp_apply) also have \\ = 0\ by (simp add: t_def) finally have \x - P *\<^sub>V x = 0\ by blast thus ?thesis by simp qed have v1: "range (cblinfun_apply P) \ (\x. x - cblinfun_apply P x) -` {0}" using v3 by blast have "x \ range (cblinfun_apply P)" if "x \ (\x. x - P *\<^sub>V x) -` {0}" for x :: 'a proof- have x1:\x - P *\<^sub>V x = 0\ using that by blast have \x = P *\<^sub>V x\ by (simp add: x1 eq_iff_diff_eq_0) thus ?thesis by blast qed hence v2: "(\x. x - cblinfun_apply P x) -` {0} \ range (cblinfun_apply P)" by blast have i1: \range (cblinfun_apply P) = (\ x. x - cblinfun_apply P x) -` {0}\ using v1 v2 by (simp add: v1 dual_order.antisym) have p1: \closed {(0::'a)}\ by simp have p2: \continuous (at x) (\ x. x - P *\<^sub>V x)\ for x proof- have \cblinfun_apply (id_cblinfun - P) = (\ x. x - P *\<^sub>V x)\ by (simp add: id_cblinfun.rep_eq minus_cblinfun.rep_eq) hence \bounded_clinear (cblinfun_apply (id_cblinfun - P))\ using cblinfun_apply by blast hence \continuous (at x) (cblinfun_apply (id_cblinfun - P))\ by (simp add: clinear_continuous_at) thus ?thesis using \cblinfun_apply (id_cblinfun - P) = (\ x. x - P *\<^sub>V x)\ by simp qed have i2: \closed ( (\ x. x - P *\<^sub>V x) -` {0} )\ using p1 p2 by (rule Abstract_Topology.continuous_closed_vimage) have \closed (range (cblinfun_apply P))\ using i1 i2 by simp have u2: \cblinfun_apply P x \ space_as_set M\ for x by (simp add: M_def \closed (range ((*\<^sub>V) P))\ cblinfun_image.rep_eq top_ccsubspace.rep_eq) have xy: \\ x - P *\<^sub>V x, y \ = 0\ if y1: \y \ space_as_set M\ for x y proof- have \\t. y = P *\<^sub>V t\ using y1 by (simp add: M_def \closed (range ((*\<^sub>V) P))\ cblinfun_image.rep_eq image_iff top_ccsubspace.rep_eq) then obtain t where t_def: \y = P *\<^sub>V t\ by blast have \\ x - P *\<^sub>V x, y \ = \ x - P *\<^sub>V x, P *\<^sub>V t \\ by (simp add: t_def) also have \\ = \ P *\<^sub>V (x - P *\<^sub>V x), t \\ by (metis \P = P*\ cinner_adj_left) also have \\ = \ P *\<^sub>V x - P *\<^sub>V (P *\<^sub>V x), t \\ by (simp add: cblinfun.diff_right) also have \\ = \ P *\<^sub>V x - P *\<^sub>V x, t \\ by (metis assms(1) comp_apply cblinfun_compose.rep_eq) also have \\ = \ 0, t \\ by simp also have \\ = 0\ by simp finally show ?thesis by blast qed hence u1: \x - P *\<^sub>V x \ orthogonal_complement (space_as_set M)\ for x by (simp add: orthogonal_complementI) have "closed_csubspace (space_as_set M)" using space_as_set by auto hence f1: "(Proj M) *\<^sub>V a = P *\<^sub>V a" for a by (simp add: Proj.rep_eq projection_eqI u1 u2) have "(+) ((P - Proj M) *\<^sub>V a) = id" for a using f1 by (auto intro!: ext simp add: minus_cblinfun.rep_eq) hence "b - b = cblinfun_apply (P - Proj M) a" for a b by (metis (no_types) add_diff_cancel_right' id_apply) hence "cblinfun_apply (id_cblinfun - (P - Proj M)) a = a" for a by (simp add: minus_cblinfun.rep_eq) thus ?thesis using u1 u2 cblinfun_apply_inject diff_diff_eq2 diff_eq_diff_eq eq_id_iff id_cblinfun.rep_eq by (metis (no_types, opaque_lifting) M_def) qed lemma Proj_range_closed: assumes "is_Proj P" shows "closed (range (cblinfun_apply P))" using assms apply transfer using closed_csubspace.closed is_projection_on_image by blast lemma Proj_is_Proj[simp]: fixes M::\'a::chilbert_space ccsubspace\ shows \is_Proj (Proj M)\ proof- have u1: "closed_csubspace (space_as_set M)" using space_as_set by blast have v1: "h - Proj M *\<^sub>V h \ orthogonal_complement (space_as_set M)" for h by (simp add: Proj.rep_eq orthogonal_complementI projection_orthogonal u1) have v2: "Proj M *\<^sub>V h \ space_as_set M" for h by (metis Proj.rep_eq mem_Collect_eq orthog_proj_exists projection_eqI space_as_set) have u2: "is_projection_on ((*\<^sub>V) (Proj M)) (space_as_set M)" unfolding is_projection_on_def by (simp add: smallest_dist_is_ortho u1 v1 v2) show ?thesis using u1 u2 is_Proj.rep_eq by blast qed lemma is_Proj_algebraic: fixes P::\'a::chilbert_space \\<^sub>C\<^sub>L 'a\ shows \is_Proj P \ P o\<^sub>C\<^sub>L P = P \ P = P*\ proof have "P o\<^sub>C\<^sub>L P = P" if "is_Proj P" using that apply transfer using is_projection_on_idem by fastforce moreover have "P = P*" if "is_Proj P" using that apply transfer by (metis is_projection_on_cadjoint) ultimately show "P o\<^sub>C\<^sub>L P = P \ P = P*" if "is_Proj P" using that by blast show "is_Proj P" if "P o\<^sub>C\<^sub>L P = P \ P = P*" using that Proj_on_own_range' Proj_is_Proj by metis qed lemma Proj_on_own_range: fixes P :: \'a::chilbert_space \\<^sub>C\<^sub>L'a\ assumes \is_Proj P\ shows \Proj (P *\<^sub>S top) = P\ using Proj_on_own_range' assms is_Proj_algebraic by blast lemma Proj_image_leq: "(Proj S) *\<^sub>S A \ S" by (metis Proj_range inf_top_left le_inf_iff isometry_cblinfun_image_inf_distrib') lemma Proj_sandwich: fixes A::"'a::chilbert_space \\<^sub>C\<^sub>L 'b::chilbert_space" assumes "isometry A" shows "sandwich A *\<^sub>V Proj S = Proj (A *\<^sub>S S)" proof- define P where \P = A o\<^sub>C\<^sub>L Proj S o\<^sub>C\<^sub>L (A*)\ have \P o\<^sub>C\<^sub>L P = P\ using assms unfolding P_def isometry_def by (metis (no_types, lifting) Proj_idempotent cblinfun_assoc_left(1) cblinfun_compose_id_left) moreover have \P = P*\ unfolding P_def by (metis adj_Proj adj_cblinfun_compose cblinfun_assoc_left(1) double_adj) ultimately have \\M. P = Proj M \ space_as_set M = range (cblinfun_apply (A o\<^sub>C\<^sub>L (Proj S) o\<^sub>C\<^sub>L (A*)))\ using P_def Proj_on_own_range' by (metis Proj_is_Proj Proj_range_closed cblinfun_image.rep_eq closure_closed top_ccsubspace.rep_eq) then obtain M where \P = Proj M\ and \space_as_set M = range (cblinfun_apply (A o\<^sub>C\<^sub>L (Proj S) o\<^sub>C\<^sub>L (A*)))\ by blast have f1: "A o\<^sub>C\<^sub>L Proj S = P o\<^sub>C\<^sub>L A" by (simp add: P_def assms cblinfun_compose_assoc) hence "P o\<^sub>C\<^sub>L A o\<^sub>C\<^sub>L A* = P" using P_def by presburger hence "(P o\<^sub>C\<^sub>L A) *\<^sub>S (c \ A* *\<^sub>S d) = P *\<^sub>S (A *\<^sub>S c \ d)" for c d by (simp add: cblinfun_assoc_left(2)) hence "P *\<^sub>S (A *\<^sub>S \ \ c) = (P o\<^sub>C\<^sub>L A) *\<^sub>S \" for c by (metis sup_top_left) hence \M = A *\<^sub>S S\ using f1 by (metis \P = Proj M\ cblinfun_assoc_left(2) Proj_range sup_top_right) thus ?thesis using \P = Proj M\ unfolding P_def sandwich_apply by blast qed lemma Proj_orthog_ccspan_union: assumes "\x y. x \ X \ y \ Y \ is_orthogonal x y" shows \Proj (ccspan (X \ Y)) = Proj (ccspan X) + Proj (ccspan Y)\ proof - have \x \ cspan X \ y \ cspan Y \ is_orthogonal x y\ for x y apply (rule is_orthogonal_closure_cspan[where X=X and Y=Y]) using closure_subset assms by auto then have \x \ closure (cspan X) \ y \ closure (cspan Y) \ is_orthogonal x y\ for x y by (metis orthogonal_complementI orthogonal_complement_of_closure orthogonal_complement_orthoI') then show ?thesis apply (transfer fixing: X Y) apply (subst projection_plus[symmetric]) by auto qed abbreviation proj :: "'a::chilbert_space \ 'a \\<^sub>C\<^sub>L 'a" where "proj \ \ Proj (ccspan {\})" lemma proj_0[simp]: \proj 0 = 0\ apply transfer by auto lemma surj_isometry_is_unitary: fixes U :: \'a::chilbert_space \\<^sub>C\<^sub>L 'b::chilbert_space\ assumes \isometry U\ assumes \U *\<^sub>S \ = \\ shows \unitary U\ by (metis Proj_sandwich sandwich_apply Proj_on_own_range' assms(1) assms(2) cblinfun_compose_id_right isometry_def unitary_def unitary_id unitary_range) lemma ccsubspace_supI_via_Proj: fixes A B C::"'a::chilbert_space ccsubspace" assumes a1: \Proj (- C) *\<^sub>S A \ B\ shows "A \ sup B C" proof- have x2: \x \ space_as_set B\ if "x \ closure ( (projection (orthogonal_complement (space_as_set C))) ` space_as_set A)" for x using that by (metis Proj.rep_eq cblinfun_image.rep_eq assms less_eq_ccsubspace.rep_eq subsetD uminus_ccsubspace.rep_eq) have q1: \x \ closure {\ + \ |\ \. \ \ space_as_set B \ \ \ space_as_set C}\ if \x \ space_as_set A\ for x proof- have p1: \closed_csubspace (space_as_set C)\ using space_as_set by auto hence \x = (projection (space_as_set C)) x + (projection (orthogonal_complement (space_as_set C))) x\ by simp hence \x = (projection (orthogonal_complement (space_as_set C))) x + (projection (space_as_set C)) x\ by (metis ordered_field_class.sign_simps(2)) moreover have \(projection (orthogonal_complement (space_as_set C))) x \ space_as_set B\ using x2 by (meson closure_subset image_subset_iff that) moreover have \(projection (space_as_set C)) x \ space_as_set C\ by (metis mem_Collect_eq orthog_proj_exists projection_eqI space_as_set) ultimately show ?thesis using closure_subset by fastforce qed have x1: \x \ (space_as_set B +\<^sub>M space_as_set C)\ if "x \ space_as_set A" for x proof - have f1: "x \ closure {a + b |a b. a \ space_as_set B \ b \ space_as_set C}" by (simp add: q1 that) have "{a + b |a b. a \ space_as_set B \ b \ space_as_set C} = {a. \p. p \ space_as_set B \ (\q. q \ space_as_set C \ a = p + q)}" by blast hence "x \ closure {a. \b\space_as_set B. \c\space_as_set C. a = b + c}" using f1 by (simp add: Bex_def_raw) thus ?thesis using that unfolding closed_sum_def set_plus_def by blast qed hence \x \ space_as_set (Abs_clinear_space (space_as_set B +\<^sub>M space_as_set C))\ if "x \ space_as_set A" for x using that by (metis space_as_set_inverse sup_ccsubspace.rep_eq) thus ?thesis by (simp add: x1 less_eq_ccsubspace.rep_eq subset_eq sup_ccsubspace.rep_eq) qed lemma is_Proj_idempotent: assumes "is_Proj P" shows "P o\<^sub>C\<^sub>L P = P" using assms unfolding is_Proj_def using assms is_Proj_algebraic by auto lemma is_proj_selfadj: assumes "is_Proj P" shows "P* = P" using assms unfolding is_Proj_def by (metis is_Proj_algebraic is_Proj_def) lemma is_Proj_I: assumes "P o\<^sub>C\<^sub>L P = P" and "P* = P" shows "is_Proj P" using assms is_Proj_algebraic by metis lemma is_Proj_0[simp]: "is_Proj 0" by (metis add_left_cancel adj_plus bounded_cbilinear.zero_left bounded_cbilinear_cblinfun_compose group_cancel.rule0 is_Proj_I) lemma is_Proj_complement[simp]: assumes a1: "is_Proj P" shows "is_Proj (id_cblinfun-P)" by (smt (z3) add_diff_cancel_left add_diff_cancel_left' adj_cblinfun_compose adj_plus assms bounded_cbilinear.add_left bounded_cbilinear_cblinfun_compose diff_add_cancel id_cblinfun_adjoint is_Proj_algebraic cblinfun_compose_id_left) lemma Proj_bot[simp]: "Proj bot = 0" by (metis zero_cblinfun_image Proj_on_own_range' is_Proj_0 is_Proj_algebraic zero_ccsubspace_def) lemma Proj_ortho_compl: "Proj (- X) = id_cblinfun - Proj X" by (transfer , auto) lemma Proj_inj: assumes "Proj X = Proj Y" shows "X = Y" by (metis assms Proj_range) subsection \Kernel\ lift_definition kernel :: "'a::complex_normed_vector \\<^sub>C\<^sub>L'b::complex_normed_vector \ 'a ccsubspace" is "\ f. f -` {0}" by (metis kernel_is_closed_csubspace) definition eigenspace :: "complex \ 'a::complex_normed_vector \\<^sub>C\<^sub>L'a \ 'a ccsubspace" where "eigenspace a A = kernel (A - a *\<^sub>C id_cblinfun)" lemma kernel_scaleC[simp]: "a\0 \ kernel (a *\<^sub>C A) = kernel A" for a :: complex and A :: "(_,_) cblinfun" apply transfer using complex_vector.scale_eq_0_iff by blast lemma kernel_0[simp]: "kernel 0 = top" apply transfer by auto lemma kernel_id[simp]: "kernel id_cblinfun = 0" apply transfer by simp lemma eigenspace_scaleC[simp]: assumes a1: "a \ 0" shows "eigenspace b (a *\<^sub>C A) = eigenspace (b/a) A" proof - have "b *\<^sub>C (id_cblinfun::('a, _) cblinfun) = a *\<^sub>C (b / a) *\<^sub>C id_cblinfun" using a1 by (metis ceq_vector_fraction_iff) hence "kernel (a *\<^sub>C A - b *\<^sub>C id_cblinfun) = kernel (A - (b / a) *\<^sub>C id_cblinfun)" using a1 by (metis (no_types) complex_vector.scale_right_diff_distrib kernel_scaleC) thus ?thesis unfolding eigenspace_def by blast qed lemma eigenspace_memberD: assumes "x \ space_as_set (eigenspace e A)" shows "A *\<^sub>V x = e *\<^sub>C x" using assms unfolding eigenspace_def apply transfer by auto lemma kernel_memberD: assumes "x \ space_as_set (kernel A)" shows "A *\<^sub>V x = 0" using assms apply transfer by auto lemma eigenspace_memberI: assumes "A *\<^sub>V x = e *\<^sub>C x" shows "x \ space_as_set (eigenspace e A)" using assms unfolding eigenspace_def apply transfer by auto lemma kernel_memberI: assumes "A *\<^sub>V x = 0" shows "x \ space_as_set (kernel A)" using assms apply transfer by auto subsection \Isomorphisms and inverses\ definition iso_cblinfun :: \('a::complex_normed_vector, 'b::complex_normed_vector) cblinfun \ bool\ where \iso_cblinfun A = (\ B. A o\<^sub>C\<^sub>L B = id_cblinfun \ B o\<^sub>C\<^sub>L A = id_cblinfun)\ definition cblinfun_inv :: \('a::complex_normed_vector, 'b::complex_normed_vector) cblinfun \ ('b,'a) cblinfun\ where \cblinfun_inv A = (SOME B. B o\<^sub>C\<^sub>L A = id_cblinfun)\ lemma assumes \iso_cblinfun A\ shows cblinfun_inv_left: \cblinfun_inv A o\<^sub>C\<^sub>L A = id_cblinfun\ and cblinfun_inv_right: \A o\<^sub>C\<^sub>L cblinfun_inv A = id_cblinfun\ proof - from assms obtain B where AB: \A o\<^sub>C\<^sub>L B = id_cblinfun\ and BA: \B o\<^sub>C\<^sub>L A = id_cblinfun\ using iso_cblinfun_def by blast from BA have \cblinfun_inv A o\<^sub>C\<^sub>L A = id_cblinfun\ by (metis (mono_tags, lifting) cblinfun_inv_def someI_ex) with AB BA have \cblinfun_inv A = B\ by (metis cblinfun_assoc_left(1) cblinfun_compose_id_right) with AB BA show \cblinfun_inv A o\<^sub>C\<^sub>L A = id_cblinfun\ and \A o\<^sub>C\<^sub>L cblinfun_inv A = id_cblinfun\ by auto qed lemma cblinfun_inv_uniq: assumes "A o\<^sub>C\<^sub>L B = id_cblinfun" and "B o\<^sub>C\<^sub>L A = id_cblinfun" shows "cblinfun_inv A = B" using assms by (metis cblinfun_compose_assoc cblinfun_compose_id_right cblinfun_inv_left iso_cblinfun_def) subsection \One-dimensional spaces\ instantiation cblinfun :: (one_dim, one_dim) complex_inner begin text \Once we have a theory for the trace, we could instead define the Hilbert-Schmidt inner product and relax the \<^class>\one_dim\-sort constraint to (\<^class>\cfinite_dim\,\<^class>\complex_normed_vector\) or similar\ definition "cinner_cblinfun (A::'a \\<^sub>C\<^sub>L 'b) (B::'a \\<^sub>C\<^sub>L 'b) = cnj (one_dim_iso (A *\<^sub>V 1)) * one_dim_iso (B *\<^sub>V 1)" instance proof intro_classes fix A B C :: "'a \\<^sub>C\<^sub>L 'b" and c c' :: complex show "\A, B\ = cnj \B, A\" unfolding cinner_cblinfun_def by auto show "\A + B, C\ = \A, C\ + \B, C\" by (simp add: cinner_cblinfun_def algebra_simps plus_cblinfun.rep_eq) show "\c *\<^sub>C A, B\ = cnj c * \A, B\" by (simp add: cblinfun.scaleC_left cinner_cblinfun_def) show "0 \ \A, A\" unfolding cinner_cblinfun_def by auto have "bounded_clinear A \ A 1 = 0 \ A = (\_. 0)" for A::"'a \ 'b" proof (rule one_dim_clinear_eqI [where x = 1] , auto) show "clinear A" if "bounded_clinear A" and "A 1 = 0" for A :: "'a \ 'b" using that by (simp add: bounded_clinear.clinear) show "clinear ((\_. 0)::'a \ 'b)" if "bounded_clinear A" and "A 1 = 0" for A :: "'a \ 'b" using that by (simp add: complex_vector.module_hom_zero) qed hence "A *\<^sub>V 1 = 0 \ A = 0" by transfer hence "one_dim_iso (A *\<^sub>V 1) = 0 \ A = 0" by (metis one_dim_iso_of_zero one_dim_iso_inj) thus "(\A, A\ = 0) = (A = 0)" by (auto simp: cinner_cblinfun_def) show "norm A = sqrt (cmod \A, A\)" unfolding cinner_cblinfun_def apply transfer by (simp add: norm_mult abs_complex_def one_dim_onorm' cnj_x_x power2_eq_square bounded_clinear.clinear) qed end instantiation cblinfun :: (one_dim, one_dim) one_dim begin lift_definition one_cblinfun :: "'a \\<^sub>C\<^sub>L 'b" is "one_dim_iso" by (rule bounded_clinear_one_dim_iso) lift_definition times_cblinfun :: "'a \\<^sub>C\<^sub>L 'b \ 'a \\<^sub>C\<^sub>L 'b \ 'a \\<^sub>C\<^sub>L 'b" is "\f g. f o one_dim_iso o g" by (simp add: comp_bounded_clinear) lift_definition inverse_cblinfun :: "'a \\<^sub>C\<^sub>L 'b \ 'a \\<^sub>C\<^sub>L 'b" is "\f. ((*) (one_dim_iso (inverse (f 1)))) o one_dim_iso" by (auto intro!: comp_bounded_clinear bounded_clinear_mult_right) definition divide_cblinfun :: "'a \\<^sub>C\<^sub>L 'b \ 'a \\<^sub>C\<^sub>L 'b \ 'a \\<^sub>C\<^sub>L 'b" where "divide_cblinfun A B = A * inverse B" definition "canonical_basis_cblinfun = [1 :: 'a \\<^sub>C\<^sub>L 'b]" instance proof intro_classes let ?basis = "canonical_basis :: ('a \\<^sub>C\<^sub>L 'b) list" fix A B C :: "'a \\<^sub>C\<^sub>L 'b" and c c' :: complex show "distinct ?basis" unfolding canonical_basis_cblinfun_def by simp have "(1::'a \\<^sub>C\<^sub>L 'b) \ (0::'a \\<^sub>C\<^sub>L 'b)" by (metis cblinfun.zero_left one_cblinfun.rep_eq one_dim_iso_of_one zero_neq_one) thus "cindependent (set ?basis)" unfolding canonical_basis_cblinfun_def by simp have "A \ cspan (set ?basis)" for A proof - define c :: complex where "c = one_dim_iso (A *\<^sub>V 1)" have "A x = one_dim_iso (A 1) *\<^sub>C one_dim_iso x" for x by (smt (z3) cblinfun.scaleC_right complex_vector.scale_left_commute one_dim_iso_idem one_dim_scaleC_1) hence "A = one_dim_iso (A *\<^sub>V 1) *\<^sub>C 1" apply transfer by metis thus "A \ cspan (set ?basis)" unfolding canonical_basis_cblinfun_def by (smt complex_vector.span_base complex_vector.span_scale list.set_intros(1)) qed thus "cspan (set ?basis) = UNIV" by auto have "A = (1::'a \\<^sub>C\<^sub>L 'b) \ norm (1::'a \\<^sub>C\<^sub>L 'b) = (1::real)" apply transfer by simp thus "A \ set ?basis \ norm A = 1" unfolding canonical_basis_cblinfun_def by simp show "?basis = [1]" unfolding canonical_basis_cblinfun_def by simp show "c *\<^sub>C 1 * c' *\<^sub>C 1 = (c * c') *\<^sub>C (1::'a\\<^sub>C\<^sub>L'b)" apply transfer by auto have "(1::'a \\<^sub>C\<^sub>L 'b) = (0::'a \\<^sub>C\<^sub>L 'b) \ False" by (metis cblinfun.zero_left one_cblinfun.rep_eq one_dim_iso_of_zero' zero_neq_neg_one) thus "is_ortho_set (set ?basis)" unfolding is_ortho_set_def canonical_basis_cblinfun_def by auto show "A div B = A * inverse B" by (simp add: divide_cblinfun_def) show "inverse (c *\<^sub>C 1) = (1::'a\\<^sub>C\<^sub>L'b) /\<^sub>C c" apply transfer by (simp add: o_def one_dim_inverse) qed end lemma id_cblinfun_eq_1[simp]: \id_cblinfun = 1\ apply transfer by auto lemma one_dim_apply_is_times[simp]: fixes A :: "'a::one_dim \\<^sub>C\<^sub>L 'a" and B :: "'a \\<^sub>C\<^sub>L 'a" shows "A o\<^sub>C\<^sub>L B = A * B" apply transfer by simp lemma one_comp_one_cblinfun[simp]: "1 o\<^sub>C\<^sub>L 1 = 1" apply transfer unfolding o_def by simp lemma one_cblinfun_adj[simp]: "1* = 1" apply transfer by simp lemma scaleC_1_right[simp]: \scaleC x (1::'a::one_dim) = of_complex x\ unfolding of_complex_def by simp lemma scaleC_of_complex[simp]: \scaleC x (of_complex y) = of_complex (x * y)\ unfolding of_complex_def using scaleC_scaleC by blast lemma scaleC_1_apply[simp]: \(x *\<^sub>C 1) *\<^sub>V y = x *\<^sub>C y\ by (metis cblinfun.scaleC_left cblinfun_id_cblinfun_apply id_cblinfun_eq_1) lemma cblinfun_apply_1_left[simp]: \1 *\<^sub>V y = y\ by (metis cblinfun_id_cblinfun_apply id_cblinfun_eq_1) lemma of_complex_cblinfun_apply[simp]: \of_complex x *\<^sub>V y = x *\<^sub>C y\ unfolding of_complex_def by (metis cblinfun.scaleC_left cblinfun_id_cblinfun_apply id_cblinfun_eq_1) lemma cblinfun_compose_1_left[simp]: \1 o\<^sub>C\<^sub>L x = x\ apply transfer by auto lemma cblinfun_compose_1_right[simp]: \x o\<^sub>C\<^sub>L 1 = x\ apply transfer by auto lemma one_dim_iso_id_cblinfun: \one_dim_iso id_cblinfun = id_cblinfun\ by simp lemma one_dim_iso_id_cblinfun_eq_1: \one_dim_iso id_cblinfun = 1\ by simp lemma one_dim_iso_comp_distr[simp]: \one_dim_iso (a o\<^sub>C\<^sub>L b) = one_dim_iso a o\<^sub>C\<^sub>L one_dim_iso b\ by (smt (z3) cblinfun_compose_scaleC_left cblinfun_compose_scaleC_right one_cinner_a_scaleC_one one_comp_one_cblinfun one_dim_iso_of_one one_dim_iso_scaleC) lemma one_dim_iso_comp_distr_times[simp]: \one_dim_iso (a o\<^sub>C\<^sub>L b) = one_dim_iso a * one_dim_iso b\ by (smt (verit, del_insts) mult.left_neutral mult_scaleC_left one_cinner_a_scaleC_one one_comp_one_cblinfun one_dim_iso_of_one one_dim_iso_scaleC cblinfun_compose_scaleC_right cblinfun_compose_scaleC_left) lemma one_dim_iso_adjoint[simp]: \one_dim_iso (A*) = (one_dim_iso A)*\ by (smt (z3) one_cblinfun_adj one_cinner_a_scaleC_one one_dim_iso_of_one one_dim_iso_scaleC scaleC_adj) lemma one_dim_iso_adjoint_complex[simp]: \one_dim_iso (A*) = cnj (one_dim_iso A)\ by (metis (mono_tags, lifting) one_cblinfun_adj one_dim_iso_idem one_dim_scaleC_1 scaleC_adj) lemma one_dim_cblinfun_compose_commute: \a o\<^sub>C\<^sub>L b = b o\<^sub>C\<^sub>L a\ for a b :: \('a::one_dim,'a) cblinfun\ by (simp add: one_dim_iso_inj) lemma one_cblinfun_apply_one[simp]: \1 *\<^sub>V 1 = 1\ by (simp add: one_cblinfun.rep_eq) subsection \Loewner order\ lift_definition heterogenous_cblinfun_id :: \'a::complex_normed_vector \\<^sub>C\<^sub>L 'b::complex_normed_vector\ is \if bounded_clinear (heterogenous_identity :: 'a::complex_normed_vector \ 'b::complex_normed_vector) then heterogenous_identity else (\_. 0)\ by auto lemma heterogenous_cblinfun_id_def'[simp]: "heterogenous_cblinfun_id = id_cblinfun" apply transfer by auto definition "heterogenous_same_type_cblinfun (x::'a::chilbert_space itself) (y::'b::chilbert_space itself) \ unitary (heterogenous_cblinfun_id :: 'a \\<^sub>C\<^sub>L 'b) \ unitary (heterogenous_cblinfun_id :: 'b \\<^sub>C\<^sub>L 'a)" lemma heterogenous_same_type_cblinfun[simp]: \heterogenous_same_type_cblinfun (x::'a::chilbert_space itself) (y::'a::chilbert_space itself)\ unfolding heterogenous_same_type_cblinfun_def by auto instantiation cblinfun :: (chilbert_space, chilbert_space) ord begin definition less_eq_cblinfun :: \('a \\<^sub>C\<^sub>L 'b) \ ('a \\<^sub>C\<^sub>L 'b) \ bool\ where less_eq_cblinfun_def_heterogenous: \less_eq_cblinfun A B = (if heterogenous_same_type_cblinfun TYPE('a) TYPE('b) then \\::'b. cinner \ ((B-A) *\<^sub>V heterogenous_cblinfun_id *\<^sub>V \) \ 0 else (A=B))\ definition \less_cblinfun (A :: 'a \\<^sub>C\<^sub>L 'b) B \ A \ B \ \ B \ A\ instance.. end lemma less_eq_cblinfun_def: \A \ B \ (\\. cinner \ (A *\<^sub>V \) \ cinner \ (B *\<^sub>V \))\ unfolding less_eq_cblinfun_def_heterogenous by (auto simp del: less_eq_complex_def simp: cblinfun.diff_left cinner_diff_right) instantiation cblinfun :: (chilbert_space, chilbert_space) ordered_complex_vector begin instance proof intro_classes note less_eq_complex_def[simp del] fix x y z :: \'a \\<^sub>C\<^sub>L 'b\ fix a b :: complex define pos where \pos X \ (\\. cinner \ (X *\<^sub>V \) \ 0)\ for X :: \'b \\<^sub>C\<^sub>L 'b\ consider (unitary) \heterogenous_same_type_cblinfun TYPE('a) TYPE('b)\ \\A B :: 'a \\<^sub>C\<^sub>L 'b. A \ B = pos ((B-A) o\<^sub>C\<^sub>L (heterogenous_cblinfun_id :: 'b\\<^sub>C\<^sub>L'a))\ | (trivial) \\A B :: 'a \\<^sub>C\<^sub>L 'b. A \ B \ A = B\ apply atomize_elim by (auto simp: pos_def less_eq_cblinfun_def_heterogenous) note cases = this have [simp]: \pos 0\ unfolding pos_def by auto have pos_nondeg: \X = 0\ if \pos X\ and \pos (-X)\ for X apply (rule cblinfun_cinner_eqI, simp) using that by (metis (no_types, lifting) cblinfun.minus_left cinner_minus_right dual_order.antisym equation_minus_iff neg_le_0_iff_le pos_def) have pos_add: \pos (X+Y)\ if \pos X\ and \pos Y\ for X Y by (smt (z3) pos_def cblinfun.diff_left cinner_minus_right cinner_simps(3) diff_ge_0_iff_ge diff_minus_eq_add neg_le_0_iff_le order_trans that(1) that(2) uminus_cblinfun.rep_eq) have pos_scaleC: \pos (a *\<^sub>C X)\ if \a\0\ and \pos X\ for X a using that unfolding pos_def by (auto simp: cblinfun.scaleC_left) let ?id = \heterogenous_cblinfun_id :: 'b \\<^sub>C\<^sub>L 'a\ show \x \ x\ apply (cases rule:cases) by auto show \(x < y) \ (x \ y \ \ y \ x)\ unfolding less_cblinfun_def by simp show \x \ z\ if \x \ y\ and \y \ z\ proof (cases rule:cases) case unitary define a b :: \'b \\<^sub>C\<^sub>L 'b\ where \a = (y-x) o\<^sub>C\<^sub>L heterogenous_cblinfun_id\ and \b = (z-y) o\<^sub>C\<^sub>L heterogenous_cblinfun_id\ with unitary that have \pos a\ and \pos b\ by auto then have \pos (a + b)\ by (rule pos_add) moreover have \a + b = (z - x) o\<^sub>C\<^sub>L heterogenous_cblinfun_id\ unfolding a_def b_def by (metis (no_types, lifting) bounded_cbilinear.add_left bounded_cbilinear_cblinfun_compose diff_add_cancel ordered_field_class.sign_simps(2) ordered_field_class.sign_simps(8)) ultimately show ?thesis using unitary by auto next case trivial with that show ?thesis by auto qed show \x = y\ if \x \ y\ and \y \ x\ proof (cases rule:cases) case unitary then have \unitary ?id\ by (auto simp: heterogenous_same_type_cblinfun_def) define a b :: \'b \\<^sub>C\<^sub>L 'b\ where \a = (y-x) o\<^sub>C\<^sub>L ?id\ and \b = (x-y) o\<^sub>C\<^sub>L ?id\ with unitary that have \pos a\ and \pos b\ by auto then have \a = 0\ apply (rule_tac pos_nondeg) apply (auto simp: a_def b_def) by (smt (verit, best) add.commute bounded_cbilinear.add_left bounded_cbilinear_cblinfun_compose cblinfun_compose_zero_left diff_0 diff_add_cancel group_cancel.rule0 group_cancel.sub1) then show ?thesis unfolding a_def using \unitary ?id\ by (metis cblinfun_compose_assoc cblinfun_compose_id_right cblinfun_compose_zero_left eq_iff_diff_eq_0 unitaryD2) next case trivial with that show ?thesis by simp qed show \x + y \ x + z\ if \y \ z\ proof (cases rule:cases) case unitary with that show ?thesis by auto next case trivial with that show ?thesis by auto qed show \a *\<^sub>C x \ a *\<^sub>C y\ if \x \ y\ and \0 \ a\ proof (cases rule:cases) case unitary with that pos_scaleC show ?thesis by (metis cblinfun_compose_scaleC_left complex_vector.scale_right_diff_distrib) next case trivial with that show ?thesis by auto qed show \a *\<^sub>C x \ b *\<^sub>C x\ if \a \ b\ and \0 \ x\ proof (cases rule:cases) case unitary with that show ?thesis by (auto intro!: pos_scaleC simp flip: scaleC_diff_left) next case trivial with that show ?thesis by auto qed qed end lemma positive_id_cblinfun[simp]: "id_cblinfun \ 0" unfolding less_eq_cblinfun_def using cinner_ge_zero by auto lemma positive_hermitianI: \A = A*\ if \A \ 0\ apply (rule cinner_real_hermiteanI) using that by (auto simp: complex_is_real_iff_compare0 less_eq_cblinfun_def) lemma positive_cblinfunI: \A \ 0\ if \\x. cinner x (A *\<^sub>V x) \ 0\ unfolding less_eq_cblinfun_def using that by auto (* Note: this does not require B to be a square operator *) lemma positive_cblinfun_squareI: \A = B* o\<^sub>C\<^sub>L B \ A \ 0\ apply (rule positive_cblinfunI) by (metis cblinfun_apply_cblinfun_compose cinner_adj_right cinner_ge_zero) lemma one_dim_loewner_order: \A \ B \ one_dim_iso A \ (one_dim_iso B :: complex)\ for A B :: \'a \\<^sub>C\<^sub>L 'a::{chilbert_space, one_dim}\ proof - note less_eq_complex_def[simp del] have A: \A = one_dim_iso A *\<^sub>C id_cblinfun\ by simp have B: \B = one_dim_iso B *\<^sub>C id_cblinfun\ by simp have \A \ B \ (\\. cinner \ (A \) \ cinner \ (B \))\ by (simp add: less_eq_cblinfun_def) also have \\ \ (\\::'a. one_dim_iso B * (\ \\<^sub>C \) \ one_dim_iso A * (\ \\<^sub>C \))\ apply (subst A, subst B) by (metis (no_types, opaque_lifting) cinner_scaleC_right id_cblinfun_apply scaleC_cblinfun.rep_eq) also have \\ \ one_dim_iso A \ (one_dim_iso B :: complex)\ by (auto intro!: mult_right_mono elim!: allE[where x=1]) finally show ?thesis by - qed lemma one_dim_positive: \A \ 0 \ one_dim_iso A \ (0::complex)\ for A :: \'a \\<^sub>C\<^sub>L 'a::{chilbert_space, one_dim}\ using one_dim_loewner_order[where B=0] by auto subsection \Embedding vectors to operators\ lift_definition vector_to_cblinfun :: \'a::complex_normed_vector \ 'b::one_dim \\<^sub>C\<^sub>L 'a\ is \\\ \. one_dim_iso \ *\<^sub>C \\ by (simp add: bounded_clinear_scaleC_const) lemma vector_to_cblinfun_cblinfun_apply: "vector_to_cblinfun (A *\<^sub>V \) = A o\<^sub>C\<^sub>L (vector_to_cblinfun \)" apply transfer unfolding comp_def bounded_clinear_def clinear_def Vector_Spaces.linear_def module_hom_def module_hom_axioms_def by simp lemma vector_to_cblinfun_add: \vector_to_cblinfun (x + y) = vector_to_cblinfun x + vector_to_cblinfun y\ apply transfer by (simp add: scaleC_add_right) lemma norm_vector_to_cblinfun[simp]: "norm (vector_to_cblinfun x) = norm x" proof transfer have "bounded_clinear (one_dim_iso::'a \ complex)" by simp moreover have "onorm (one_dim_iso::'a \ complex) * norm x = norm x" for x :: 'b by simp ultimately show "onorm (\\. one_dim_iso (\::'a) *\<^sub>C x) = norm x" for x :: 'b by (subst onorm_scaleC_left) qed lemma bounded_clinear_vector_to_cblinfun[bounded_clinear]: "bounded_clinear vector_to_cblinfun" apply (rule bounded_clinearI[where K=1]) apply (transfer, simp add: scaleC_add_right) apply (transfer, simp add: mult.commute) by simp lemma vector_to_cblinfun_scaleC[simp]: "vector_to_cblinfun (a *\<^sub>C \) = a *\<^sub>C vector_to_cblinfun \" for a::complex proof (subst asm_rl [of "a *\<^sub>C \ = (a *\<^sub>C id_cblinfun) *\<^sub>V \"]) show "a *\<^sub>C \ = a *\<^sub>C id_cblinfun *\<^sub>V \" by (simp add: scaleC_cblinfun.rep_eq) show "vector_to_cblinfun (a *\<^sub>C id_cblinfun *\<^sub>V \) = a *\<^sub>C (vector_to_cblinfun \::'a \\<^sub>C\<^sub>L 'b)" by (metis cblinfun_id_cblinfun_apply cblinfun_compose_scaleC_left vector_to_cblinfun_cblinfun_apply) qed lemma vector_to_cblinfun_apply_one_dim[simp]: shows "vector_to_cblinfun \ *\<^sub>V \ = one_dim_iso \ *\<^sub>C \" apply transfer by (rule refl) lemma vector_to_cblinfun_adj_apply[simp]: shows "vector_to_cblinfun \* *\<^sub>V \ = of_complex (cinner \ \)" by (simp add: cinner_adj_right one_dim_iso_def one_dim_iso_inj) lemma vector_to_cblinfun_comp_one[simp]: "(vector_to_cblinfun s :: 'a::one_dim \\<^sub>C\<^sub>L _) o\<^sub>C\<^sub>L 1 = (vector_to_cblinfun s :: 'b::one_dim \\<^sub>C\<^sub>L _)" apply (transfer fixing: s) by fastforce lemma vector_to_cblinfun_0[simp]: "vector_to_cblinfun 0 = 0" by (metis cblinfun.zero_left cblinfun_compose_zero_left vector_to_cblinfun_cblinfun_apply) lemma image_vector_to_cblinfun[simp]: "vector_to_cblinfun x *\<^sub>S top = ccspan {x}" proof transfer show "closure (range (\\::'b. one_dim_iso \ *\<^sub>C x)) = closure (cspan {x})" for x :: 'a proof (rule arg_cong [where f = closure]) have "k *\<^sub>C x \ range (\\. one_dim_iso \ *\<^sub>C x)" for k by (smt (z3) id_apply one_dim_iso_id one_dim_iso_idem range_eqI) thus "range (\\. one_dim_iso (\::'b) *\<^sub>C x) = cspan {x}" unfolding complex_vector.span_singleton by auto qed qed lemma vector_to_cblinfun_adj_comp_vector_to_cblinfun[simp]: shows "vector_to_cblinfun \* o\<^sub>C\<^sub>L vector_to_cblinfun \ = cinner \ \ *\<^sub>C id_cblinfun" proof - have "one_dim_iso \ *\<^sub>C one_dim_iso (of_complex \\, \\) = \\, \\ *\<^sub>C one_dim_iso \" for \ :: "'c::one_dim" by (metis complex_vector.scale_left_commute of_complex_def one_dim_iso_of_one one_dim_iso_scaleC one_dim_scaleC_1) hence "one_dim_iso ((vector_to_cblinfun \* o\<^sub>C\<^sub>L vector_to_cblinfun \) *\<^sub>V \) = one_dim_iso ((cinner \ \ *\<^sub>C id_cblinfun) *\<^sub>V \)" for \ :: "'c::one_dim" by simp hence "((vector_to_cblinfun \* o\<^sub>C\<^sub>L vector_to_cblinfun \) *\<^sub>V \) = ((cinner \ \ *\<^sub>C id_cblinfun) *\<^sub>V \)" for \ :: "'c::one_dim" by (rule one_dim_iso_inj) thus ?thesis using cblinfun_eqI[where x = "vector_to_cblinfun \* o\<^sub>C\<^sub>L vector_to_cblinfun \" and y = "\\, \\ *\<^sub>C id_cblinfun"] by auto qed lemma isometry_vector_to_cblinfun[simp]: assumes "norm x = 1" shows "isometry (vector_to_cblinfun x)" using assms cnorm_eq_1 isometry_def by force subsection \Butterflies (rank-1 projectors)\ definition butterfly_def: "butterfly (s::'a::complex_normed_vector) (t::'b::chilbert_space) = vector_to_cblinfun s o\<^sub>C\<^sub>L (vector_to_cblinfun t :: complex \\<^sub>C\<^sub>L _)*" abbreviation "selfbutter s \ butterfly s s" lemma butterfly_add_left: \butterfly (a + a') b = butterfly a b + butterfly a' b\ by (simp add: butterfly_def vector_to_cblinfun_add cbilinear_add_left bounded_cbilinear.add_left bounded_cbilinear_cblinfun_compose) lemma butterfly_add_right: \butterfly a (b + b') = butterfly a b + butterfly a b'\ by (simp add: butterfly_def adj_plus vector_to_cblinfun_add cblinfun_compose_add_right) lemma butterfly_def_one_dim: "butterfly s t = (vector_to_cblinfun s :: 'c::one_dim \\<^sub>C\<^sub>L _) o\<^sub>C\<^sub>L (vector_to_cblinfun t :: 'c \\<^sub>C\<^sub>L _)*" (is "_ = ?rhs") for s :: "'a::complex_normed_vector" and t :: "'b::chilbert_space" proof - let ?isoAC = "1 :: 'c \\<^sub>C\<^sub>L complex" let ?isoCA = "1 :: complex \\<^sub>C\<^sub>L 'c" let ?vector = "vector_to_cblinfun :: _ \ ('c \\<^sub>C\<^sub>L _)" have "butterfly s t = (?vector s o\<^sub>C\<^sub>L ?isoCA) o\<^sub>C\<^sub>L (?vector t o\<^sub>C\<^sub>L ?isoCA)*" unfolding butterfly_def vector_to_cblinfun_comp_one by simp also have "\ = ?vector s o\<^sub>C\<^sub>L (?isoCA o\<^sub>C\<^sub>L ?isoCA*) o\<^sub>C\<^sub>L (?vector t)*" by (metis (no_types, lifting) cblinfun_compose_assoc adj_cblinfun_compose) also have "\ = ?rhs" by simp finally show ?thesis by simp qed lemma butterfly_comp_cblinfun: "butterfly \ \ o\<^sub>C\<^sub>L a = butterfly \ (a* *\<^sub>V \)" unfolding butterfly_def by (simp add: cblinfun_compose_assoc vector_to_cblinfun_cblinfun_apply) lemma cblinfun_comp_butterfly: "a o\<^sub>C\<^sub>L butterfly \ \ = butterfly (a *\<^sub>V \) \" unfolding butterfly_def by (simp add: cblinfun_compose_assoc vector_to_cblinfun_cblinfun_apply) lemma butterfly_apply[simp]: "butterfly \ \' *\<^sub>V \ = \\', \\ *\<^sub>C \" by (simp add: butterfly_def scaleC_cblinfun.rep_eq) lemma butterfly_scaleC_left[simp]: "butterfly (c *\<^sub>C \) \ = c *\<^sub>C butterfly \ \" unfolding butterfly_def vector_to_cblinfun_scaleC scaleC_adj by (simp add: cnj_x_x) lemma butterfly_scaleC_right[simp]: "butterfly \ (c *\<^sub>C \) = cnj c *\<^sub>C butterfly \ \" unfolding butterfly_def vector_to_cblinfun_scaleC scaleC_adj by (simp add: cnj_x_x) lemma butterfly_scaleR_left[simp]: "butterfly (r *\<^sub>R \) \ = r *\<^sub>C butterfly \ \" by (simp add: scaleR_scaleC) lemma butterfly_scaleR_right[simp]: "butterfly \ (r *\<^sub>R \) = r *\<^sub>C butterfly \ \" by (simp add: butterfly_scaleC_right scaleR_scaleC) lemma butterfly_adjoint[simp]: "(butterfly \ \)* = butterfly \ \" unfolding butterfly_def by auto lemma butterfly_comp_butterfly[simp]: "butterfly \1 \2 o\<^sub>C\<^sub>L butterfly \3 \4 = \\2, \3\ *\<^sub>C butterfly \1 \4" by (simp add: butterfly_comp_cblinfun) lemma butterfly_0_left[simp]: "butterfly 0 a = 0" by (simp add: butterfly_def) lemma butterfly_0_right[simp]: "butterfly a 0 = 0" by (simp add: butterfly_def) lemma norm_butterfly: "norm (butterfly \ \) = norm \ * norm \" proof (cases "\=0") case True then show ?thesis by simp next case False show ?thesis unfolding norm_cblinfun.rep_eq thm onormI[OF _ False] proof (rule onormI[OF _ False]) fix x have "cmod \\, x\ * norm \ \ norm \ * norm \ * norm x" by (metis ab_semigroup_mult_class.mult_ac(1) complex_inner_class.Cauchy_Schwarz_ineq2 mult.commute mult_left_mono norm_ge_zero) thus "norm (butterfly \ \ *\<^sub>V x) \ norm \ * norm \ * norm x" by (simp add: power2_eq_square) show "norm (butterfly \ \ *\<^sub>V \) = norm \ * norm \ * norm \" by (smt (z3) ab_semigroup_mult_class.mult_ac(1) butterfly_apply mult.commute norm_eq_sqrt_cinner norm_ge_zero norm_scaleC power2_eq_square real_sqrt_abs real_sqrt_eq_iff) qed qed lemma bounded_sesquilinear_butterfly[bounded_sesquilinear]: \bounded_sesquilinear (\(b::'b::chilbert_space) (a::'a::chilbert_space). butterfly a b)\ proof standard fix a a' :: 'a and b b' :: 'b and r :: complex show \butterfly (a + a') b = butterfly a b + butterfly a' b\ by (rule butterfly_add_left) show \butterfly a (b + b') = butterfly a b + butterfly a b'\ by (rule butterfly_add_right) show \butterfly (r *\<^sub>C a) b = r *\<^sub>C butterfly a b\ by simp show \butterfly a (r *\<^sub>C b) = cnj r *\<^sub>C butterfly a b\ by simp show \\K. \b a. norm (butterfly a b) \ norm b * norm a * K \ apply (rule exI[of _ 1]) by (simp add: norm_butterfly) qed lemma inj_selfbutter_upto_phase: assumes "selfbutter x = selfbutter y" shows "\c. cmod c = 1 \ x = c *\<^sub>C y" proof (cases "x = 0") case True from assms have "y = 0" using norm_butterfly by (metis True butterfly_0_left divisors_zero norm_eq_zero) with True show ?thesis using norm_one by fastforce next case False define c where "c = \y, x\ / \x, x\" have "\x, x\ *\<^sub>C x = selfbutter x *\<^sub>V x" by (simp add: butterfly_apply) also have "\ = selfbutter y *\<^sub>V x" using assms by simp also have "\ = \y, x\ *\<^sub>C y" by (simp add: butterfly_apply) finally have xcy: "x = c *\<^sub>C y" by (simp add: c_def ceq_vector_fraction_iff) have "cmod c * norm x = cmod c * norm y" using assms norm_butterfly by (smt (verit, ccfv_SIG) \\x, x\ *\<^sub>C x = selfbutter x *\<^sub>V x\ \selfbutter y *\<^sub>V x = \y, x\ *\<^sub>C y\ cinner_scaleC_right complex_vector.scale_left_commute complex_vector.scale_right_imp_eq mult_cancel_left norm_eq_sqrt_cinner norm_eq_zero scaleC_scaleC xcy) also have "cmod c * norm y = norm (c *\<^sub>C y)" by simp also have "\ = norm x" unfolding xcy[symmetric] by simp finally have c: "cmod c = 1" by (simp add: False) from c xcy show ?thesis by auto qed lemma butterfly_eq_proj: assumes "norm x = 1" shows "selfbutter x = proj x" proof - define B and \ :: "complex \\<^sub>C\<^sub>L 'a" where "B = selfbutter x" and "\ = vector_to_cblinfun x" then have B: "B = \ o\<^sub>C\<^sub>L \*" unfolding butterfly_def by simp have \adj\: "\* o\<^sub>C\<^sub>L \ = id_cblinfun" using \_def assms isometry_def isometry_vector_to_cblinfun by blast have "B o\<^sub>C\<^sub>L B = \ o\<^sub>C\<^sub>L (\* o\<^sub>C\<^sub>L \) o\<^sub>C\<^sub>L \*" by (simp add: B cblinfun_assoc_left(1)) also have "\ = B" unfolding \adj\ by (simp add: B) finally have idem: "B o\<^sub>C\<^sub>L B = B". have herm: "B = B*" unfolding B by simp from idem herm have BProj: "B = Proj (B *\<^sub>S top)" by (rule Proj_on_own_range'[symmetric]) have "B *\<^sub>S top = ccspan {x}" by (simp add: B \_def assms cblinfun_compose_image range_adjoint_isometry) with BProj show "B = proj x" by simp qed lemma butterfly_is_Proj: \norm x = 1 \ is_Proj (selfbutter x)\ by (subst butterfly_eq_proj, simp_all) lemma cspan_butterfly_UNIV: assumes \cspan basisA = UNIV\ assumes \cspan basisB = UNIV\ assumes \is_ortho_set basisB\ assumes \\b. b \ basisB \ norm b = 1\ shows \cspan {butterfly a b| (a::'a::{complex_normed_vector}) (b::'b::{chilbert_space,cfinite_dim}). a \ basisA \ b \ basisB} = UNIV\ proof - have F: \\F\{butterfly a b |a b. a \ basisA \ b \ basisB}. \b'\basisB. F *\<^sub>V b' = (if b' = b then a else 0)\ if \a \ basisA\ and \b \ basisB\ for a b apply (rule bexI[where x=\butterfly a b\]) using assms that by (auto simp: is_ortho_set_def cnorm_eq_1) show ?thesis apply (rule cblinfun_cspan_UNIV[where basisA=basisB and basisB=basisA]) using assms apply auto[2] using F by (smt (verit, ccfv_SIG) image_iff) qed lemma cindependent_butterfly: fixes basisA :: \'a::chilbert_space set\ and basisB :: \'b::chilbert_space set\ assumes \is_ortho_set basisA\ \is_ortho_set basisB\ assumes normA: \\a. a\basisA \ norm a = 1\ and normB: \\b. b\basisB \ norm b = 1\ shows \cindependent {butterfly a b| a b. a\basisA \ b\basisB}\ proof (unfold complex_vector.independent_explicit_module, intro allI impI, rename_tac T f g) fix T :: \('b \\<^sub>C\<^sub>L 'a) set\ and f :: \'b \\<^sub>C\<^sub>L 'a \ complex\ and g :: \'b \\<^sub>C\<^sub>L 'a\ assume \finite T\ assume T_subset: \T \ {butterfly a b |a b. a \ basisA \ b \ basisB}\ define lin where \lin = (\g\T. f g *\<^sub>C g)\ assume \lin = 0\ assume \g \ T\ (* To show: f g = 0 *) then obtain a b where g: \g = butterfly a b\ and [simp]: \a \ basisA\ \b \ basisB\ using T_subset by auto have *: "(vector_to_cblinfun a)* *\<^sub>V f g *\<^sub>C g *\<^sub>V b = 0" if \g \ T - {butterfly a b}\ for g proof - from that obtain a' b' where g: \g = butterfly a' b'\ and [simp]: \a' \ basisA\ \b' \ basisB\ using T_subset by auto from that have \g \ butterfly a b\ by auto with g consider (a) \a\a'\ | (b) \b\b'\ by auto then show \(vector_to_cblinfun a)* *\<^sub>V f g *\<^sub>C g *\<^sub>V b = 0\ proof cases case a then show ?thesis using \is_ortho_set basisA\ unfolding g by (auto simp: is_ortho_set_def butterfly_def scaleC_cblinfun.rep_eq) next case b then show ?thesis using \is_ortho_set basisB\ unfolding g by (auto simp: is_ortho_set_def butterfly_def scaleC_cblinfun.rep_eq) qed qed have \0 = (vector_to_cblinfun a)* *\<^sub>V lin *\<^sub>V b\ using \lin = 0\ by auto also have \\ = (\g\T. (vector_to_cblinfun a)* *\<^sub>V (f g *\<^sub>C g) *\<^sub>V b)\ unfolding lin_def apply (rule complex_vector.linear_sum) by (smt (z3) cblinfun.scaleC_left cblinfun.scaleC_right cblinfun.add_right clinearI plus_cblinfun.rep_eq) also have \\ = (\g\{butterfly a b}. (vector_to_cblinfun a)* *\<^sub>V (f g *\<^sub>C g) *\<^sub>V b)\ apply (rule sum.mono_neutral_right) using \finite T\ * \g \ T\ g by auto also have \\ = (vector_to_cblinfun a)* *\<^sub>V (f g *\<^sub>C g) *\<^sub>V b\ by (simp add: g) also have \\ = f g\ unfolding g using normA normB by (auto simp: butterfly_def scaleC_cblinfun.rep_eq cnorm_eq_1) finally show \f g = 0\ by simp qed lemma clinear_eq_butterflyI: fixes F G :: \('a::{chilbert_space,cfinite_dim} \\<^sub>C\<^sub>L 'b::complex_inner) \ 'c::complex_vector\ assumes "clinear F" and "clinear G" assumes \cspan basisA = UNIV\ \cspan basisB = UNIV\ assumes \is_ortho_set basisA\ \is_ortho_set basisB\ assumes "\a b. a\basisA \ b\basisB \ F (butterfly a b) = G (butterfly a b)" assumes \\b. b\basisB \ norm b = 1\ shows "F = G" apply (rule complex_vector.linear_eq_on_span[where f=F, THEN ext, rotated 3]) apply (subst cspan_butterfly_UNIV) using assms by auto subsection \Bifunctionals\ lift_definition bifunctional :: \'a::complex_normed_vector \\<^sub>C\<^sub>L (('a \\<^sub>C\<^sub>L complex) \\<^sub>C\<^sub>L complex)\ is \\x f. f *\<^sub>V x\ by (simp add: cblinfun.flip) lemma bifunctional_apply[simp]: \(bifunctional *\<^sub>V x) *\<^sub>V f = f *\<^sub>V x\ by (transfer fixing: x f, simp) lemma bifunctional_isometric[simp]: \norm (bifunctional *\<^sub>V x) = norm x\ for x :: \'a::complex_inner\ proof - define f :: \'a \\<^sub>C\<^sub>L complex\ where \f = CBlinfun (\y. cinner x y)\ then have [simp]: \f *\<^sub>V y = cinner x y\ for y by (simp add: bounded_clinear_CBlinfun_apply bounded_clinear_cinner_right) then have [simp]: \norm f = norm x\ apply (auto intro!: norm_cblinfun_eqI[where x=x] simp: power2_norm_eq_cinner[symmetric]) apply (smt (verit, best) norm_eq_sqrt_cinner norm_ge_zero power2_norm_eq_cinner real_div_sqrt) using Cauchy_Schwarz_ineq2 by blast show ?thesis apply (auto intro!: norm_cblinfun_eqI[where x=f]) apply (metis norm_eq_sqrt_cinner norm_imp_pos_and_ge real_div_sqrt) by (metis norm_cblinfun ordered_field_class.sign_simps(33)) qed lemma norm_bifunctional[simp]: \norm (bifunctional :: 'a::{complex_inner, not_singleton} \\<^sub>C\<^sub>L _) = 1\ proof - obtain x :: 'a where [simp]: \norm x = 1\ by (meson UNIV_not_singleton ex_norm1) show ?thesis by (auto intro!: norm_cblinfun_eqI[where x=x]) qed subsection \Banach-Steinhaus\ theorem cbanach_steinhaus: fixes F :: \'c \ 'a::cbanach \\<^sub>C\<^sub>L 'b::complex_normed_vector\ assumes \\x. \M. \n. norm ((F n) *\<^sub>V x) \ M\ shows \\M. \ n. norm (F n) \ M\ using cblinfun_blinfun_transfer[transfer_rule] apply (rule TrueI)? (* Deletes current facts *) proof (use assms in transfer) fix F :: \'c \ 'a \\<^sub>L 'b\ assume \(\x. \M. \n. norm (F n *\<^sub>v x) \ M)\ hence \\x. bounded (range (\n. blinfun_apply (F n) x))\ by (metis (no_types, lifting) boundedI rangeE) hence \bounded (range F)\ by (simp add: banach_steinhaus) thus \\M. \n. norm (F n) \ M\ by (simp add: bounded_iff) qed subsection \Riesz-representation theorem\ theorem riesz_frechet_representation_cblinfun_existence: \ \Theorem 3.4 in @{cite conway2013course}\ fixes f::\'a::chilbert_space \\<^sub>C\<^sub>L complex\ shows \\t. \x. f *\<^sub>V x = \t, x\\ apply transfer by (rule riesz_frechet_representation_existence) lemma riesz_frechet_representation_cblinfun_unique: \ \Theorem 3.4 in @{cite conway2013course}\ fixes f::\'a::complex_inner \\<^sub>C\<^sub>L complex\ assumes \\x. f *\<^sub>V x = \t, x\\ assumes \\x. f *\<^sub>V x = \u, x\\ shows \t = u\ using assms by (rule riesz_frechet_representation_unique) theorem riesz_frechet_representation_cblinfun_norm: includes notation_norm fixes f::\'a::chilbert_space \\<^sub>C\<^sub>L complex\ assumes \\x. f *\<^sub>V x = \t, x\\ shows \\f\ = \t\\ using assms proof transfer fix f::\'a \ complex\ and t assume \bounded_clinear f\ and \\x. f x = \t, x\\ from \\x. f x = \t, x\\ have \(norm (f x)) / (norm x) \ norm t\ for x proof(cases \norm x = 0\) case True thus ?thesis by simp next case False have \norm (f x) = norm (\t, x\)\ using \\x. f x = \t, x\\ by simp also have \norm \t, x\ \ norm t * norm x\ by (simp add: complex_inner_class.Cauchy_Schwarz_ineq2) finally have \norm (f x) \ norm t * norm x\ by blast thus ?thesis by (metis False linordered_field_class.divide_right_mono nonzero_mult_div_cancel_right norm_ge_zero) qed moreover have \(norm (f t)) / (norm t) = norm t\ proof(cases \norm t = 0\) case True thus ?thesis by simp next case False have \f t = \t, t\\ using \\x. f x = \t, x\\ by blast also have \\ = (norm t)^2\ by (meson cnorm_eq_square) also have \\ = (norm t)*(norm t)\ by (simp add: power2_eq_square) finally have \f t = (norm t)*(norm t)\ by blast thus ?thesis by (metis False Re_complex_of_real \\x. f x = cinner t x\ cinner_ge_zero complex_of_real_cmod nonzero_divide_eq_eq) qed ultimately have \Sup {(norm (f x)) / (norm x)| x. True} = norm t\ by (smt cSup_eq_maximum mem_Collect_eq) moreover have \Sup {(norm (f x)) / (norm x)| x. True} = (SUP x. (norm (f x)) / (norm x))\ by (simp add: full_SetCompr_eq) ultimately show \onorm f = norm t\ by (simp add: onorm_def) qed subsection \Extension of complex bounded operators\ definition cblinfun_extension where "cblinfun_extension S \ = (SOME B. \x\S. B *\<^sub>V x = \ x)" definition cblinfun_extension_exists where "cblinfun_extension_exists S \ = (\B. \x\S. B *\<^sub>V x = \ x)" lemma cblinfun_extension_existsI: assumes "\x. x\S \ B *\<^sub>V x = \ x" shows "cblinfun_extension_exists S \" using assms cblinfun_extension_exists_def by blast lemma cblinfun_extension_exists_finite_dim: fixes \::"'a::{complex_normed_vector,cfinite_dim} \ 'b::complex_normed_vector" assumes "cindependent S" and "cspan S = UNIV" shows "cblinfun_extension_exists S \" proof- define f::"'a \ 'b" where "f = complex_vector.construct S \" have "clinear f" by (simp add: complex_vector.linear_construct assms linear_construct f_def) have "bounded_clinear f" using \clinear f\ assms by auto then obtain B::"'a \\<^sub>C\<^sub>L 'b" where "B *\<^sub>V x = f x" for x using cblinfun_apply_cases by blast have "B *\<^sub>V x = \ x" if c1: "x\S" for x proof- have "B *\<^sub>V x = f x" by (simp add: \\x. B *\<^sub>V x = f x\) also have "\ = \ x" using assms complex_vector.construct_basis f_def that by (simp add: complex_vector.construct_basis) finally show?thesis by blast qed thus ?thesis unfolding cblinfun_extension_exists_def by blast qed lemma cblinfun_extension_exists_bounded_dense: fixes f :: \'a::complex_normed_vector \ 'b::cbanach\ assumes \csubspace S\ assumes \closure S = UNIV\ assumes f_add: \\x y. x \ S \ y \ S \ f (x + y) = f x + f y\ assumes f_scale: \\c x y. x \ S \ f (c *\<^sub>C x) = c *\<^sub>C f x\ assumes bounded: \\x. x \ S \ norm (f x) \ B * norm x\ shows \cblinfun_extension_exists S f\ proof - obtain B where bounded: \\x. x \ S \ norm (f x) \ B * norm x\ and \B > 0\ using bounded by (smt (z3) mult_mono norm_ge_zero) have \\xi. (xi \ x) \ (\i. xi i \ S)\ for x using assms(2) closure_sequential by blast then obtain seq :: \'a \ nat \ 'a\ where seq_lim: \seq x \ x\ and seq_S: \seq x i \ S\ for x i apply (atomize_elim, subst all_conj_distrib[symmetric]) apply (rule choice) by auto define g where \g x = lim (\i. f (seq x i))\ for x have \Cauchy (\i. f (seq x i))\ for x proof (rule CauchyI) fix e :: real assume \e > 0\ have \Cauchy (seq x)\ using LIMSEQ_imp_Cauchy seq_lim by blast then obtain M where less_eB: \norm (seq x m - seq x n) < e/B\ if \n \ M\ and \m \ M\ for n m apply atomize_elim by (meson CauchyD \0 < B\ \0 < e\ linordered_field_class.divide_pos_pos) have \norm (f (seq x m) - f (seq x n)) < e\ if \n \ M\ and \m \ M\ for n m proof - have \norm (f (seq x m) - f (seq x n)) = norm (f (seq x m - seq x n))\ using f_add f_scale seq_S by (metis add_diff_cancel assms(1) complex_vector.subspace_diff diff_add_cancel) also have \\ \ B * norm (seq x m - seq x n)\ apply (rule bounded) by (simp add: assms(1) complex_vector.subspace_diff seq_S) also from less_eB have \\ < B * (e/B)\ by (meson \0 < B\ linordered_semiring_strict_class.mult_strict_left_mono that) also have \\ \ e\ using \0 < B\ by auto finally show ?thesis by - qed then show \\M. \m\M. \n\M. norm (f (seq x m) - f (seq x n)) < e\ by auto qed then have f_seq_lim: \(\i. f (seq x i)) \ g x\ for x by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff g_def) have f_xi_lim: \(\i. f (xi i)) \ g x\ if \xi \ x\ and \\i. xi i \ S\ for xi x proof - from seq_lim that have \(\i. B * norm (xi i - seq x i)) \ 0\ by (metis (no_types) \0 < B\ cancel_comm_monoid_add_class.diff_cancel norm_not_less_zero norm_zero tendsto_diff tendsto_norm_zero_iff tendsto_zero_mult_left_iff) then have \(\i. f (xi i + (-1) *\<^sub>C seq x i)) \ 0\ apply (rule Lim_null_comparison[rotated]) using bounded by (simp add: assms(1) complex_vector.subspace_diff seq_S that(2)) then have \(\i. f (xi i) - f (seq x i)) \ 0\ apply (subst (asm) f_add) apply (auto simp: that \csubspace S\ complex_vector.subspace_neg seq_S)[2] apply (subst (asm) f_scale) by (auto simp: that \csubspace S\ complex_vector.subspace_neg seq_S) then show \(\i. f (xi i)) \ g x\ using Lim_transform f_seq_lim by fastforce qed have g_add: \g (x + y) = g x + g y\ for x y proof - obtain xi :: \nat \ 'a\ where \xi \ x\ and \xi i \ S\ for i using seq_S seq_lim by auto obtain yi :: \nat \ 'a\ where \yi \ y\ and \yi i \ S\ for i using seq_S seq_lim by auto have \(\i. xi i + yi i) \ x + y\ using \xi \ x\ \yi \ y\ tendsto_add by blast then have lim1: \(\i. f (xi i + yi i)) \ g (x + y)\ by (simp add: \\i. xi i \ S\ \\i. yi i \ S\ assms(1) complex_vector.subspace_add f_xi_lim) have \(\i. f (xi i + yi i)) = (\i. f (xi i) + f (yi i))\ by (simp add: \\i. xi i \ S\ \\i. yi i \ S\ f_add) also have \\ \ g x + g y\ by (simp add: \\i. xi i \ S\ \\i. yi i \ S\ \xi \ x\ \yi \ y\ f_xi_lim tendsto_add) finally show ?thesis using lim1 LIMSEQ_unique by blast qed have g_scale: \g (c *\<^sub>C x) = c *\<^sub>C g x\ for c x proof - obtain xi :: \nat \ 'a\ where \xi \ x\ and \xi i \ S\ for i using seq_S seq_lim by auto have \(\i. c *\<^sub>C xi i) \ c *\<^sub>C x\ using \xi \ x\ bounded_clinear_scaleC_right clinear_continuous_at isCont_tendsto_compose by blast then have lim1: \(\i. f (c *\<^sub>C xi i)) \ g (c *\<^sub>C x)\ by (simp add: \\i. xi i \ S\ assms(1) complex_vector.subspace_scale f_xi_lim) have \(\i. f (c *\<^sub>C xi i)) = (\i. c *\<^sub>C f (xi i))\ by (simp add: \\i. xi i \ S\ f_scale) also have \\ \ c *\<^sub>C g x\ using \\i. xi i \ S\ \xi \ x\ bounded_clinear_scaleC_right clinear_continuous_at f_xi_lim isCont_tendsto_compose by blast finally show ?thesis using lim1 LIMSEQ_unique by blast qed have [simp]: \f x = g x\ if \x \ S\ for x proof - have \(\_. x) \ x\ by auto then have \(\_. f x) \ g x\ using that by (rule f_xi_lim) then show \f x = g x\ by (simp add: LIMSEQ_const_iff) qed have g_bounded: \norm (g x) \ B * norm x\ for x proof - obtain xi :: \nat \ 'a\ where \xi \ x\ and \xi i \ S\ for i using seq_S seq_lim by auto then have \(\i. f (xi i)) \ g x\ using f_xi_lim by presburger then have \(\i. norm (f (xi i))) \ norm (g x)\ by (metis tendsto_norm) moreover have \(\i. B * norm (xi i)) \ B * norm x\ by (simp add: \xi \ x\ tendsto_mult_left tendsto_norm) ultimately show \norm (g x) \ B * norm x\ apply (rule lim_mono[rotated]) using bounded using \xi _ \ S\ by blast qed have \bounded_clinear g\ using g_add g_scale apply (rule bounded_clinearI[where K=B]) using g_bounded by (simp add: ordered_field_class.sign_simps(5)) then have [simp]: \CBlinfun g *\<^sub>V x = g x\ for x by (subst CBlinfun_inverse, auto) show \cblinfun_extension_exists S f\ apply (rule cblinfun_extension_existsI[where B=\CBlinfun g\]) by auto qed lemma cblinfun_extension_apply: assumes "cblinfun_extension_exists S f" and "v \ S" shows "(cblinfun_extension S f) *\<^sub>V v = f v" by (smt assms cblinfun_extension_def cblinfun_extension_exists_def tfl_some) subsection \Notation\ bundle cblinfun_notation begin notation cblinfun_compose (infixl "o\<^sub>C\<^sub>L" 55) notation cblinfun_apply (infixr "*\<^sub>V" 70) notation cblinfun_image (infixr "*\<^sub>S" 70) notation adj ("_*" [99] 100) end bundle no_cblinfun_notation begin no_notation cblinfun_compose (infixl "o\<^sub>C\<^sub>L" 55) no_notation cblinfun_apply (infixr "*\<^sub>V" 70) no_notation cblinfun_image (infixr "*\<^sub>S" 70) no_notation adj ("_*" [99] 100) end bundle blinfun_notation begin notation blinfun_apply (infixr "*\<^sub>V" 70) end bundle no_blinfun_notation begin no_notation blinfun_apply (infixr "*\<^sub>V" 70) end unbundle no_cblinfun_notation +unbundle no_lattice_syntax end diff --git a/thys/Complex_Bounded_Operators/Complex_L2.thy b/thys/Complex_Bounded_Operators/Complex_L2.thy --- a/thys/Complex_Bounded_Operators/Complex_L2.thy +++ b/thys/Complex_Bounded_Operators/Complex_L2.thy @@ -1,1462 +1,1463 @@ section \\Complex_L2\ -- Hilbert space of square-summable functions\ (* Authors: Dominique Unruh, University of Tartu, unruh@ut.ee Jose Manuel Rodriguez Caballero, University of Tartu, jose.manuel.rodriguez.caballero@ut.ee *) theory Complex_L2 imports Complex_Bounded_Linear_Function "HOL-Analysis.L2_Norm" "HOL-Library.Rewrite" "HOL-Analysis.Infinite_Sum" begin +unbundle lattice_syntax unbundle cblinfun_notation unbundle no_notation_blinfun_apply subsection \l2 norm of functions\ definition "has_ell2_norm (x::_\complex) \ (\i. (x i)\<^sup>2) abs_summable_on UNIV" lemma has_ell2_norm_bdd_above: \has_ell2_norm x \ bdd_above (sum (\xa. norm ((x xa)\<^sup>2)) ` Collect finite)\ by (simp add: has_ell2_norm_def abs_summable_iff_bdd_above) lemma has_ell2_norm_L2_set: "has_ell2_norm x = bdd_above (L2_set (norm o x) ` Collect finite)" proof (rule iffI) have \mono sqrt\ using monoI real_sqrt_le_mono by blast assume \has_ell2_norm x\ then have *: \bdd_above (sum (\xa. norm ((x xa)\<^sup>2)) ` Collect finite)\ by (subst (asm) has_ell2_norm_bdd_above) have \bdd_above ((\F. sqrt (sum (\xa. norm ((x xa)\<^sup>2)) F)) ` Collect finite)\ using bdd_above_image_mono[OF \mono sqrt\ *] by (auto simp: image_image) then show \bdd_above (L2_set (norm o x) ` Collect finite)\ by (auto simp: L2_set_def norm_power) next define p2 where \p2 x = (if x < 0 then 0 else x^2)\ for x :: real have \mono p2\ by (simp add: monoI p2_def) have [simp]: \p2 (L2_set f F) = (\i\F. (f i)\<^sup>2)\ for f and F :: \'a set\ by (smt (verit) L2_set_def L2_set_nonneg p2_def power2_less_0 real_sqrt_pow2 sum.cong sum_nonneg) assume *: \bdd_above (L2_set (norm o x) ` Collect finite)\ have \bdd_above (p2 ` L2_set (norm o x) ` Collect finite)\ using bdd_above_image_mono[OF \mono p2\ *] by auto then show \has_ell2_norm x\ apply (simp add: image_image has_ell2_norm_def abs_summable_iff_bdd_above) by (simp add: norm_power) qed definition ell2_norm :: \('a \ complex) \ real\ where \ell2_norm x = sqrt (\\<^sub>\i. norm (x i)^2)\ lemma ell2_norm_SUP: assumes \has_ell2_norm x\ shows "ell2_norm x = sqrt (SUP F\{F. finite F}. sum (\i. norm (x i)^2) F)" using assms apply (auto simp add: ell2_norm_def has_ell2_norm_def) apply (subst infsum_nonneg_is_SUPREMUM_real) by (auto simp: norm_power) lemma ell2_norm_L2_set: assumes "has_ell2_norm x" shows "ell2_norm x = (SUP F\{F. finite F}. L2_set (norm o x) F)" proof- have "sqrt (\ (sum (\i. (cmod (x i))\<^sup>2) ` Collect finite)) = (SUP F\{F. finite F}. sqrt (\i\F. (cmod (x i))\<^sup>2))" proof (subst continuous_at_Sup_mono) show "mono sqrt" by (simp add: mono_def) show "continuous (at_left (\ (sum (\i. (cmod (x i))\<^sup>2) ` Collect finite))) sqrt" using continuous_at_split isCont_real_sqrt by blast show "sum (\i. (cmod (x i))\<^sup>2) ` Collect finite \ {}" by auto show "bdd_above (sum (\i. (cmod (x i))\<^sup>2) ` Collect finite)" using has_ell2_norm_bdd_above[THEN iffD1, OF assms] by (auto simp: norm_power) show "\ (sqrt ` sum (\i. (cmod (x i))\<^sup>2) ` Collect finite) = (SUP F\Collect finite. sqrt (\i\F. (cmod (x i))\<^sup>2))" by (metis image_image) qed thus ?thesis using assms by (auto simp: ell2_norm_SUP L2_set_def) qed lemma has_ell2_norm_finite[simp]: "has_ell2_norm (x::'a::finite\_)" unfolding has_ell2_norm_def by simp lemma ell2_norm_finite: "ell2_norm (x::'a::finite\complex) = sqrt (sum (\i. (norm(x i))^2) UNIV)" by (simp add: ell2_norm_def) lemma ell2_norm_finite_L2_set: "ell2_norm (x::'a::finite\complex) = L2_set (norm o x) UNIV" by (simp add: ell2_norm_finite L2_set_def) lemma ell2_ket: fixes a defines \f \ (\i. if a = i then 1 else 0)\ shows has_ell2_norm_ket: \has_ell2_norm f\ and ell2_norm_ket: \ell2_norm f = 1\ proof - have \(\x. (f x)\<^sup>2) abs_summable_on {a}\ apply (rule summable_on_finite) by simp then show \has_ell2_norm f\ unfolding has_ell2_norm_def apply (rule summable_on_cong_neutral[THEN iffD1, rotated -1]) unfolding f_def by auto have \(\\<^sub>\x\{a}. (f x)\<^sup>2) = 1\ apply (subst infsum_finite) by (auto simp: f_def) then show \ell2_norm f = 1\ unfolding ell2_norm_def apply (subst infsum_cong_neutral[where T=\{a}\ and g=\\x. (cmod (f x))\<^sup>2\]) by (auto simp: f_def) qed lemma ell2_norm_geq0: \ell2_norm x \ 0\ by (auto simp: ell2_norm_def intro!: infsum_nonneg) lemma ell2_norm_point_bound: assumes \has_ell2_norm x\ shows \ell2_norm x \ cmod (x i)\ proof - have \(cmod (x i))\<^sup>2 = norm ((x i)\<^sup>2)\ by (simp add: norm_power) also have \norm ((x i)\<^sup>2) = sum (\i. (norm ((x i)\<^sup>2))) {i}\ by auto also have \\ = infsum (\i. (norm ((x i)\<^sup>2))) {i}\ by (rule infsum_finite[symmetric], simp) also have \\ \ infsum (\i. (norm ((x i)\<^sup>2))) UNIV\ apply (rule infsum_mono_neutral) using assms by (auto simp: has_ell2_norm_def) also have \\ = (ell2_norm x)\<^sup>2\ by (metis (no_types, lifting) ell2_norm_def ell2_norm_geq0 infsum_cong norm_power real_sqrt_eq_iff real_sqrt_unique) finally show ?thesis using ell2_norm_geq0 power2_le_imp_le by blast qed lemma ell2_norm_0: assumes "has_ell2_norm x" shows "(ell2_norm x = 0) = (x = (\_. 0))" proof assume u1: "x = (\_. 0)" have u2: "(SUP x::'a set\Collect finite. (0::real)) = 0" if "x = (\_. 0)" by (metis cSUP_const empty_Collect_eq finite.emptyI) show "ell2_norm x = 0" unfolding ell2_norm_def using u1 u2 by auto next assume norm0: "ell2_norm x = 0" show "x = (\_. 0)" proof fix i have \cmod (x i) \ ell2_norm x\ using assms by (rule ell2_norm_point_bound) also have \\ = 0\ by (fact norm0) finally show "x i = 0" by auto qed qed lemma ell2_norm_smult: assumes "has_ell2_norm x" shows "has_ell2_norm (\i. c * x i)" and "ell2_norm (\i. c * x i) = cmod c * ell2_norm x" proof - have L2_set_mul: "L2_set (cmod \ (\i. c * x i)) F = cmod c * L2_set (cmod \ x) F" for F proof- have "L2_set (cmod \ (\i. c * x i)) F = L2_set (\i. (cmod c * (cmod o x) i)) F" by (metis comp_def norm_mult) also have "\ = cmod c * L2_set (cmod o x) F" by (metis norm_ge_zero L2_set_right_distrib) finally show ?thesis . qed from assms obtain M where M: "M \ L2_set (cmod o x) F" if "finite F" for F unfolding has_ell2_norm_L2_set bdd_above_def by auto hence "cmod c * M \ L2_set (cmod o (\i. c * x i)) F" if "finite F" for F unfolding L2_set_mul by (simp add: ordered_comm_semiring_class.comm_mult_left_mono that) thus has: "has_ell2_norm (\i. c * x i)" unfolding has_ell2_norm_L2_set bdd_above_def using L2_set_mul[symmetric] by auto have "ell2_norm (\i. c * x i) = (SUP F \ Collect finite. (L2_set (cmod \ (\i. c * x i)) F))" by (simp add: ell2_norm_L2_set has) also have "\ = (SUP F \ Collect finite. (cmod c * L2_set (cmod \ x) F))" using L2_set_mul by auto also have "\ = cmod c * ell2_norm x" proof (subst ell2_norm_L2_set) show "has_ell2_norm x" by (simp add: assms) show "(SUP F\Collect finite. cmod c * L2_set (cmod \ x) F) = cmod c * \ (L2_set (cmod \ x) ` Collect finite)" proof (subst continuous_at_Sup_mono [where f = "\x. cmod c * x"]) show "mono ((*) (cmod c))" by (simp add: mono_def ordered_comm_semiring_class.comm_mult_left_mono) show "continuous (at_left (\ (L2_set (cmod \ x) ` Collect finite))) ((*) (cmod c))" proof (rule continuous_mult) show "continuous (at_left (\ (L2_set (cmod \ x) ` Collect finite))) (\x. cmod c)" by simp show "continuous (at_left (\ (L2_set (cmod \ x) ` Collect finite))) (\x. x)" by simp qed show "L2_set (cmod \ x) ` Collect finite \ {}" by auto show "bdd_above (L2_set (cmod \ x) ` Collect finite)" by (meson assms has_ell2_norm_L2_set) show "(SUP F\Collect finite. cmod c * L2_set (cmod \ x) F) = \ ((*) (cmod c) ` L2_set (cmod \ x) ` Collect finite)" by (metis image_image) qed qed finally show "ell2_norm (\i. c * x i) = cmod c * ell2_norm x". qed lemma ell2_norm_triangle: assumes "has_ell2_norm x" and "has_ell2_norm y" shows "has_ell2_norm (\i. x i + y i)" and "ell2_norm (\i. x i + y i) \ ell2_norm x + ell2_norm y" proof - have triangle: "L2_set (cmod \ (\i. x i + y i)) F \ L2_set (cmod \ x) F + L2_set (cmod \ y) F" (is "?lhs\?rhs") if "finite F" for F proof - have "?lhs \ L2_set (\i. (cmod o x) i + (cmod o y) i) F" proof (rule L2_set_mono) show "(cmod \ (\i. x i + y i)) i \ (cmod \ x) i + (cmod \ y) i" if "i \ F" for i :: 'a using that norm_triangle_ineq by auto show "0 \ (cmod \ (\i. x i + y i)) i" if "i \ F" for i :: 'a using that by simp qed also have "\ \ ?rhs" by (rule L2_set_triangle_ineq) finally show ?thesis . qed obtain Mx My where Mx: "Mx \ L2_set (cmod o x) F" and My: "My \ L2_set (cmod o y) F" if "finite F" for F using assms unfolding has_ell2_norm_L2_set bdd_above_def by auto hence MxMy: "Mx + My \ L2_set (cmod \ x) F + L2_set (cmod \ y) F" if "finite F" for F using that by fastforce hence bdd_plus: "bdd_above ((\xa. L2_set (cmod \ x) xa + L2_set (cmod \ y) xa) ` Collect finite)" unfolding bdd_above_def by auto from MxMy have MxMy': "Mx + My \ L2_set (cmod \ (\i. x i + y i)) F" if "finite F" for F using triangle that by fastforce thus has: "has_ell2_norm (\i. x i + y i)" unfolding has_ell2_norm_L2_set bdd_above_def by auto have SUP_plus: "(SUP x\A. f x + g x) \ (SUP x\A. f x) + (SUP x\A. g x)" if notempty: "A\{}" and bddf: "bdd_above (f`A)"and bddg: "bdd_above (g`A)" for f g :: "'a set \ real" and A proof- have xleq: "x \ (SUP x\A. f x) + (SUP x\A. g x)" if x: "x \ (\x. f x + g x) ` A" for x proof - obtain a where aA: "a:A" and ax: "x = f a + g a" using x by blast have fa: "f a \ (SUP x\A. f x)" by (simp add: bddf aA cSUP_upper) moreover have "g a \ (SUP x\A. g x)" by (simp add: bddg aA cSUP_upper) ultimately have "f a + g a \ (SUP x\A. f x) + (SUP x\A. g x)" by simp with ax show ?thesis by simp qed have "(\x. f x + g x) ` A \ {}" using notempty by auto moreover have "x \ \ (f ` A) + \ (g ` A)" if "x \ (\x. f x + g x) ` A" for x :: real using that by (simp add: xleq) ultimately show ?thesis by (meson bdd_above_def cSup_le_iff) qed have a2: "bdd_above (L2_set (cmod \ x) ` Collect finite)" by (meson assms(1) has_ell2_norm_L2_set) have a3: "bdd_above (L2_set (cmod \ y) ` Collect finite)" by (meson assms(2) has_ell2_norm_L2_set) have a1: "Collect finite \ {}" by auto have a4: "\ (L2_set (cmod \ (\i. x i + y i)) ` Collect finite) \ (SUP xa\Collect finite. L2_set (cmod \ x) xa + L2_set (cmod \ y) xa)" by (metis (mono_tags, lifting) a1 bdd_plus cSUP_mono mem_Collect_eq triangle) have "\r. \ (L2_set (cmod \ (\a. x a + y a)) ` Collect finite) \ r \ \ (SUP A\Collect finite. L2_set (cmod \ x) A + L2_set (cmod \ y) A) \ r" using a4 by linarith hence "\ (L2_set (cmod \ (\i. x i + y i)) ` Collect finite) \ \ (L2_set (cmod \ x) ` Collect finite) + \ (L2_set (cmod \ y) ` Collect finite)" by (metis (no_types) SUP_plus a1 a2 a3) hence "\ (L2_set (cmod \ (\i. x i + y i)) ` Collect finite) \ ell2_norm x + ell2_norm y" by (simp add: assms(1) assms(2) ell2_norm_L2_set) thus "ell2_norm (\i. x i + y i) \ ell2_norm x + ell2_norm y" by (simp add: ell2_norm_L2_set has) qed lemma ell2_norm_uminus: assumes "has_ell2_norm x" shows \has_ell2_norm (\i. - x i)\ and \ell2_norm (\i. - x i) = ell2_norm x\ using assms by (auto simp: has_ell2_norm_def ell2_norm_def) subsection \The type \ell2\ of square-summable functions\ typedef 'a ell2 = "{x::'a\complex. has_ell2_norm x}" unfolding has_ell2_norm_def by (rule exI[of _ "\_.0"], auto) setup_lifting type_definition_ell2 instantiation ell2 :: (type)complex_vector begin lift_definition zero_ell2 :: "'a ell2" is "\_. 0" by (auto simp: has_ell2_norm_def) lift_definition uminus_ell2 :: "'a ell2 \ 'a ell2" is uminus by (simp add: has_ell2_norm_def) lift_definition plus_ell2 :: "'a ell2 \ 'a ell2 \ 'a ell2" is "\f g x. f x + g x" by (rule ell2_norm_triangle) lift_definition minus_ell2 :: "'a ell2 \ 'a ell2 \ 'a ell2" is "\f g x. f x - g x" apply (subst add_uminus_conv_diff[symmetric]) apply (rule ell2_norm_triangle) by (auto simp add: ell2_norm_uminus) lift_definition scaleR_ell2 :: "real \ 'a ell2 \ 'a ell2" is "\r f x. complex_of_real r * f x" by (rule ell2_norm_smult) lift_definition scaleC_ell2 :: "complex \ 'a ell2 \ 'a ell2" is "\c f x. c * f x" by (rule ell2_norm_smult) instance proof fix a b c :: "'a ell2" show "((*\<^sub>R) r::'a ell2 \ _) = (*\<^sub>C) (complex_of_real r)" for r apply (rule ext) apply transfer by auto show "a + b + c = a + (b + c)" by (transfer; rule ext; simp) show "a + b = b + a" by (transfer; rule ext; simp) show "0 + a = a" by (transfer; rule ext; simp) show "- a + a = 0" by (transfer; rule ext; simp) show "a - b = a + - b" by (transfer; rule ext; simp) show "r *\<^sub>C (a + b) = r *\<^sub>C a + r *\<^sub>C b" for r apply (transfer; rule ext) by (simp add: vector_space_over_itself.scale_right_distrib) show "(r + r') *\<^sub>C a = r *\<^sub>C a + r' *\<^sub>C a" for r r' apply (transfer; rule ext) by (simp add: ring_class.ring_distribs(2)) show "r *\<^sub>C r' *\<^sub>C a = (r * r') *\<^sub>C a" for r r' by (transfer; rule ext; simp) show "1 *\<^sub>C a = a" by (transfer; rule ext; simp) qed end instantiation ell2 :: (type)complex_normed_vector begin lift_definition norm_ell2 :: "'a ell2 \ real" is ell2_norm . declare norm_ell2_def[code del] definition "dist x y = norm (x - y)" for x y::"'a ell2" definition "sgn x = x /\<^sub>R norm x" for x::"'a ell2" definition [code del]: "uniformity = (INF e\{0<..}. principal {(x::'a ell2, y). norm (x - y) < e})" definition [code del]: "open U = (\x\U. \\<^sub>F (x', y) in INF e\{0<..}. principal {(x, y). norm (x - y) < e}. x' = x \ y \ U)" for U :: "'a ell2 set" instance proof fix a b :: "'a ell2" show "dist a b = norm (a - b)" by (simp add: dist_ell2_def) show "sgn a = a /\<^sub>R norm a" by (simp add: sgn_ell2_def) show "uniformity = (INF e\{0<..}. principal {(x, y). dist (x::'a ell2) y < e})" unfolding dist_ell2_def uniformity_ell2_def by simp show "open U = (\x\U. \\<^sub>F (x', y) in uniformity. (x'::'a ell2) = x \ y \ U)" for U :: "'a ell2 set" unfolding uniformity_ell2_def open_ell2_def by simp_all show "(norm a = 0) = (a = 0)" apply transfer by (fact ell2_norm_0) show "norm (a + b) \ norm a + norm b" apply transfer by (fact ell2_norm_triangle) show "norm (r *\<^sub>R (a::'a ell2)) = \r\ * norm a" for r and a :: "'a ell2" apply transfer by (simp add: ell2_norm_smult(2)) show "norm (r *\<^sub>C a) = cmod r * norm a" for r apply transfer by (simp add: ell2_norm_smult(2)) qed end lemma norm_point_bound_ell2: "norm (Rep_ell2 x i) \ norm x" apply transfer by (simp add: ell2_norm_point_bound) lemma ell2_norm_finite_support: assumes \finite S\ \\ i. i \ S \ Rep_ell2 x i = 0\ shows \norm x = sqrt ((sum (\i. (cmod (Rep_ell2 x i))\<^sup>2)) S)\ proof (insert assms(2), transfer fixing: S) fix x :: \'a \ complex\ assume zero: \\i. i \ S \ x i = 0\ have \ell2_norm x = sqrt (\\<^sub>\i. (cmod (x i))\<^sup>2)\ by (auto simp: ell2_norm_def) also have \\ = sqrt (\\<^sub>\i\S. (cmod (x i))\<^sup>2)\ apply (subst infsum_cong_neutral[where g=\\i. (cmod (x i))\<^sup>2\ and S=UNIV and T=S]) using zero by auto also have \\ = sqrt (\i\S. (cmod (x i))\<^sup>2)\ using \finite S\ by simp finally show \ell2_norm x = sqrt (\i\S. (cmod (x i))\<^sup>2)\ by - qed instantiation ell2 :: (type) complex_inner begin lift_definition cinner_ell2 :: "'a ell2 \ 'a ell2 \ complex" is "\x y. infsum (\i. (cnj (x i) * y i)) UNIV" . declare cinner_ell2_def[code del] instance proof standard fix x y z :: "'a ell2" fix c :: complex show "cinner x y = cnj (cinner y x)" proof transfer fix x y :: "'a\complex" assume "has_ell2_norm x" and "has_ell2_norm y" have "(\\<^sub>\i. cnj (x i) * y i) = (\\<^sub>\i. cnj (cnj (y i) * x i))" by (metis complex_cnj_cnj complex_cnj_mult mult.commute) also have "\ = cnj (\\<^sub>\i. cnj (y i) * x i)" by (metis infsum_cnj) finally show "(\\<^sub>\i. cnj (x i) * y i) = cnj (\\<^sub>\i. cnj (y i) * x i)" . qed show "cinner (x + y) z = cinner x z + cinner y z" proof transfer fix x y z :: "'a \ complex" assume "has_ell2_norm x" hence cnj_x: "(\i. cnj (x i) * cnj (x i)) abs_summable_on UNIV" by (simp del: complex_cnj_mult add: norm_mult[symmetric] complex_cnj_mult[symmetric] has_ell2_norm_def power2_eq_square) assume "has_ell2_norm y" hence cnj_y: "(\i. cnj (y i) * cnj (y i)) abs_summable_on UNIV" by (simp del: complex_cnj_mult add: norm_mult[symmetric] complex_cnj_mult[symmetric] has_ell2_norm_def power2_eq_square) assume "has_ell2_norm z" hence z: "(\i. z i * z i) abs_summable_on UNIV" by (simp add: norm_mult[symmetric] has_ell2_norm_def power2_eq_square) have cnj_x_z:"(\i. cnj (x i) * z i) abs_summable_on UNIV" using cnj_x z by (rule abs_summable_product) have cnj_y_z:"(\i. cnj (y i) * z i) abs_summable_on UNIV" using cnj_y z by (rule abs_summable_product) show "(\\<^sub>\i. cnj (x i + y i) * z i) = (\\<^sub>\i. cnj (x i) * z i) + (\\<^sub>\i. cnj (y i) * z i)" apply (subst infsum_add [symmetric]) using cnj_x_z cnj_y_z by (auto simp add: summable_on_iff_abs_summable_on_complex distrib_left mult.commute) qed show "cinner (c *\<^sub>C x) y = cnj c * cinner x y" proof transfer fix x y :: "'a \ complex" and c :: complex assume "has_ell2_norm x" hence cnj_x: "(\i. cnj (x i) * cnj (x i)) abs_summable_on UNIV" by (simp del: complex_cnj_mult add: norm_mult[symmetric] complex_cnj_mult[symmetric] has_ell2_norm_def power2_eq_square) assume "has_ell2_norm y" hence y: "(\i. y i * y i) abs_summable_on UNIV" by (simp add: norm_mult[symmetric] has_ell2_norm_def power2_eq_square) have cnj_x_y:"(\i. cnj (x i) * y i) abs_summable_on UNIV" using cnj_x y by (rule abs_summable_product) thus "(\\<^sub>\i. cnj (c * x i) * y i) = cnj c * (\\<^sub>\i. cnj (x i) * y i)" by (auto simp flip: infsum_cmult_right simp add: abs_summable_summable mult.commute vector_space_over_itself.scale_left_commute) qed show "0 \ cinner x x" proof transfer fix x :: "'a \ complex" assume "has_ell2_norm x" hence "(\i. cmod (cnj (x i) * x i)) abs_summable_on UNIV" by (simp add: norm_mult has_ell2_norm_def power2_eq_square) hence "(\i. cnj (x i) * x i) abs_summable_on UNIV" by auto hence sum: "(\i. cnj (x i) * x i) abs_summable_on UNIV" unfolding has_ell2_norm_def power2_eq_square. have "0 = (\\<^sub>\i::'a. 0)" by auto also have "\ \ (\\<^sub>\i. cnj (x i) * x i)" apply (rule infsum_mono_complex) by (auto simp add: abs_summable_summable sum) finally show "0 \ (\\<^sub>\i. cnj (x i) * x i)" by assumption qed show "(cinner x x = 0) = (x = 0)" proof (transfer, auto) fix x :: "'a \ complex" assume "has_ell2_norm x" hence "(\i::'a. cmod (cnj (x i) * x i)) abs_summable_on UNIV" by (smt (verit, del_insts) complex_mod_mult_cnj has_ell2_norm_def mult.commute norm_ge_zero norm_power real_norm_def summable_on_cong) hence cmod_x2: "(\i. cnj (x i) * x i) abs_summable_on UNIV" unfolding has_ell2_norm_def power2_eq_square by simp assume eq0: "(\\<^sub>\i. cnj (x i) * x i) = 0" show "x = (\_. 0)" proof (rule ccontr) assume "x \ (\_. 0)" then obtain i where "x i \ 0" by auto hence "0 < cnj (x i) * x i" by (metis le_less cnj_x_x_geq0 complex_cnj_zero_iff vector_space_over_itself.scale_eq_0_iff) also have "\ = (\\<^sub>\i\{i}. cnj (x i) * x i)" by auto also have "\ \ (\\<^sub>\i. cnj (x i) * x i)" apply (rule infsum_mono_neutral_complex) by (auto simp add: abs_summable_summable cmod_x2) also from eq0 have "\ = 0" by assumption finally show False by simp qed qed show "norm x = sqrt (cmod (cinner x x))" proof transfer fix x :: "'a \ complex" assume x: "has_ell2_norm x" have "(\i::'a. cmod (x i) * cmod (x i)) abs_summable_on UNIV \ (\i::'a. cmod (cnj (x i) * x i)) abs_summable_on UNIV" by (simp add: norm_mult has_ell2_norm_def power2_eq_square) hence sum: "(\i. cnj (x i) * x i) abs_summable_on UNIV" by (metis (no_types, lifting) complex_mod_mult_cnj has_ell2_norm_def mult.commute norm_power summable_on_cong x) from x have "ell2_norm x = sqrt (\\<^sub>\i. (cmod (x i))\<^sup>2)" unfolding ell2_norm_def by simp also have "\ = sqrt (\\<^sub>\i. cmod (cnj (x i) * x i))" unfolding norm_complex_def power2_eq_square by auto also have "\ = sqrt (cmod (\\<^sub>\i. cnj (x i) * x i))" by (auto simp: infsum_cmod abs_summable_summable sum) finally show "ell2_norm x = sqrt (cmod (\\<^sub>\i. cnj (x i) * x i))" by assumption qed qed end instance ell2 :: (type) chilbert_space proof fix X :: \nat \ 'a ell2\ define x where \x n a = Rep_ell2 (X n) a\ for n a have [simp]: \has_ell2_norm (x n)\ for n using Rep_ell2 x_def[abs_def] by simp assume \Cauchy X\ moreover have "dist (x n a) (x m a) \ dist (X n) (X m)" for n m a by (metis Rep_ell2 x_def dist_norm ell2_norm_point_bound mem_Collect_eq minus_ell2.rep_eq norm_ell2.rep_eq) ultimately have \Cauchy (\n. x n a)\ for a by (meson Cauchy_def le_less_trans) then obtain l where x_lim: \(\n. x n a) \ l a\ for a apply atomize_elim apply (rule choice) by (simp add: convergent_eq_Cauchy) define L where \L = Abs_ell2 l\ define normF where \normF F x = L2_set (cmod \ x) F\ for F :: \'a set\ and x have normF_triangle: \normF F (\a. x a + y a) \ normF F x + normF F y\ if \finite F\ for F x y proof - have \normF F (\a. x a + y a) = L2_set (\a. cmod (x a + y a)) F\ by (metis (mono_tags, lifting) L2_set_cong comp_apply normF_def) also have \\ \ L2_set (\a. cmod (x a) + cmod (y a)) F\ by (meson L2_set_mono norm_ge_zero norm_triangle_ineq) also have \\ \ L2_set (\a. cmod (x a)) F + L2_set (\a. cmod (y a)) F\ by (simp add: L2_set_triangle_ineq) also have \\ \ normF F x + normF F y\ by (smt (verit, best) L2_set_cong normF_def comp_apply) finally show ?thesis by - qed have normF_negate: \normF F (\a. - x a) = normF F x\ if \finite F\ for F x unfolding normF_def o_def by simp have normF_ell2norm: \normF F x \ ell2_norm x\ if \finite F\ and \has_ell2_norm x\ for F x apply (auto intro!: cSUP_upper2[where x=F] simp: that normF_def ell2_norm_L2_set) by (meson has_ell2_norm_L2_set that(2)) note Lim_bounded2[rotated, rule_format, trans] from \Cauchy X\ obtain I where cauchyX: \norm (X n - X m) \ \\ if \\>0\ \n\I \\ \m\I \\ for \ n m by (metis Cauchy_def dist_norm less_eq_real_def) have normF_xx: \normF F (\a. x n a - x m a) \ \\ if \finite F\ \\>0\ \n\I \\ \m\I \\ for \ n m F apply (subst asm_rl[of \(\a. x n a - x m a) = Rep_ell2 (X n - X m)\]) apply (simp add: x_def minus_ell2.rep_eq) using that cauchyX by (metis Rep_ell2 mem_Collect_eq normF_ell2norm norm_ell2.rep_eq order_trans) have normF_xl_lim: \(\m. normF F (\a. x m a - l a)) \ 0\ if \finite F\ for F proof - have \(\xa. cmod (x xa m - l m)) \ 0\ for m using x_lim by (simp add: LIM_zero_iff tendsto_norm_zero) then have \(\m. \i\F. ((cmod \ (\a. x m a - l a)) i)\<^sup>2) \ 0\ by (auto intro: tendsto_null_sum) then show ?thesis unfolding normF_def L2_set_def using tendsto_real_sqrt by force qed have normF_xl: \normF F (\a. x n a - l a) \ \\ if \n \ I \\ and \\ > 0\ and \finite F\ for n \ F proof - have \normF F (\a. x n a - l a) - \ \ normF F (\a. x n a - x m a) + normF F (\a. x m a - l a) - \\ for m using normF_triangle[OF \finite F\, where x=\(\a. x n a - x m a)\ and y=\(\a. x m a - l a)\] by auto also have \\ m \ normF F (\a. x m a - l a)\ if \m \ I \\ for m using normF_xx[OF \finite F\ \\>0\ \n \ I \\ \m \ I \\] by auto also have \(\m. \ m) \ 0\ using \finite F\ by (rule normF_xl_lim) finally show ?thesis by auto qed have \normF F l \ 1 + normF F (x (I 1))\ if [simp]: \finite F\ for F using normF_xl[where F=F and \=1 and n=\I 1\] using normF_triangle[where F=F and x=\x (I 1)\ and y=\\a. l a - x (I 1) a\] using normF_negate[where F=F and x=\(\a. x (I 1) a - l a)\] by auto also have \\ F \ 1 + ell2_norm (x (I 1))\ if \finite F\ for F using normF_ell2norm that by simp finally have [simp]: \has_ell2_norm l\ unfolding has_ell2_norm_L2_set by (auto intro!: bdd_aboveI simp flip: normF_def) then have \l = Rep_ell2 L\ by (simp add: Abs_ell2_inverse L_def) have [simp]: \has_ell2_norm (\a. x n a - l a)\ for n apply (subst diff_conv_add_uminus) apply (rule ell2_norm_triangle) by (auto intro!: ell2_norm_uminus) from normF_xl have ell2norm_xl: \ell2_norm (\a. x n a - l a) \ \\ if \n \ I \\ and \\ > 0\ for n \ apply (subst ell2_norm_L2_set) using that by (auto intro!: cSUP_least simp: normF_def) have \norm (X n - L) \ \\ if \n \ I \\ and \\ > 0\ for n \ using ell2norm_xl[OF that] by (simp add: x_def norm_ell2.rep_eq \l = Rep_ell2 L\ minus_ell2.rep_eq) then have \X \ L\ unfolding tendsto_iff apply (auto simp: dist_norm eventually_sequentially) by (meson field_lbound_gt_zero le_less_trans) then show \convergent X\ by (rule convergentI) qed instantiation ell2 :: (CARD_1) complex_algebra_1 begin lift_definition one_ell2 :: "'a ell2" is "\_. 1" by simp lift_definition times_ell2 :: "'a ell2 \ 'a ell2 \ 'a ell2" is "\a b x. a x * b x" by simp instance proof fix a b c :: "'a ell2" and r :: complex show "a * b * c = a * (b * c)" by (transfer, auto) show "(a + b) * c = a * c + b * c" apply (transfer, rule ext) by (simp add: distrib_left mult.commute) show "a * (b + c) = a * b + a * c" apply transfer by (simp add: ring_class.ring_distribs(1)) show "r *\<^sub>C a * b = r *\<^sub>C (a * b)" by (transfer, auto) show "(a::'a ell2) * r *\<^sub>C b = r *\<^sub>C (a * b)" by (transfer, auto) show "1 * a = a" by (transfer, rule ext, auto) show "a * 1 = a" by (transfer, rule ext, auto) show "(0::'a ell2) \ 1" apply transfer by (meson zero_neq_one) qed end instantiation ell2 :: (CARD_1) field begin lift_definition divide_ell2 :: "'a ell2 \ 'a ell2 \ 'a ell2" is "\a b x. a x / b x" by simp lift_definition inverse_ell2 :: "'a ell2 \ 'a ell2" is "\a x. inverse (a x)" by simp instance proof (intro_classes; transfer) fix a :: "'a \ complex" assume "a \ (\_. 0)" then obtain y where ay: "a y \ 0" by auto show "(\x. inverse (a x) * a x) = (\_. 1)" proof (rule ext) fix x have "x = y" by auto with ay have "a x \ 0" by metis then show "inverse (a x) * a x = 1" by auto qed qed (auto simp add: divide_complex_def mult.commute ring_class.ring_distribs) end subsection \Orthogonality\ lemma ell2_pointwise_ortho: assumes \\ i. Rep_ell2 x i = 0 \ Rep_ell2 y i = 0\ shows \is_orthogonal x y\ using assms apply transfer by (simp add: infsum_0) subsection \Truncated vectors\ lift_definition trunc_ell2:: \'a set \ 'a ell2 \ 'a ell2\ is \\ S x. (\ i. (if i \ S then x i else 0))\ proof (rename_tac S x) fix x :: \'a \ complex\ and S :: \'a set\ assume \has_ell2_norm x\ then have \(\i. (x i)\<^sup>2) abs_summable_on UNIV\ unfolding has_ell2_norm_def by - then have \(\i. (x i)\<^sup>2) abs_summable_on S\ using summable_on_subset_banach by blast then have \(\xa. (if xa \ S then x xa else 0)\<^sup>2) abs_summable_on UNIV\ apply (rule summable_on_cong_neutral[THEN iffD1, rotated -1]) by auto then show \has_ell2_norm (\i. if i \ S then x i else 0)\ unfolding has_ell2_norm_def by - qed lemma trunc_ell2_empty[simp]: \trunc_ell2 {} x = 0\ apply transfer by simp lemma norm_id_minus_trunc_ell2: \(norm (x - trunc_ell2 S x))^2 = (norm x)^2 - (norm (trunc_ell2 S x))^2\ proof- have \Rep_ell2 (trunc_ell2 S x) i = 0 \ Rep_ell2 (x - trunc_ell2 S x) i = 0\ for i apply transfer by auto hence \\ (trunc_ell2 S x), (x - trunc_ell2 S x) \ = 0\ using ell2_pointwise_ortho by blast hence \(norm x)^2 = (norm (trunc_ell2 S x))^2 + (norm (x - trunc_ell2 S x))^2\ using pythagorean_theorem by fastforce thus ?thesis by simp qed lemma norm_trunc_ell2_finite: \finite S \ (norm (trunc_ell2 S x)) = sqrt ((sum (\i. (cmod (Rep_ell2 x i))\<^sup>2)) S)\ proof- assume \finite S\ moreover have \\ i. i \ S \ Rep_ell2 ((trunc_ell2 S x)) i = 0\ by (simp add: trunc_ell2.rep_eq) ultimately have \(norm (trunc_ell2 S x)) = sqrt ((sum (\i. (cmod (Rep_ell2 ((trunc_ell2 S x)) i))\<^sup>2)) S)\ using ell2_norm_finite_support by blast moreover have \\ i. i \ S \ Rep_ell2 ((trunc_ell2 S x)) i = Rep_ell2 x i\ by (simp add: trunc_ell2.rep_eq) ultimately show ?thesis by simp qed lemma trunc_ell2_lim_at_UNIV: \((\S. trunc_ell2 S \) \ \) (finite_subsets_at_top UNIV)\ proof - define f where \f i = (cmod (Rep_ell2 \ i))\<^sup>2\ for i have has: \has_ell2_norm (Rep_ell2 \)\ using Rep_ell2 by blast then have summable: "f abs_summable_on UNIV" by (smt (verit, del_insts) f_def has_ell2_norm_def norm_ge_zero norm_power real_norm_def summable_on_cong) have \norm \ = (ell2_norm (Rep_ell2 \))\ apply transfer by simp also have \\ = sqrt (infsum f UNIV)\ by (simp add: ell2_norm_def f_def[symmetric]) finally have norm\: \norm \ = sqrt (infsum f UNIV)\ by - have norm_trunc: \norm (trunc_ell2 S \) = sqrt (sum f S)\ if \finite S\ for S using f_def that norm_trunc_ell2_finite by fastforce have \(sum f \ infsum f UNIV) (finite_subsets_at_top UNIV)\ using f_def[abs_def] infsum_tendsto local.summable by fastforce then have \((\S. sqrt (sum f S)) \ sqrt (infsum f UNIV)) (finite_subsets_at_top UNIV)\ using tendsto_real_sqrt by blast then have \((\S. norm (trunc_ell2 S \)) \ norm \) (finite_subsets_at_top UNIV)\ apply (subst tendsto_cong[where g=\\S. sqrt (sum f S)\]) by (auto simp add: eventually_finite_subsets_at_top_weakI norm_trunc norm\) then have \((\S. (norm (trunc_ell2 S \))\<^sup>2) \ (norm \)\<^sup>2) (finite_subsets_at_top UNIV)\ by (simp add: tendsto_power) then have \((\S. (norm \)\<^sup>2 - (norm (trunc_ell2 S \))\<^sup>2) \ 0) (finite_subsets_at_top UNIV)\ apply (rule tendsto_diff[where a=\(norm \)^2\ and b=\(norm \)^2\, simplified, rotated]) by auto then have \((\S. (norm (\ - trunc_ell2 S \))\<^sup>2) \ 0) (finite_subsets_at_top UNIV)\ unfolding norm_id_minus_trunc_ell2 by simp then have \((\S. norm (\ - trunc_ell2 S \)) \ 0) (finite_subsets_at_top UNIV)\ by auto then have \((\S. \ - trunc_ell2 S \) \ 0) (finite_subsets_at_top UNIV)\ by (rule tendsto_norm_zero_cancel) then show ?thesis apply (rule Lim_transform2[where f=\\_. \\, rotated]) by simp qed subsection \Kets and bras\ lift_definition ket :: "'a \ 'a ell2" is "\x y. if x=y then 1 else 0" by (rule has_ell2_norm_ket) abbreviation bra :: "'a \ (_,complex) cblinfun" where "bra i \ vector_to_cblinfun (ket i)*" for i instance ell2 :: (type) not_singleton proof standard have "ket undefined \ (0::'a ell2)" proof transfer show "(\y. if (undefined::'a) = y then 1::complex else 0) \ (\_. 0)" by (meson one_neq_zero) qed thus \\x y::'a ell2. x \ y\ by blast qed lemma cinner_ket_left: \\ket i, \\ = Rep_ell2 \ i\ apply (transfer fixing: i) apply (subst infsum_cong_neutral[where T=\{i}\]) by auto lemma cinner_ket_right: \\\, ket i\ = cnj (Rep_ell2 \ i)\ apply (transfer fixing: i) apply (subst infsum_cong_neutral[where T=\{i}\]) by auto lemma cinner_ket_eqI: assumes \\i. cinner (ket i) \ = cinner (ket i) \\ shows \\ = \\ by (metis Rep_ell2_inject assms cinner_ket_left ext) lemma norm_ket[simp]: "norm (ket i) = 1" apply transfer by (rule ell2_norm_ket) lemma cinner_ket_same[simp]: \\ket i, ket i\ = 1\ proof- have \norm (ket i) = 1\ by simp hence \sqrt (cmod \ket i, ket i\) = 1\ by (metis norm_eq_sqrt_cinner) hence \cmod \ket i, ket i\ = 1\ using real_sqrt_eq_1_iff by blast moreover have \\ket i, ket i\ = cmod \ket i, ket i\\ proof- have \\ket i, ket i\ \ \\ by (simp add: cinner_real) thus ?thesis by (metis cinner_ge_zero complex_of_real_cmod) qed ultimately show ?thesis by simp qed lemma orthogonal_ket[simp]: \is_orthogonal (ket i) (ket j) \ i \ j\ by (simp add: cinner_ket_left ket.rep_eq) lemma cinner_ket: \\ket i, ket j\ = (if i=j then 1 else 0)\ by (simp add: cinner_ket_left ket.rep_eq) lemma ket_injective[simp]: \ket i = ket j \ i = j\ by (metis cinner_ket one_neq_zero) lemma inj_ket[simp]: \inj ket\ by (simp add: inj_on_def) lemma trunc_ell2_ket_cspan: \trunc_ell2 S x \ (cspan (range ket))\ if \finite S\ proof (use that in induction) case empty then show ?case by (auto intro: complex_vector.span_zero) next case (insert a F) from insert.hyps have \trunc_ell2 (insert a F) x = trunc_ell2 F x + Rep_ell2 x a *\<^sub>C ket a\ apply (transfer fixing: F a) by auto with insert.IH show ?case by (simp add: complex_vector.span_add_eq complex_vector.span_base complex_vector.span_scale) qed lemma closed_cspan_range_ket[simp]: \closure (cspan (range ket)) = UNIV\ proof (intro set_eqI iffI UNIV_I closure_approachable[THEN iffD2] allI impI) fix \ :: \'a ell2\ fix e :: real assume \e > 0\ have \((\S. trunc_ell2 S \) \ \) (finite_subsets_at_top UNIV)\ by (rule trunc_ell2_lim_at_UNIV) then obtain F where \finite F\ and \dist (trunc_ell2 F \) \ < e\ apply (drule_tac tendstoD[OF _ \e > 0\]) by (auto dest: simp: eventually_finite_subsets_at_top) moreover have \trunc_ell2 F \ \ cspan (range ket)\ using \finite F\ trunc_ell2_ket_cspan by blast ultimately show \\\\cspan (range ket). dist \ \ < e\ by auto qed lemma ccspan_range_ket[simp]: "ccspan (range ket) = (top::('a ell2 ccsubspace))" proof- have \closure (complex_vector.span (range ket)) = (UNIV::'a ell2 set)\ using Complex_L2.closed_cspan_range_ket by blast thus ?thesis by (simp add: ccspan.abs_eq top_ccsubspace.abs_eq) qed lemma cspan_range_ket_finite[simp]: "cspan (range ket :: 'a::finite ell2 set) = UNIV" by (metis closed_cspan_range_ket closure_finite_cspan finite_class.finite_UNIV finite_imageI) instance ell2 :: (finite) cfinite_dim proof define basis :: \'a ell2 set\ where \basis = range ket\ have \finite basis\ unfolding basis_def by simp moreover have \cspan basis = UNIV\ by (simp add: basis_def) ultimately show \\basis::'a ell2 set. finite basis \ cspan basis = UNIV\ by auto qed instantiation ell2 :: (enum) onb_enum begin definition "canonical_basis_ell2 = map ket Enum.enum" instance proof show "distinct (canonical_basis::'a ell2 list)" proof- have \finite (UNIV::'a set)\ by simp have \distinct (enum_class.enum::'a list)\ using enum_distinct by blast moreover have \inj_on ket (set enum_class.enum)\ by (meson inj_onI ket_injective) ultimately show ?thesis unfolding canonical_basis_ell2_def using distinct_map by blast qed show "is_ortho_set (set (canonical_basis::'a ell2 list))" apply (auto simp: canonical_basis_ell2_def enum_UNIV) by (smt (z3) norm_ket f_inv_into_f is_ortho_set_def orthogonal_ket norm_zero) show "cindependent (set (canonical_basis::'a ell2 list))" apply (auto simp: canonical_basis_ell2_def enum_UNIV) by (smt (verit, best) norm_ket f_inv_into_f is_ortho_set_def is_ortho_set_cindependent orthogonal_ket norm_zero) show "cspan (set (canonical_basis::'a ell2 list)) = UNIV" by (auto simp: canonical_basis_ell2_def enum_UNIV) show "norm (x::'a ell2) = 1" if "(x::'a ell2) \ set canonical_basis" for x :: "'a ell2" using that unfolding canonical_basis_ell2_def by auto qed end lemma canonical_basis_length_ell2[code_unfold, simp]: "length (canonical_basis ::'a::enum ell2 list) = CARD('a)" unfolding canonical_basis_ell2_def apply simp using card_UNIV_length_enum by metis lemma ket_canonical_basis: "ket x = canonical_basis ! enum_idx x" proof- have "x = (enum_class.enum::'a list) ! enum_idx x" using enum_idx_correct[where i = x] by simp hence p1: "ket x = ket ((enum_class.enum::'a list) ! enum_idx x)" by simp have "enum_idx x < length (enum_class.enum::'a list)" using enum_idx_bound[where x = x]. hence "(map ket (enum_class.enum::'a list)) ! enum_idx x = ket ((enum_class.enum::'a list) ! enum_idx x)" by auto thus ?thesis unfolding canonical_basis_ell2_def using p1 by auto qed lemma clinear_equal_ket: fixes f g :: \'a::finite ell2 \ _\ assumes \clinear f\ assumes \clinear g\ assumes \\i. f (ket i) = g (ket i)\ shows \f = g\ apply (rule ext) apply (rule complex_vector.linear_eq_on_span[where f=f and g=g and B=\range ket\]) using assms by auto lemma equal_ket: fixes A B :: \('a ell2, 'b::complex_normed_vector) cblinfun\ assumes \\ x. cblinfun_apply A (ket x) = cblinfun_apply B (ket x)\ shows \A = B\ apply (rule cblinfun_eq_gen_eqI[where G=\range ket\]) using assms by auto lemma antilinear_equal_ket: fixes f g :: \'a::finite ell2 \ _\ assumes \antilinear f\ assumes \antilinear g\ assumes \\i. f (ket i) = g (ket i)\ shows \f = g\ proof - have [simp]: \clinear (f \ from_conjugate_space)\ apply (rule antilinear_o_antilinear) using assms by (simp_all add: antilinear_from_conjugate_space) have [simp]: \clinear (g \ from_conjugate_space)\ apply (rule antilinear_o_antilinear) using assms by (simp_all add: antilinear_from_conjugate_space) have [simp]: \cspan (to_conjugate_space ` (range ket :: 'a ell2 set)) = UNIV\ by simp have "f o from_conjugate_space = g o from_conjugate_space" apply (rule ext) apply (rule complex_vector.linear_eq_on_span[where f="f o from_conjugate_space" and g="g o from_conjugate_space" and B=\to_conjugate_space ` range ket\]) apply (simp, simp) using assms(3) by (auto simp: to_conjugate_space_inverse) then show "f = g" by (smt (verit) UNIV_I from_conjugate_space_inverse surj_def surj_fun_eq to_conjugate_space_inject) qed lemma cinner_ket_adjointI: fixes F::"'a ell2 \\<^sub>C\<^sub>L _" and G::"'b ell2 \\<^sub>C\<^sub>L_" assumes "\ i j. \F *\<^sub>V ket i, ket j\ = \ket i, G *\<^sub>V ket j\" shows "F = G*" proof - from assms have \(F *\<^sub>V x) \\<^sub>C y = x \\<^sub>C (G *\<^sub>V y)\ if \x \ range ket\ and \y \ range ket\ for x y using that by auto then have \(F *\<^sub>V x) \\<^sub>C y = x \\<^sub>C (G *\<^sub>V y)\ if \x \ range ket\ for x y apply (rule bounded_clinear_eq_on[where G=\range ket\ and t=y, rotated 2]) using that by (auto intro!: bounded_linear_intros) then have \(F *\<^sub>V x) \\<^sub>C y = x \\<^sub>C (G *\<^sub>V y)\ for x y apply (rule bounded_antilinear_eq_on[where G=\range ket\ and t=x, rotated 2]) by (auto intro!: bounded_linear_intros) then show ?thesis by (rule adjoint_eqI) qed lemma ket_nonzero[simp]: "ket i \ 0" using norm_ket[of i] by force lemma cindependent_ket: "cindependent (range (ket::'a\_))" proof- define S where "S = range (ket::'a\_)" have "is_ortho_set S" unfolding S_def is_ortho_set_def by auto moreover have "0 \ S" unfolding S_def using ket_nonzero by (simp add: image_iff) ultimately show ?thesis using is_ortho_set_cindependent[where A = S] unfolding S_def by blast qed lemma cdim_UNIV_ell2[simp]: \cdim (UNIV::'a::finite ell2 set) = CARD('a)\ apply (subst cspan_range_ket_finite[symmetric]) by (metis card_image cindependent_ket complex_vector.dim_span_eq_card_independent inj_ket) lemma is_ortho_set_ket[simp]: \is_ortho_set (range ket)\ using is_ortho_set_def by fastforce subsection \Butterflies\ lemma cspan_butterfly_ket: \cspan {butterfly (ket i) (ket j)| (i::'b::finite) (j::'a::finite). True} = UNIV\ proof - have *: \{butterfly (ket i) (ket j)| (i::'b::finite) (j::'a::finite). True} = {butterfly a b |a b. a \ range ket \ b \ range ket}\ by auto show ?thesis apply (subst *) apply (rule cspan_butterfly_UNIV) by auto qed lemma cindependent_butterfly_ket: \cindependent {butterfly (ket i) (ket j)| (i::'b) (j::'a). True}\ proof - have *: \{butterfly (ket i) (ket j)| (i::'b) (j::'a). True} = {butterfly a b |a b. a \ range ket \ b \ range ket}\ by auto show ?thesis apply (subst *) apply (rule cindependent_butterfly) by auto qed lemma clinear_eq_butterfly_ketI: fixes F G :: \('a::finite ell2 \\<^sub>C\<^sub>L 'b::finite ell2) \ 'c::complex_vector\ assumes "clinear F" and "clinear G" assumes "\i j. F (butterfly (ket i) (ket j)) = G (butterfly (ket i) (ket j))" shows "F = G" apply (rule complex_vector.linear_eq_on_span[where f=F, THEN ext, rotated 3]) apply (subst cspan_butterfly_ket) using assms by auto lemma sum_butterfly_ket[simp]: \(\(i::'a::finite)\UNIV. butterfly (ket i) (ket i)) = id_cblinfun\ apply (rule equal_ket) apply (subst complex_vector.linear_sum[where f=\\y. y *\<^sub>V ket _\]) apply (auto simp add: scaleC_cblinfun.rep_eq cblinfun.add_left clinearI butterfly_def cblinfun_compose_image cinner_ket) apply (subst sum.mono_neutral_cong_right[where S=\{_}\]) by auto subsection \One-dimensional spaces\ instantiation ell2 :: ("{enum,CARD_1}") one_dim begin text \Note: enum is not needed logically, but without it this instantiation clashes with \instantiation ell2 :: (enum) onb_enum\\ instance proof show "canonical_basis = [1::'a ell2]" unfolding canonical_basis_ell2_def apply transfer by (simp add: enum_CARD_1[of undefined]) show "a *\<^sub>C 1 * b *\<^sub>C 1 = (a * b) *\<^sub>C (1::'a ell2)" for a b apply (transfer fixing: a b) by simp show "x / y = x * inverse y" for x y :: "'a ell2" by (simp add: divide_inverse) show "inverse (c *\<^sub>C 1) = inverse c *\<^sub>C (1::'a ell2)" for c :: complex apply transfer by auto qed end subsection \Classical operators\ text \We call an operator mapping \<^term>\ket x\ to \<^term>\ket (\ x)\ or \<^term>\0\ "classical". (The meaning is inspired by the fact that in quantum mechanics, such operators usually correspond to operations with classical interpretation (such as Pauli-X, CNOT, measurement in the computational basis, etc.))\ definition classical_operator :: "('a\'b option) \ 'a ell2 \\<^sub>C\<^sub>L'b ell2" where "classical_operator \ = (let f = (\t. (case \ (inv (ket::'a\_) t) of None \ (0::'b ell2) | Some i \ ket i)) in cblinfun_extension (range (ket::'a\_)) f)" definition "classical_operator_exists \ \ cblinfun_extension_exists (range ket) (\t. case \ (inv ket t) of None \ 0 | Some i \ ket i)" lemma classical_operator_existsI: assumes "\x. B *\<^sub>V (ket x) = (case \ x of Some i \ ket i | None \ 0)" shows "classical_operator_exists \" unfolding classical_operator_exists_def apply (rule cblinfun_extension_existsI[of _ B]) using assms by (auto simp: inv_f_f[OF inj_ket]) lemma classical_operator_exists_inj: assumes "inj_map \" shows "classical_operator_exists \" proof - define f where \f t = (case \ (inv ket t) of None \ 0 | Some x \ ket x)\ for t define g where \g = cconstruct (range ket) f\ have g_f: \g (ket x) = f (ket x)\ for x unfolding g_def apply (rule complex_vector.construct_basis) using cindependent_ket by auto have \clinear g\ unfolding g_def apply (rule complex_vector.linear_construct) using cindependent_ket by blast then have \g (x + y) = g x + g y\ if \x \ cspan (range ket)\ and \y \ cspan (range ket)\ for x y using clinear_iff by blast moreover from \clinear g\ have \g (c *\<^sub>C x) = c *\<^sub>C g x\ if \x \ cspan (range ket)\ for x c by (simp add: complex_vector.linear_scale) moreover have \norm (g x) \ norm x\ if \x \ cspan (range ket)\ for x proof - from that obtain t r where x_sum: \x = (\a\t. r a *\<^sub>C a)\ and \finite t\ and \t \ range ket\ unfolding complex_vector.span_explicit by auto then obtain T where tT: \t = ket ` T\ and [simp]: \finite T\ by (meson finite_subset_image) define R where \R i = r (ket i)\ for i have x_sum: \x = (\i\T. R i *\<^sub>C ket i)\ unfolding R_def tT x_sum apply (rule sum.reindex_cong) by (auto simp add: inj_on_def) define T' \' \T \R where \T' = {i\T. \ i \ None}\ and \\' = the o \\ and \\T = \' ` T'\ and \\R i = R (inv_into T' \' i)\ for i have \inj_on \' T'\ by (smt (z3) T'_def \'_def assms comp_apply inj_map_def inj_on_def mem_Collect_eq option.expand) have [simp]: \finite \T\ by (simp add: T'_def \T_def) have \g x = (\i\T. R i *\<^sub>C g (ket i))\ by (smt (verit, ccfv_threshold) \clinear g\ complex_vector.linear_scale complex_vector.linear_sum sum.cong x_sum) also have \\ = (\i\T. R i *\<^sub>C f (ket i))\ using g_f by presburger also have \\ = (\i\T. R i *\<^sub>C (case \ i of None \ 0 | Some x \ ket x))\ unfolding f_def by auto also have \\ = (\i\T'. R i *\<^sub>C ket (\' i))\ apply (rule sum.mono_neutral_cong_right) unfolding T'_def \'_def by auto also have \\ = (\i\\' ` T'. R (inv_into T' \' i) *\<^sub>C ket i)\ apply (subst sum.reindex) using \inj_on \' T'\ apply assumption apply (rule sum.cong) using \inj_on \' T'\ by auto finally have gx_sum: \g x = (\i\\T. \R i *\<^sub>C ket i)\ using \R_def \T_def by auto have \(norm (g x))\<^sup>2 = (\a\\T. (cmod (\R a))\<^sup>2)\ unfolding gx_sum apply (subst pythagorean_theorem_sum) by auto also have \\ = (\i\T'. (cmod (R i))\<^sup>2)\ unfolding \R_def \T_def apply (subst sum.reindex) using \inj_on \' T'\ apply assumption apply (rule sum.cong) using \inj_on \' T'\ by auto also have \\ \ (\a\T. (cmod (R a))\<^sup>2)\ apply (rule sum_mono2) using T'_def by auto also have \\ = (norm x)\<^sup>2\ unfolding x_sum apply (subst pythagorean_theorem_sum) using \finite T\ by auto finally show \norm (g x) \ norm x\ by auto qed ultimately have \cblinfun_extension_exists (cspan (range ket)) g\ apply (rule_tac cblinfun_extension_exists_bounded_dense[where B=1]) by auto then have \cblinfun_extension_exists (range ket) f\ by (metis (mono_tags, opaque_lifting) g_f cblinfun_extension_apply cblinfun_extension_existsI complex_vector.span_base rangeE) then show \classical_operator_exists \\ unfolding classical_operator_exists_def f_def by simp qed lemma classical_operator_exists_finite[simp]: "classical_operator_exists (\ :: _::finite \ _)" unfolding classical_operator_exists_def apply (rule cblinfun_extension_exists_finite_dim) using cindependent_ket apply blast using finite_class.finite_UNIV finite_imageI closed_cspan_range_ket closure_finite_cspan by blast lemma classical_operator_ket: assumes "classical_operator_exists \" shows "(classical_operator \) *\<^sub>V (ket x) = (case \ x of Some i \ ket i | None \ 0)" unfolding classical_operator_def using f_inv_into_f ket_injective rangeI by (metis assms cblinfun_extension_apply classical_operator_exists_def) lemma classical_operator_ket_finite: "(classical_operator \) *\<^sub>V (ket (x::'a::finite)) = (case \ x of Some i \ ket i | None \ 0)" by (rule classical_operator_ket, simp) lemma classical_operator_adjoint[simp]: fixes \ :: "'a \ 'b option" assumes a1: "inj_map \" shows "(classical_operator \)* = classical_operator (inv_map \)" proof- define F where "F = classical_operator (inv_map \)" define G where "G = classical_operator \" have "\F *\<^sub>V ket i, ket j\ = \ket i, G *\<^sub>V ket j\" for i j proof- have w1: "(classical_operator (inv_map \)) *\<^sub>V (ket i) = (case inv_map \ i of Some k \ ket k | None \ 0)" by (simp add: classical_operator_ket classical_operator_exists_inj) have w2: "(classical_operator \) *\<^sub>V (ket j) = (case \ j of Some k \ ket k | None \ 0)" by (simp add: assms classical_operator_ket classical_operator_exists_inj) have "\F *\<^sub>V ket i, ket j\ = \classical_operator (inv_map \) *\<^sub>V ket i, ket j\" unfolding F_def by blast also have "\ = \(case inv_map \ i of Some k \ ket k | None \ 0), ket j\" using w1 by simp also have "\ = \ket i, (case \ j of Some k \ ket k | None \ 0)\" proof(induction "inv_map \ i") case None hence pi1: "None = inv_map \ i". show ?case proof (induction "\ j") case None thus ?case using pi1 by auto next case (Some c) have "c \ i" proof(rule classical) assume "\(c \ i)" hence "c = i" by blast hence "inv_map \ c = inv_map \ i" by simp hence "inv_map \ c = None" by (simp add: pi1) moreover have "inv_map \ c = Some j" using Some.hyps unfolding inv_map_def apply auto by (metis a1 f_inv_into_f inj_map_def option.distinct(1) rangeI) ultimately show ?thesis by simp qed thus ?thesis by (metis None.hyps Some.hyps cinner_zero_left orthogonal_ket option.simps(4) option.simps(5)) qed next case (Some d) hence s1: "Some d = inv_map \ i". show "\case inv_map \ i of None \ 0 | Some a \ ket a, ket j\ = \ket i, case \ j of None \ 0 | Some a \ ket a\" proof(induction "\ j") case None have "d \ j" proof(rule classical) assume "\(d \ j)" hence "d = j" by blast hence "\ d = \ j" by simp hence "\ d = None" by (simp add: None.hyps) moreover have "\ d = Some i" using Some.hyps unfolding inv_map_def apply auto by (metis f_inv_into_f option.distinct(1) option.inject) ultimately show ?thesis by simp qed thus ?case by (metis None.hyps Some.hyps cinner_zero_right orthogonal_ket option.case_eq_if option.simps(5)) next case (Some c) hence s2: "\ j = Some c" by simp have "\ket d, ket j\ = \ket i, ket c\" proof(cases "\ j = Some i") case True hence ij: "Some j = inv_map \ i" unfolding inv_map_def apply auto apply (metis a1 f_inv_into_f inj_map_def option.discI range_eqI) by (metis range_eqI) have "i = c" using True s2 by auto moreover have "j = d" by (metis option.inject s1 ij) ultimately show ?thesis by (simp add: cinner_ket_same) next case False moreover have "\ d = Some i" using s1 unfolding inv_map_def by (metis f_inv_into_f option.distinct(1) option.inject) ultimately have "j \ d" by auto moreover have "i \ c" using False s2 by auto ultimately show ?thesis by (metis orthogonal_ket) qed hence "\case Some d of None \ 0 | Some a \ ket a, ket j\ = \ket i, case Some c of None \ 0 | Some a \ ket a\" by simp thus "\case inv_map \ i of None \ 0 | Some a \ ket a, ket j\ = \ket i, case \ j of None \ 0 | Some a \ ket a\" by (simp add: Some.hyps s1) qed qed also have "\ = \ket i, classical_operator \ *\<^sub>V ket j\" by (simp add: w2) also have "\ = \ket i, G *\<^sub>V ket j\" unfolding G_def by blast finally show ?thesis . qed hence "G* = F" using cinner_ket_adjointI by auto thus ?thesis unfolding G_def F_def . qed lemma fixes \::"'b \ 'c option" and \::"'a \ 'b option" assumes "classical_operator_exists \" assumes "classical_operator_exists \" shows classical_operator_exists_comp[simp]: "classical_operator_exists (\ \\<^sub>m \)" and classical_operator_mult[simp]: "classical_operator \ o\<^sub>C\<^sub>L classical_operator \ = classical_operator (\ \\<^sub>m \)" proof - define C\ C\ C\\ where "C\ = classical_operator \" and "C\ = classical_operator \" and "C\\ = classical_operator (\ \\<^sub>m \)" have C\x: "C\ *\<^sub>V (ket x) = (case \ x of Some i \ ket i | None \ 0)" for x unfolding C\_def using \classical_operator_exists \\ by (rule classical_operator_ket) have C\x: "C\ *\<^sub>V (ket x) = (case \ x of Some i \ ket i | None \ 0)" for x unfolding C\_def using \classical_operator_exists \\ by (rule classical_operator_ket) have C\\x': "(C\ o\<^sub>C\<^sub>L C\) *\<^sub>V (ket x) = (case (\ \\<^sub>m \) x of Some i \ ket i | None \ 0)" for x apply (simp add: scaleC_cblinfun.rep_eq C\x) apply (cases "\ x") by (auto simp: C\x) thus \classical_operator_exists (\ \\<^sub>m \)\ by (rule classical_operator_existsI) hence "C\\ *\<^sub>V (ket x) = (case (\ \\<^sub>m \) x of Some i \ ket i | None \ 0)" for x unfolding C\\_def by (rule classical_operator_ket) with C\\x' have "(C\ o\<^sub>C\<^sub>L C\) *\<^sub>V (ket x) = C\\ *\<^sub>V (ket x)" for x by simp thus "C\ o\<^sub>C\<^sub>L C\ = C\\" by (simp add: equal_ket) qed lemma classical_operator_Some[simp]: "classical_operator (Some::'a\_) = id_cblinfun" proof- have "(classical_operator Some) *\<^sub>V (ket i) = id_cblinfun *\<^sub>V (ket i)" for i::'a apply (subst classical_operator_ket) apply (rule classical_operator_exists_inj) by auto thus ?thesis using equal_ket[where A = "classical_operator (Some::'a \ _ option)" and B = "id_cblinfun::'a ell2 \\<^sub>C\<^sub>L _"] by blast qed lemma isometry_classical_operator[simp]: fixes \::"'a \ 'b" assumes a1: "inj \" shows "isometry (classical_operator (Some o \))" proof - have b0: "inj_map (Some \ \)" by (simp add: a1) have b0': "inj_map (inv_map (Some \ \))" by simp have b1: "inv_map (Some \ \) \\<^sub>m (Some \ \) = Some" apply (rule ext) unfolding inv_map_def o_def using assms unfolding inj_def inv_def by auto have b3: "classical_operator (inv_map (Some \ \)) o\<^sub>C\<^sub>L classical_operator (Some \ \) = classical_operator (inv_map (Some \ \) \\<^sub>m (Some \ \))" by (metis b0 b0' b1 classical_operator_Some classical_operator_exists_inj classical_operator_mult) show ?thesis unfolding isometry_def apply (subst classical_operator_adjoint) using b0 by (auto simp add: b1 b3) qed lemma unitary_classical_operator[simp]: fixes \::"'a \ 'b" assumes a1: "bij \" shows "unitary (classical_operator (Some o \))" proof (unfold unitary_def, rule conjI) have "inj \" using a1 bij_betw_imp_inj_on by auto hence "isometry (classical_operator (Some o \))" by simp hence "classical_operator (Some \ \)* o\<^sub>C\<^sub>L classical_operator (Some \ \) = id_cblinfun" unfolding isometry_def by simp thus \classical_operator (Some \ \)* o\<^sub>C\<^sub>L classical_operator (Some \ \) = id_cblinfun\ by simp next have "inj \" by (simp add: assms bij_is_inj) have comp: "Some \ \ \\<^sub>m inv_map (Some \ \) = Some" apply (rule ext) unfolding inv_map_def o_def map_comp_def unfolding inv_def apply auto apply (metis \inj \\ inv_def inv_f_f) using bij_def image_iff range_eqI by (metis a1) have "classical_operator (Some \ \) o\<^sub>C\<^sub>L classical_operator (Some \ \)* = classical_operator (Some \ \) o\<^sub>C\<^sub>L classical_operator (inv_map (Some \ \))" by (simp add: \inj \\) also have "\ = classical_operator ((Some \ \) \\<^sub>m (inv_map (Some \ \)))" by (simp add: \inj \\ classical_operator_exists_inj) also have "\ = classical_operator (Some::'b\_)" using comp by simp also have "\ = (id_cblinfun:: 'b ell2 \\<^sub>C\<^sub>L _)" by simp finally show "classical_operator (Some \ \) o\<^sub>C\<^sub>L classical_operator (Some \ \)* = id_cblinfun". qed - +unbundle no_lattice_syntax unbundle no_cblinfun_notation end diff --git a/thys/Complex_Bounded_Operators/Complex_Vector_Spaces.thy b/thys/Complex_Bounded_Operators/Complex_Vector_Spaces.thy --- a/thys/Complex_Bounded_Operators/Complex_Vector_Spaces.thy +++ b/thys/Complex_Bounded_Operators/Complex_Vector_Spaces.thy @@ -1,2820 +1,2824 @@ section \\Complex_Vector_Spaces\ -- Complex Vector Spaces\ (* Authors: Dominique Unruh, University of Tartu, unruh@ut.ee Jose Manuel Rodriguez Caballero, University of Tartu, jose.manuel.rodriguez.caballero@ut.ee *) theory Complex_Vector_Spaces imports "HOL-Analysis.Elementary_Topology" "HOL-Analysis.Operator_Norm" "HOL-Analysis.Elementary_Normed_Spaces" "HOL-Library.Set_Algebras" "HOL-Analysis.Starlike" "HOL-Types_To_Sets.Types_To_Sets" "Complex_Bounded_Operators.Extra_Vector_Spaces" "Complex_Bounded_Operators.Extra_Ordered_Fields" "Complex_Bounded_Operators.Extra_Lattice" "Complex_Bounded_Operators.Extra_General" Complex_Vector_Spaces0 begin bundle notation_norm begin notation norm ("\_\") end +unbundle lattice_syntax + subsection \Misc\ lemma (in scaleC) scaleC_real: assumes "r\\" shows "r *\<^sub>C x = Re r *\<^sub>R x" unfolding scaleR_scaleC using assms by simp lemma of_complex_of_real_eq [simp]: "of_complex (of_real n) = of_real n" unfolding of_complex_def of_real_def unfolding scaleR_scaleC by simp lemma Complexs_of_real [simp]: "of_real r \ \" unfolding Complexs_def of_real_def of_complex_def apply (subst scaleR_scaleC) by simp lemma Reals_in_Complexs: "\ \ \" unfolding Reals_def by auto lemma (in clinear) "linear f" apply standard by (simp_all add: add scaleC scaleR_scaleC) lemma (in bounded_clinear) bounded_linear: "bounded_linear f" by (simp add: add bounded bounded_linear.intro bounded_linear_axioms.intro linearI scaleC scaleR_scaleC) lemma clinear_times: "clinear (\x. c * x)" for c :: "'a::complex_algebra" by (auto simp: clinearI distrib_left) lemma (in clinear) linear: shows \linear f\ by (simp add: add linearI scaleC scaleR_scaleC) lemma bounded_clinearI: assumes \\b1 b2. f (b1 + b2) = f b1 + f b2\ assumes \\r b. f (r *\<^sub>C b) = r *\<^sub>C f b\ assumes \\x. norm (f x) \ norm x * K\ shows "bounded_clinear f" using assms by (auto intro!: exI bounded_clinear.intro clinearI simp: bounded_clinear_axioms_def) lemma bounded_clinear_id[simp]: \bounded_clinear id\ by (simp add: id_def) (* The following would be a natural inclusion of locales, but unfortunately it leads to name conflicts upon interpretation of bounded_cbilinear *) (* sublocale bounded_cbilinear \ bounded_bilinear by (rule bounded_bilinear) *) definition cbilinear :: \('a::complex_vector \ 'b::complex_vector \ 'c::complex_vector) \ bool\ where \cbilinear = (\ f. (\ y. clinear (\ x. f x y)) \ (\ x. clinear (\ y. f x y)) )\ lemma cbilinear_add_left: assumes \cbilinear f\ shows \f (a + b) c = f a c + f b c\ by (smt (verit, del_insts) assms cbilinear_def complex_vector.linear_add) lemma cbilinear_add_right: assumes \cbilinear f\ shows \f a (b + c) = f a b + f a c\ by (smt (verit, del_insts) assms cbilinear_def complex_vector.linear_add) lemma cbilinear_times: fixes g' :: \'a::complex_vector \ complex\ and g :: \'b::complex_vector \ complex\ assumes \\ x y. h x y = (g' x)*(g y)\ and \clinear g\ and \clinear g'\ shows \cbilinear h\ proof - have w1: "h (b1 + b2) y = h b1 y + h b2 y" for b1 :: 'a and b2 :: 'a and y proof- have \h (b1 + b2) y = g' (b1 + b2) * g y\ using \\ x y. h x y = (g' x)*(g y)\ by auto also have \\ = (g' b1 + g' b2) * g y\ using \clinear g'\ unfolding clinear_def by (simp add: assms(3) complex_vector.linear_add) also have \\ = g' b1 * g y + g' b2 * g y\ by (simp add: ring_class.ring_distribs(2)) also have \\ = h b1 y + h b2 y\ using assms(1) by auto finally show ?thesis by blast qed have w2: "h (r *\<^sub>C b) y = r *\<^sub>C h b y" for r :: complex and b :: 'a and y proof- have \h (r *\<^sub>C b) y = g' (r *\<^sub>C b) * g y\ by (simp add: assms(1)) also have \\ = r *\<^sub>C (g' b * g y)\ by (simp add: assms(3) complex_vector.linear_scale) also have \\ = r *\<^sub>C (h b y)\ by (simp add: assms(1)) finally show ?thesis by blast qed have "clinear (\x. h x y)" for y :: 'b unfolding clinear_def by (meson clinearI clinear_def w1 w2) hence t2: "\y. clinear (\x. h x y)" by simp have v1: "h x (b1 + b2) = h x b1 + h x b2" for b1 :: 'b and b2 :: 'b and x proof- have \h x (b1 + b2) = g' x * g (b1 + b2)\ using \\ x y. h x y = (g' x)*(g y)\ by auto also have \\ = g' x * (g b1 + g b2)\ using \clinear g'\ unfolding clinear_def by (simp add: assms(2) complex_vector.linear_add) also have \\ = g' x * g b1 + g' x * g b2\ by (simp add: ring_class.ring_distribs(1)) also have \\ = h x b1 + h x b2\ using assms(1) by auto finally show ?thesis by blast qed have v2: "h x (r *\<^sub>C b) = r *\<^sub>C h x b" for r :: complex and b :: 'b and x proof- have \h x (r *\<^sub>C b) = g' x * g (r *\<^sub>C b)\ by (simp add: assms(1)) also have \\ = r *\<^sub>C (g' x * g b)\ by (simp add: assms(2) complex_vector.linear_scale) also have \\ = r *\<^sub>C (h x b)\ by (simp add: assms(1)) finally show ?thesis by blast qed have "Vector_Spaces.linear (*\<^sub>C) (*\<^sub>C) (h x)" for x :: 'a using v1 v2 by (meson clinearI clinear_def) hence t1: "\x. clinear (h x)" unfolding clinear_def by simp show ?thesis unfolding cbilinear_def by (simp add: t1 t2) qed lemma csubspace_is_subspace: "csubspace A \ subspace A" apply (rule subspaceI) by (auto simp: complex_vector.subspace_def scaleR_scaleC) lemma span_subset_cspan: "span A \ cspan A" unfolding span_def complex_vector.span_def by (simp add: csubspace_is_subspace hull_antimono) lemma cindependent_implies_independent: assumes "cindependent (S::'a::complex_vector set)" shows "independent S" using assms unfolding dependent_def complex_vector.dependent_def using span_subset_cspan by blast lemma cspan_singleton: "cspan {x} = {\ *\<^sub>C x| \. True}" proof - have \cspan {x} = {y. y\cspan {x}}\ by auto also have \\ = {\ *\<^sub>C x| \. True}\ apply (subst complex_vector.span_breakdown_eq) by auto finally show ?thesis by - qed lemma cspan_as_span: "cspan (B::'a::complex_vector set) = span (B \ scaleC \ ` B)" proof auto let ?cspan = complex_vector.span let ?rspan = real_vector.span fix \ assume cspan: "\ \ ?cspan B" have "\B' r. finite B' \ B' \ B \ \ = (\b\B'. r b *\<^sub>C b)" using complex_vector.span_explicit[of B] cspan by auto then obtain B' r where "finite B'" and "B' \ B" and \_explicit: "\ = (\b\B'. r b *\<^sub>C b)" by atomize_elim define R where "R = B \ scaleC \ ` B" have x2: "(case x of (b, i) \ if i then Im (r b) *\<^sub>R \ *\<^sub>C b else Re (r b) *\<^sub>R b) \ span (B \ (*\<^sub>C) \ ` B)" if "x \ B' \ (UNIV::bool set)" for x :: "'a \ bool" using that \B' \ B\ by (auto simp add: real_vector.span_base real_vector.span_scale subset_iff) have x1: "\ = (\x\B'. \i\UNIV. if i then Im (r x) *\<^sub>R \ *\<^sub>C x else Re (r x) *\<^sub>R x)" if "\b. r b *\<^sub>C b = Re (r b) *\<^sub>R b + Im (r b) *\<^sub>R \ *\<^sub>C b" using that by (simp add: UNIV_bool \_explicit) moreover have "r b *\<^sub>C b = Re (r b) *\<^sub>R b + Im (r b) *\<^sub>R \ *\<^sub>C b" for b using complex_eq scaleC_add_left scaleC_scaleC scaleR_scaleC by (metis (no_types, lifting) complex_of_real_i i_complex_of_real) ultimately have "\ = (\(b,i)\(B'\UNIV). if i then Im (r b) *\<^sub>R (\ *\<^sub>C b) else Re (r b) *\<^sub>R b)" by (simp add: sum.cartesian_product) also have "\ \ ?rspan R" unfolding R_def using x2 by (rule real_vector.span_sum) finally show "\ \ ?rspan R" by - next let ?cspan = complex_vector.span let ?rspan = real_vector.span define R where "R = B \ scaleC \ ` B" fix \ assume rspan: "\ \ ?rspan R" have "subspace {a. a \ cspan B}" by (rule real_vector.subspaceI, auto simp add: complex_vector.span_zero complex_vector.span_add_eq2 complex_vector.span_scale scaleR_scaleC) moreover have "x \ cspan B" if "x \ R" for x :: 'a using that R_def complex_vector.span_base complex_vector.span_scale by fastforce ultimately show "\ \ ?cspan B" using real_vector.span_induct rspan by blast qed lemma isomorphic_equal_cdim: assumes lin_f: \clinear f\ assumes inj_f: \inj_on f (cspan S)\ assumes im_S: \f ` S = T\ shows \cdim S = cdim T\ proof - obtain SB where SB_span: "cspan SB = cspan S" and indep_SB: \cindependent SB\ by (metis complex_vector.basis_exists complex_vector.span_mono complex_vector.span_span subset_antisym) with lin_f inj_f have indep_fSB: \cindependent (f ` SB)\ apply (rule_tac complex_vector.linear_independent_injective_image) by auto from lin_f have \cspan (f ` SB) = f ` cspan SB\ by (meson complex_vector.linear_span_image) also from SB_span lin_f have \\ = cspan T\ by (metis complex_vector.linear_span_image im_S) finally have \cdim T = card (f ` SB)\ using indep_fSB complex_vector.dim_eq_card by blast also have \\ = card SB\ apply (rule card_image) using inj_f by (metis SB_span complex_vector.linear_inj_on_span_iff_independent_image indep_fSB lin_f) also have \\ = cdim S\ using indep_SB SB_span by (metis complex_vector.dim_eq_card) finally show ?thesis by simp qed lemma cindependent_inter_scaleC_cindependent: assumes a1: "cindependent (B::'a::complex_vector set)" and a3: "c \ 1" shows "B \ (*\<^sub>C) c ` B = {}" proof (rule classical, cases \c = 0\) case True then show ?thesis using a1 by (auto simp add: complex_vector.dependent_zero) next case False assume "\(B \ (*\<^sub>C) c ` B = {})" hence "B \ (*\<^sub>C) c ` B \ {}" by blast then obtain x where u1: "x \ B \ (*\<^sub>C) c ` B" by blast then obtain b where u2: "x = b" and u3: "b\B" by blast then obtain b' where u2': "x = c *\<^sub>C b'" and u3': "b'\B" using u1 by blast have g1: "b = c *\<^sub>C b'" using u2 and u2' by simp hence "b \ complex_vector.span {b'}" using False by (simp add: complex_vector.span_base complex_vector.span_scale) hence "b = b'" by (metis u3' a1 complex_vector.dependent_def complex_vector.span_base complex_vector.span_scale insertE insert_Diff u2 u2' u3) hence "b' = c *\<^sub>C b'" using g1 by blast thus ?thesis by (metis a1 a3 complex_vector.dependent_zero complex_vector.scale_right_imp_eq mult_cancel_right2 scaleC_scaleC u3') qed lemma real_independent_from_complex_independent: assumes "cindependent (B::'a::complex_vector set)" defines "B' == ((*\<^sub>C) \ ` B)" shows "independent (B \ B')" proof (rule notI) assume \dependent (B \ B')\ then obtain T f0 x where [simp]: \finite T\ and \T \ B \ B'\ and f0_sum: \(\v\T. f0 v *\<^sub>R v) = 0\ and x: \x \ T\ and f0_x: \f0 x \ 0\ by (auto simp: real_vector.dependent_explicit) define f T1 T2 T' f' x' where \f v = (if v \ T then f0 v else 0)\ and \T1 = T \ B\ and \T2 = scaleC (-\) ` (T \ B')\ and \T' = T1 \ T2\ and \f' v = f v + \ * f (\ *\<^sub>C v)\ and \x' = (if x \ T1 then x else -\ *\<^sub>C x)\ for v have \B \ B' = {}\ by (simp add: assms cindependent_inter_scaleC_cindependent) have \T' \ B\ by (auto simp: T'_def T1_def T2_def B'_def) have [simp]: \finite T'\ \finite T1\ \finite T2\ by (auto simp add: T'_def T1_def T2_def) have f_sum: \(\v\T. f v *\<^sub>R v) = 0\ unfolding f_def using f0_sum by auto have f_x: \f x \ 0\ using f0_x x by (auto simp: f_def) have f'_sum: \(\v\T'. f' v *\<^sub>C v) = 0\ proof - have \(\v\T'. f' v *\<^sub>C v) = (\v\T'. complex_of_real (f v) *\<^sub>C v) + (\v\T'. (\ * complex_of_real (f (\ *\<^sub>C v))) *\<^sub>C v)\ by (auto simp: f'_def sum.distrib scaleC_add_left) also have \(\v\T'. complex_of_real (f v) *\<^sub>C v) = (\v\T1. f v *\<^sub>R v)\ (is \_ = ?left\) apply (auto simp: T'_def scaleR_scaleC intro!: sum.mono_neutral_cong_right) using T'_def T1_def \T' \ B\ f_def by auto also have \(\v\T'. (\ * complex_of_real (f (\ *\<^sub>C v))) *\<^sub>C v) = (\v\T2. (\ * complex_of_real (f (\ *\<^sub>C v))) *\<^sub>C v)\ (is \_ = ?right\) apply (auto simp: T'_def intro!: sum.mono_neutral_cong_right) by (smt (z3) B'_def IntE IntI T1_def T2_def \f \ \v. if v \ T then f0 v else 0\ add.inverse_inverse complex_vector.vector_space_axioms i_squared imageI mult_minus_left vector_space.vector_space_assms(3) vector_space.vector_space_assms(4)) also have \?right = (\v\T\B'. f v *\<^sub>R v)\ (is \_ = ?right\) apply (rule sum.reindex_cong[symmetric, where l=\scaleC \\]) apply (auto simp: T2_def image_image scaleR_scaleC) using inj_on_def by fastforce also have \?left + ?right = (\v\T. f v *\<^sub>R v)\ apply (subst sum.union_disjoint[symmetric]) using \B \ B' = {}\ \T \ B \ B'\ apply (auto simp: T1_def) by (metis Int_Un_distrib Un_Int_eq(4) sup.absorb_iff1) also have \\ = 0\ by (rule f_sum) finally show ?thesis by - qed have x': \x' \ T'\ using \T \ B \ B'\ x by (auto simp: x'_def T'_def T1_def T2_def) have f'_x': \f' x' \ 0\ using Complex_eq Complex_eq_0 f'_def f_x x'_def by auto from \finite T'\ \T' \ B\ f'_sum x' f'_x' have \cdependent B\ using complex_vector.independent_explicit_module by blast with assms show False by auto qed lemma crepresentation_from_representation: assumes a1: "cindependent B" and a2: "b \ B" and a3: "finite B" shows "crepresentation B \ b = (representation (B \ (*\<^sub>C) \ ` B) \ b) + \ *\<^sub>C (representation (B \ (*\<^sub>C) \ ` B) \ (\ *\<^sub>C b))" proof (cases "\ \ cspan B") define B' where "B' = B \ (*\<^sub>C) \ ` B" case True define r where "r v = real_vector.representation B' \ v" for v define r' where "r' v = real_vector.representation B' \ (\ *\<^sub>C v)" for v define f where "f v = r v + \ *\<^sub>C r' v" for v define g where "g v = crepresentation B \ v" for v have "(\v | g v \ 0. g v *\<^sub>C v) = \" unfolding g_def using Collect_cong Collect_mono_iff DiffD1 DiffD2 True a1 complex_vector.finite_representation complex_vector.sum_nonzero_representation_eq sum.mono_neutral_cong_left by fastforce moreover have "finite {v. g v \ 0}" unfolding g_def by (simp add: complex_vector.finite_representation) moreover have "v \ B" if "g v \ 0" for v using that unfolding g_def by (simp add: complex_vector.representation_ne_zero) ultimately have rep1: "(\v\B. g v *\<^sub>C v) = \" unfolding g_def using a3 True a1 complex_vector.sum_representation_eq by blast have l0': "inj ((*\<^sub>C) \::'a \'a)" unfolding inj_def by simp have l0: "inj ((*\<^sub>C) (- \)::'a \'a)" unfolding inj_def by simp have l1: "(*\<^sub>C) (- \) ` B \ B = {}" using cindependent_inter_scaleC_cindependent[where B=B and c = "- \"] by (metis Int_commute a1 add.inverse_inverse complex_i_not_one i_squared mult_cancel_left1 neg_equal_0_iff_equal) have l2: "B \ (*\<^sub>C) \ ` B = {}" by (simp add: a1 cindependent_inter_scaleC_cindependent) have rr1: "r (\ *\<^sub>C v) = r' v" for v unfolding r_def r'_def by simp have k1: "independent B'" unfolding B'_def using a1 real_independent_from_complex_independent by simp have "\ \ span B'" using B'_def True cspan_as_span by blast have "v \ B'" if "r v \ 0" for v unfolding r_def using r_def real_vector.representation_ne_zero that by auto have "finite B'" unfolding B'_def using a3 by simp have "(\v\B'. r v *\<^sub>R v) = \" unfolding r_def using True Real_Vector_Spaces.real_vector.sum_representation_eq[where B = B' and basis = B' and v = \] by (smt Real_Vector_Spaces.dependent_raw_def \\ \ Real_Vector_Spaces.span B'\ \finite B'\ equalityD2 k1) have d1: "(\v\B. r (\ *\<^sub>C v) *\<^sub>R (\ *\<^sub>C v)) = (\v\(*\<^sub>C) \ ` B. r v *\<^sub>R v)" using l0' by (metis (mono_tags, lifting) inj_eq inj_on_def sum.reindex_cong) have "(\v\B. (r v + \ * (r' v)) *\<^sub>C v) = (\v\B. r v *\<^sub>C v + (\ * r' v) *\<^sub>C v)" by (meson scaleC_left.add) also have "\ = (\v\B. r v *\<^sub>C v) + (\v\B. (\ * r' v) *\<^sub>C v)" using sum.distrib by fastforce also have "\ = (\v\B. r v *\<^sub>C v) + (\v\B. \ *\<^sub>C (r' v *\<^sub>C v))" by auto also have "\ = (\v\B. r v *\<^sub>R v) + (\v\B. \ *\<^sub>C (r (\ *\<^sub>C v) *\<^sub>R v))" unfolding r'_def r_def by (metis (mono_tags, lifting) scaleR_scaleC sum.cong) also have "\ = (\v\B. r v *\<^sub>R v) + (\v\B. r (\ *\<^sub>C v) *\<^sub>R (\ *\<^sub>C v))" by (metis (no_types, lifting) complex_vector.scale_left_commute scaleR_scaleC) also have "\ = (\v\B. r v *\<^sub>R v) + (\v\(*\<^sub>C) \ ` B. r v *\<^sub>R v)" using d1 by simp also have "\ = \" using l2 \(\v\B'. r v *\<^sub>R v) = \\ unfolding B'_def by (simp add: a3 sum.union_disjoint) finally have "(\v\B. f v *\<^sub>C v) = \" unfolding r'_def r_def f_def by simp hence "0 = (\v\B. f v *\<^sub>C v) - (\v\B. crepresentation B \ v *\<^sub>C v)" using rep1 unfolding g_def by simp also have "\ = (\v\B. f v *\<^sub>C v - crepresentation B \ v *\<^sub>C v)" by (simp add: sum_subtractf) also have "\ = (\v\B. (f v - crepresentation B \ v) *\<^sub>C v)" by (metis scaleC_left.diff) finally have "0 = (\v\B. (f v - crepresentation B \ v) *\<^sub>C v)". hence "(\v\B. (f v - crepresentation B \ v) *\<^sub>C v) = 0" by simp hence "f b - crepresentation B \ b = 0" using a1 a2 a3 complex_vector.independentD[where s = B and t = B and u = "\v. f v - crepresentation B \ v" and v = b] order_refl by smt hence "crepresentation B \ b = f b" by simp thus ?thesis unfolding f_def r_def r'_def B'_def by auto next define B' where "B' = B \ (*\<^sub>C) \ ` B" case False have b2: "\ \ real_vector.span B'" unfolding B'_def using False cspan_as_span by auto have "\ \ complex_vector.span B" using False by blast have "crepresentation B \ b = 0" unfolding complex_vector.representation_def by (simp add: False) moreover have "real_vector.representation B' \ b = 0" unfolding real_vector.representation_def by (simp add: b2) moreover have "real_vector.representation B' \ ((*\<^sub>C) \ b) = 0" unfolding real_vector.representation_def by (simp add: b2) ultimately show ?thesis unfolding B'_def by simp qed lemma CARD_1_vec_0[simp]: \(\ :: _ ::{complex_vector,CARD_1}) = 0\ by auto lemma scaleC_cindependent: assumes a1: "cindependent (B::'a::complex_vector set)" and a3: "c \ 0" shows "cindependent ((*\<^sub>C) c ` B)" proof- have "u y = 0" if g1: "y\S" and g2: "(\x\S. u x *\<^sub>C x) = 0" and g3: "finite S" and g4: "S\(*\<^sub>C) c ` B" for u y S proof- define v where "v x = u (c *\<^sub>C x)" for x obtain S' where "S'\B" and S_S': "S = (*\<^sub>C) c ` S'" by (meson g4 subset_imageE) have "inj ((*\<^sub>C) c::'a\_)" unfolding inj_def using a3 by auto hence "finite S'" using S_S' finite_imageD g3 subset_inj_on by blast have "t \ (*\<^sub>C) (inverse c) ` S" if "t \ S'" for t proof- have "c *\<^sub>C t \ S" using \S = (*\<^sub>C) c ` S'\ that by blast hence "(inverse c) *\<^sub>C (c *\<^sub>C t) \ (*\<^sub>C) (inverse c) ` S" by blast moreover have "(inverse c) *\<^sub>C (c *\<^sub>C t) = t" by (simp add: a3) ultimately show ?thesis by simp qed moreover have "t \ S'" if "t \ (*\<^sub>C) (inverse c) ` S" for t proof- obtain t' where "t = (inverse c) *\<^sub>C t'" and "t' \ S" using \t \ (*\<^sub>C) (inverse c) ` S\ by auto have "c *\<^sub>C t = c *\<^sub>C ((inverse c) *\<^sub>C t')" using \t = (inverse c) *\<^sub>C t'\ by simp also have "\ = (c * (inverse c)) *\<^sub>C t'" by simp also have "\ = t'" by (simp add: a3) finally have "c *\<^sub>C t = t'". thus ?thesis using \t' \ S\ using \S = (*\<^sub>C) c ` S'\ a3 complex_vector.scale_left_imp_eq by blast qed ultimately have "S' = (*\<^sub>C) (inverse c) ` S" by blast hence "inverse c *\<^sub>C y \ S'" using that(1) by blast have t: "inj (((*\<^sub>C) c)::'a \ _)" using a3 complex_vector.injective_scale[where c = c] by blast have "0 = (\x\(*\<^sub>C) c ` S'. u x *\<^sub>C x)" using \S = (*\<^sub>C) c ` S'\ that(2) by auto also have "\ = (\x\S'. v x *\<^sub>C (c *\<^sub>C x))" unfolding v_def using t Groups_Big.comm_monoid_add_class.sum.reindex[where h = "((*\<^sub>C) c)" and A = S' and g = "\x. u x *\<^sub>C x"] subset_inj_on by auto also have "\ = c *\<^sub>C (\x\S'. v x *\<^sub>C x)" by (metis (mono_tags, lifting) complex_vector.scale_left_commute scaleC_right.sum sum.cong) finally have "0 = c *\<^sub>C (\x\S'. v x *\<^sub>C x)". hence "(\x\S'. v x *\<^sub>C x) = 0" using a3 by auto hence "v (inverse c *\<^sub>C y) = 0" using \inverse c *\<^sub>C y \ S'\ \finite S'\ \S' \ B\ a1 complex_vector.independentD by blast thus "u y = 0" unfolding v_def by (simp add: a3) qed thus ?thesis using complex_vector.dependent_explicit by (simp add: complex_vector.dependent_explicit ) qed subsection \Antilinear maps and friends\ locale antilinear = additive f for f :: "'a::complex_vector \ 'b::complex_vector" + assumes scaleC: "f (scaleC r x) = cnj r *\<^sub>C f x" sublocale antilinear \ linear proof (rule linearI) show "f (b1 + b2) = f b1 + f b2" for b1 :: 'a and b2 :: 'a by (simp add: add) show "f (r *\<^sub>R b) = r *\<^sub>R f b" for r :: real and b :: 'a unfolding scaleR_scaleC by (subst scaleC, simp) qed lemma antilinear_imp_scaleC: fixes D :: "complex \ 'a::complex_vector" assumes "antilinear D" obtains d where "D = (\x. cnj x *\<^sub>C d)" proof - interpret clinear "D o cnj" apply standard apply auto apply (simp add: additive.add assms antilinear.axioms(1)) using assms antilinear.scaleC by fastforce obtain d where "D o cnj = (\x. x *\<^sub>C d)" using clinear_axioms complex_vector.linear_imp_scale by blast then have \D = (\x. cnj x *\<^sub>C d)\ by (metis comp_apply complex_cnj_cnj) then show ?thesis by (rule that) qed corollary complex_antilinearD: fixes f :: "complex \ complex" assumes "antilinear f" obtains c where "f = (\x. c * cnj x)" by (rule antilinear_imp_scaleC [OF assms]) (force simp: scaleC_conv_of_complex) lemma antilinearI: assumes "\x y. f (x + y) = f x + f y" and "\c x. f (c *\<^sub>C x) = cnj c *\<^sub>C f x" shows "antilinear f" by standard (rule assms)+ lemma antilinear_o_antilinear: "antilinear f \ antilinear g \ clinear (g o f)" apply (rule clinearI) apply (simp add: additive.add antilinear_def) by (simp add: antilinear.scaleC) lemma clinear_o_antilinear: "antilinear f \ clinear g \ antilinear (g o f)" apply (rule antilinearI) apply (simp add: additive.add complex_vector.linear_add antilinear_def) by (simp add: complex_vector.linear_scale antilinear.scaleC) lemma antilinear_o_clinear: "clinear f \ antilinear g \ antilinear (g o f)" apply (rule antilinearI) apply (simp add: additive.add complex_vector.linear_add antilinear_def) by (simp add: complex_vector.linear_scale antilinear.scaleC) locale bounded_antilinear = antilinear f for f :: "'a::complex_normed_vector \ 'b::complex_normed_vector" + assumes bounded: "\K. \x. norm (f x) \ norm x * K" lemma bounded_antilinearI: assumes \\b1 b2. f (b1 + b2) = f b1 + f b2\ assumes \\r b. f (r *\<^sub>C b) = cnj r *\<^sub>C f b\ assumes \\x. norm (f x) \ norm x * K\ shows "bounded_antilinear f" using assms by (auto intro!: exI bounded_antilinear.intro antilinearI simp: bounded_antilinear_axioms_def) sublocale bounded_antilinear \ bounded_linear apply standard by (fact bounded) lemma (in bounded_antilinear) bounded_linear: "bounded_linear f" by (fact bounded_linear) lemma (in bounded_antilinear) antilinear: "antilinear f" by (fact antilinear_axioms) lemma bounded_antilinear_intro: assumes "\x y. f (x + y) = f x + f y" and "\r x. f (scaleC r x) = scaleC (cnj r) (f x)" and "\x. norm (f x) \ norm x * K" shows "bounded_antilinear f" by standard (blast intro: assms)+ lemma bounded_antilinear_0[simp]: \bounded_antilinear (\_. 0)\ by (rule bounded_antilinear_intro[where K=0], auto) lemma cnj_bounded_antilinear[simp]: "bounded_antilinear cnj" apply (rule bounded_antilinear_intro [where K = 1]) by auto lemma bounded_antilinear_o_bounded_antilinear: assumes "bounded_antilinear f" and "bounded_antilinear g" shows "bounded_clinear (\x. f (g x))" proof interpret f: bounded_antilinear f by fact interpret g: bounded_antilinear g by fact fix b1 b2 b r show "f (g (b1 + b2)) = f (g b1) + f (g b2)" by (simp add: f.add g.add) show "f (g (r *\<^sub>C b)) = r *\<^sub>C f (g b)" by (simp add: f.scaleC g.scaleC) have "bounded_linear (\x. f (g x))" using f.bounded_linear g.bounded_linear by (rule bounded_linear_compose) then show "\K. \x. norm (f (g x)) \ norm x * K" by (rule bounded_linear.bounded) qed lemma bounded_antilinear_o_bounded_clinear: assumes "bounded_antilinear f" and "bounded_clinear g" shows "bounded_antilinear (\x. f (g x))" proof interpret f: bounded_antilinear f by fact interpret g: bounded_clinear g by fact show "f (g (x + y)) = f (g x) + f (g y)" for x y by (simp only: f.add g.add) show "f (g (scaleC r x)) = scaleC (cnj r) (f (g x))" for r x by (simp add: f.scaleC g.scaleC) have "bounded_linear (\x. f (g x))" using f.bounded_linear g.bounded_linear by (rule bounded_linear_compose) then show "\K. \x. norm (f (g x)) \ norm x * K" by (rule bounded_linear.bounded) qed lemma bounded_clinear_o_bounded_antilinear: assumes "bounded_clinear f" and "bounded_antilinear g" shows "bounded_antilinear (\x. f (g x))" proof interpret f: bounded_clinear f by fact interpret g: bounded_antilinear g by fact show "f (g (x + y)) = f (g x) + f (g y)" for x y by (simp only: f.add g.add) show "f (g (scaleC r x)) = scaleC (cnj r) (f (g x))" for r x using f.scaleC g.scaleC by fastforce have "bounded_linear (\x. f (g x))" using f.bounded_linear g.bounded_linear by (rule bounded_linear_compose) then show "\K. \x. norm (f (g x)) \ norm x * K" by (rule bounded_linear.bounded) qed lemma bij_clinear_imp_inv_clinear: "clinear (inv f)" if a1: "clinear f" and a2: "bij f" proof fix b1 b2 r b show "inv f (b1 + b2) = inv f b1 + inv f b2" by (simp add: a1 a2 bij_is_inj bij_is_surj complex_vector.linear_add inv_f_eq surj_f_inv_f) show "inv f (r *\<^sub>C b) = r *\<^sub>C inv f b" using that by (smt bij_inv_eq_iff clinear_def complex_vector.linear_scale) qed locale bounded_sesquilinear = fixes prod :: "'a::complex_normed_vector \ 'b::complex_normed_vector \ 'c::complex_normed_vector" (infixl "**" 70) assumes add_left: "prod (a + a') b = prod a b + prod a' b" and add_right: "prod a (b + b') = prod a b + prod a b'" and scaleC_left: "prod (r *\<^sub>C a) b = (cnj r) *\<^sub>C (prod a b)" and scaleC_right: "prod a (r *\<^sub>C b) = r *\<^sub>C (prod a b)" and bounded: "\K. \a b. norm (prod a b) \ norm a * norm b * K" sublocale bounded_sesquilinear \ bounded_bilinear apply standard by (auto simp: add_left add_right scaleC_left scaleC_right bounded scaleR_scaleC) lemma (in bounded_sesquilinear) bounded_bilinear[simp]: "bounded_bilinear prod" by (fact bounded_bilinear_axioms) lemma (in bounded_sesquilinear) bounded_antilinear_left: "bounded_antilinear (\a. prod a b)" apply standard apply (auto simp add: scaleC_left add_left) by (metis ab_semigroup_mult_class.mult_ac(1) bounded) lemma (in bounded_sesquilinear) bounded_clinear_right: "bounded_clinear (\b. prod a b)" apply standard apply (auto simp add: scaleC_right add_right) by (metis ab_semigroup_mult_class.mult_ac(1) ordered_field_class.sign_simps(34) pos_bounded) lemma (in bounded_sesquilinear) comp1: assumes \bounded_clinear g\ shows \bounded_sesquilinear (\x. prod (g x))\ proof interpret bounded_clinear g by fact fix a a' b b' r show "prod (g (a + a')) b = prod (g a) b + prod (g a') b" by (simp add: add add_left) show "prod (g a) (b + b') = prod (g a) b + prod (g a) b'" by (simp add: add add_right) show "prod (g (r *\<^sub>C a)) b = cnj r *\<^sub>C prod (g a) b" by (simp add: scaleC scaleC_left) show "prod (g a) (r *\<^sub>C b) = r *\<^sub>C prod (g a) b" by (simp add: scaleC_right) interpret bounded_bilinear \(\x. prod (g x))\ by (simp add: bounded_linear comp1) show "\K. \a b. norm (prod (g a) b) \ norm a * norm b * K" using bounded by blast qed lemma (in bounded_sesquilinear) comp2: assumes \bounded_clinear g\ shows \bounded_sesquilinear (\x y. prod x (g y))\ proof interpret bounded_clinear g by fact fix a a' b b' r show "prod (a + a') (g b) = prod a (g b) + prod a' (g b)" by (simp add: add add_left) show "prod a (g (b + b')) = prod a (g b) + prod a (g b')" by (simp add: add add_right) show "prod (r *\<^sub>C a) (g b) = cnj r *\<^sub>C prod a (g b)" by (simp add: scaleC scaleC_left) show "prod a (g (r *\<^sub>C b)) = r *\<^sub>C prod a (g b)" by (simp add: scaleC scaleC_right) interpret bounded_bilinear \(\x y. prod x (g y))\ apply (rule bounded_bilinear.flip) using _ bounded_linear apply (rule bounded_bilinear.comp1) using bounded_bilinear by (rule bounded_bilinear.flip) show "\K. \a b. norm (prod a (g b)) \ norm a * norm b * K" using bounded by blast qed lemma (in bounded_sesquilinear) comp: "bounded_clinear f \ bounded_clinear g \ bounded_sesquilinear (\x y. prod (f x) (g y))" using comp1 bounded_sesquilinear.comp2 by auto lemma bounded_clinear_const_scaleR: fixes c :: real assumes \bounded_clinear f\ shows \bounded_clinear (\ x. c *\<^sub>R f x )\ proof- have \bounded_clinear (\ x. (complex_of_real c) *\<^sub>C f x )\ by (simp add: assms bounded_clinear_const_scaleC) thus ?thesis by (simp add: scaleR_scaleC) qed lemma bounded_linear_bounded_clinear: \bounded_linear A \ \c x. A (c *\<^sub>C x) = c *\<^sub>C A x \ bounded_clinear A\ apply standard by (simp_all add: linear_simps bounded_linear.bounded) lemma comp_bounded_clinear: fixes A :: \'b::complex_normed_vector \ 'c::complex_normed_vector\ and B :: \'a::complex_normed_vector \ 'b\ assumes \bounded_clinear A\ and \bounded_clinear B\ shows \bounded_clinear (A \ B)\ by (metis clinear_compose assms(1) assms(2) bounded_clinear_axioms_def bounded_clinear_compose bounded_clinear_def o_def) lemmas isCont_scaleC [simp] = bounded_bilinear.isCont [OF bounded_cbilinear_scaleC[THEN bounded_cbilinear.bounded_bilinear]] subsection \Misc 2\ lemmas sums_of_complex = bounded_linear.sums [OF bounded_clinear_of_complex[THEN bounded_clinear.bounded_linear]] lemmas summable_of_complex = bounded_linear.summable [OF bounded_clinear_of_complex[THEN bounded_clinear.bounded_linear]] lemmas suminf_of_complex = bounded_linear.suminf [OF bounded_clinear_of_complex[THEN bounded_clinear.bounded_linear]] lemmas sums_scaleC_left = bounded_linear.sums[OF bounded_clinear_scaleC_left[THEN bounded_clinear.bounded_linear]] lemmas summable_scaleC_left = bounded_linear.summable[OF bounded_clinear_scaleC_left[THEN bounded_clinear.bounded_linear]] lemmas suminf_scaleC_left = bounded_linear.suminf[OF bounded_clinear_scaleC_left[THEN bounded_clinear.bounded_linear]] lemmas sums_scaleC_right = bounded_linear.sums[OF bounded_clinear_scaleC_right[THEN bounded_clinear.bounded_linear]] lemmas summable_scaleC_right = bounded_linear.summable[OF bounded_clinear_scaleC_right[THEN bounded_clinear.bounded_linear]] lemmas suminf_scaleC_right = bounded_linear.suminf[OF bounded_clinear_scaleC_right[THEN bounded_clinear.bounded_linear]] lemma closed_scaleC: fixes S::\'a::complex_normed_vector set\ and a :: complex assumes \closed S\ shows \closed ((*\<^sub>C) a ` S)\ proof (cases \a = 0\) case True then show ?thesis apply (cases \S = {}\) by (auto simp: image_constant) next case False then have \(*\<^sub>C) a ` S = (*\<^sub>C) (inverse a) -` S\ by (auto simp add: rev_image_eqI) moreover have \closed ((*\<^sub>C) (inverse a) -` S)\ by (simp add: assms continuous_closed_vimage) ultimately show ?thesis by simp qed lemma closure_scaleC: fixes S::\'a::complex_normed_vector set\ shows \closure ((*\<^sub>C) a ` S) = (*\<^sub>C) a ` closure S\ proof have \closed (closure S)\ by simp show "closure ((*\<^sub>C) a ` S) \ (*\<^sub>C) a ` closure S" by (simp add: closed_scaleC closure_minimal closure_subset image_mono) have "x \ closure ((*\<^sub>C) a ` S)" if "x \ (*\<^sub>C) a ` closure S" for x :: 'a proof- obtain t where \x = ((*\<^sub>C) a) t\ and \t \ closure S\ using \x \ (*\<^sub>C) a ` closure S\ by auto have \\s. (\n. s n \ S) \ s \ t\ using \t \ closure S\ Elementary_Topology.closure_sequential by blast then obtain s where \\n. s n \ S\ and \s \ t\ by blast have \(\ n. scaleC a (s n) \ ((*\<^sub>C) a ` S))\ using \\n. s n \ S\ by blast moreover have \(\ n. scaleC a (s n)) \ x\ proof- have \isCont (scaleC a) t\ by simp thus ?thesis using \s \ t\ \x = ((*\<^sub>C) a) t\ by (simp add: isCont_tendsto_compose) qed ultimately show ?thesis using Elementary_Topology.closure_sequential by metis qed thus "(*\<^sub>C) a ` closure S \ closure ((*\<^sub>C) a ` S)" by blast qed lemma onorm_scalarC: fixes f :: \'a::complex_normed_vector \ 'b::complex_normed_vector\ assumes a1: \bounded_clinear f\ shows \onorm (\ x. r *\<^sub>C (f x)) = (cmod r) * onorm f\ proof- have \(norm (f x)) / norm x \ onorm f\ for x using a1 by (simp add: bounded_clinear.bounded_linear le_onorm) hence t2: \bdd_above {(norm (f x)) / norm x | x. True}\ by fastforce have \continuous_on UNIV ( (*) w ) \ for w::real by simp hence \isCont ( ((*) (cmod r)) ) x\ for x by simp hence t3: \continuous (at_left (Sup {(norm (f x)) / norm x | x. True})) ((*) (cmod r))\ using Elementary_Topology.continuous_at_imp_continuous_within by blast have \{(norm (f x)) / norm x | x. True} \ {}\ by blast moreover have \mono ((*) (cmod r))\ by (simp add: monoI ordered_comm_semiring_class.comm_mult_left_mono) ultimately have \Sup {((*) (cmod r)) ((norm (f x)) / norm x) | x. True} = ((*) (cmod r)) (Sup {(norm (f x)) / norm x | x. True})\ using t2 t3 by (simp add: continuous_at_Sup_mono full_SetCompr_eq image_image) hence \Sup {(cmod r) * ((norm (f x)) / norm x) | x. True} = (cmod r) * (Sup {(norm (f x)) / norm x | x. True})\ by blast moreover have \Sup {(cmod r) * ((norm (f x)) / norm x) | x. True} = (SUP x. cmod r * norm (f x) / norm x)\ by (simp add: full_SetCompr_eq) moreover have \(Sup {(norm (f x)) / norm x | x. True}) = (SUP x. norm (f x) / norm x)\ by (simp add: full_SetCompr_eq) ultimately have t1: "(SUP x. cmod r * norm (f x) / norm x) = cmod r * (SUP x. norm (f x) / norm x)" by simp have \onorm (\ x. r *\<^sub>C (f x)) = (SUP x. norm ( (\ t. r *\<^sub>C (f t)) x) / norm x)\ by (simp add: onorm_def) hence \onorm (\ x. r *\<^sub>C (f x)) = (SUP x. (cmod r) * (norm (f x)) / norm x)\ by simp also have \... = (cmod r) * (SUP x. (norm (f x)) / norm x)\ using t1. finally show ?thesis by (simp add: onorm_def) qed lemma onorm_scaleC_left_lemma: fixes f :: "'a::complex_normed_vector" assumes r: "bounded_clinear r" shows "onorm (\x. r x *\<^sub>C f) \ onorm r * norm f" proof (rule onorm_bound) fix x have "norm (r x *\<^sub>C f) = norm (r x) * norm f" by simp also have "\ \ onorm r * norm x * norm f" by (simp add: bounded_clinear.bounded_linear mult.commute mult_left_mono onorm r) finally show "norm (r x *\<^sub>C f) \ onorm r * norm f * norm x" by (simp add: ac_simps) show "0 \ onorm r * norm f" by (simp add: bounded_clinear.bounded_linear onorm_pos_le r) qed lemma onorm_scaleC_left: fixes f :: "'a::complex_normed_vector" assumes f: "bounded_clinear r" shows "onorm (\x. r x *\<^sub>C f) = onorm r * norm f" proof (cases "f = 0") assume "f \ 0" show ?thesis proof (rule order_antisym) show "onorm (\x. r x *\<^sub>C f) \ onorm r * norm f" using f by (rule onorm_scaleC_left_lemma) next have bl1: "bounded_clinear (\x. r x *\<^sub>C f)" by (metis bounded_clinear_scaleC_const f) have x1:"bounded_clinear (\x. r x * norm f)" by (metis bounded_clinear_mult_const f) have "onorm r \ onorm (\x. r x * complex_of_real (norm f)) / norm f" if "onorm r \ onorm (\x. r x * complex_of_real (norm f)) * cmod (1 / complex_of_real (norm f))" and "f \ 0" using that by (metis complex_of_real_cmod complex_of_real_nn_iff field_class.field_divide_inverse inverse_eq_divide nice_ordered_field_class.zero_le_divide_1_iff norm_ge_zero of_real_1 of_real_divide of_real_eq_iff) hence "onorm r \ onorm (\x. r x * norm f) * inverse (norm f)" using \f \ 0\ onorm_scaleC_left_lemma[OF x1, of "inverse (norm f)"] by (simp add: inverse_eq_divide) also have "onorm (\x. r x * norm f) \ onorm (\x. r x *\<^sub>C f)" proof (rule onorm_bound) have "bounded_linear (\x. r x *\<^sub>C f)" using bl1 bounded_clinear.bounded_linear by auto thus "0 \ onorm (\x. r x *\<^sub>C f)" by (rule Operator_Norm.onorm_pos_le) show "cmod (r x * complex_of_real (norm f)) \ onorm (\x. r x *\<^sub>C f) * norm x" for x :: 'b by (smt \bounded_linear (\x. r x *\<^sub>C f)\ complex_of_real_cmod complex_of_real_nn_iff complex_scaleC_def norm_ge_zero norm_scaleC of_real_eq_iff onorm) qed finally show "onorm r * norm f \ onorm (\x. r x *\<^sub>C f)" using \f \ 0\ by (simp add: inverse_eq_divide pos_le_divide_eq mult.commute) qed qed (simp add: onorm_zero) subsection \Finite dimension and canonical basis\ lemma vector_finitely_spanned: assumes \z \ cspan T\ shows \\ S. finite S \ S \ T \ z \ cspan S\ proof- have \\ S r. finite S \ S \ T \ z = (\a\S. r a *\<^sub>C a)\ using complex_vector.span_explicit[where b = "T"] assms by auto then obtain S r where \finite S\ and \S \ T\ and \z = (\a\S. r a *\<^sub>C a)\ by blast thus ?thesis by (meson complex_vector.span_scale complex_vector.span_sum complex_vector.span_superset subset_iff) qed setup \Sign.add_const_constraint ("Complex_Vector_Spaces0.cindependent", SOME \<^typ>\'a set \ bool\)\ setup \Sign.add_const_constraint (\<^const_name>\cdependent\, SOME \<^typ>\'a set \ bool\)\ setup \Sign.add_const_constraint (\<^const_name>\cspan\, SOME \<^typ>\'a set \ 'a set\)\ class cfinite_dim = complex_vector + assumes cfinitely_spanned: "\S::'a set. finite S \ cspan S = UNIV" class basis_enum = complex_vector + fixes canonical_basis :: "'a list" assumes distinct_canonical_basis[simp]: "distinct canonical_basis" and is_cindependent_set[simp]: "cindependent (set canonical_basis)" and is_generator_set[simp]: "cspan (set canonical_basis) = UNIV" setup \Sign.add_const_constraint ("Complex_Vector_Spaces0.cindependent", SOME \<^typ>\'a::complex_vector set \ bool\)\ setup \Sign.add_const_constraint (\<^const_name>\cdependent\, SOME \<^typ>\'a::complex_vector set \ bool\)\ setup \Sign.add_const_constraint (\<^const_name>\cspan\, SOME \<^typ>\'a::complex_vector set \ 'a set\)\ lemma cdim_UNIV_basis_enum[simp]: \cdim (UNIV::'a::basis_enum set) = length (canonical_basis::'a list)\ apply (subst is_generator_set[symmetric]) apply (subst complex_vector.dim_span_eq_card_independent) apply (rule is_cindependent_set) using distinct_canonical_basis distinct_card by blast lemma finite_basis: "\basis::'a::cfinite_dim set. finite basis \ cindependent basis \ cspan basis = UNIV" proof - from cfinitely_spanned obtain S :: \'a set\ where \finite S\ and \cspan S = UNIV\ by auto from complex_vector.maximal_independent_subset obtain B :: \'a set\ where \B \ S\ and \cindependent B\ and \S \ cspan B\ by metis moreover have \finite B\ using \B \ S\ \finite S\ by (meson finite_subset) moreover have \cspan B = UNIV\ using \cspan S = UNIV\ \S \ cspan B\ by (metis complex_vector.span_eq top_greatest) ultimately show ?thesis by auto qed instance basis_enum \ cfinite_dim apply intro_classes apply (rule exI[of _ \set canonical_basis\]) using is_cindependent_set is_generator_set by auto lemma cindependent_cfinite_dim_finite: assumes \cindependent (S::'a::cfinite_dim set)\ shows \finite S\ by (metis assms cfinitely_spanned complex_vector.independent_span_bound top_greatest) lemma cfinite_dim_finite_subspace_basis: assumes \csubspace X\ shows "\basis::'a::cfinite_dim set. finite basis \ cindependent basis \ cspan basis = X" by (meson assms cindependent_cfinite_dim_finite complex_vector.basis_exists complex_vector.span_subspace) text \The following auxiliary lemma (\finite_span_complete_aux\) shows more or less the same as \finite_span_representation_bounded\, \finite_span_complete\ below (see there for an intuition about the mathematical content of the lemmas). However, there is one difference: Here we additionally assume here that there is a bijection rep/abs between a finite type \<^typ>\'basis\ and the set $B$. This is needed to be able to use results about euclidean spaces that are formulated w.r.t. the type class \<^class>\finite\ Since we anyway assume that $B$ is finite, this added assumption does not make the lemma weaker. However, we cannot derive the existence of \<^typ>\'basis\ inside the proof (HOL does not support such reasoning). Therefore we have the type \<^typ>\'basis\ as an explicit assumption and remove it using @{attribute internalize_sort} after the proof.\ lemma finite_span_complete_aux: fixes b :: "'b::real_normed_vector" and B :: "'b set" and rep :: "'basis::finite \ 'b" and abs :: "'b \ 'basis" assumes t: "type_definition rep abs B" and t1: "finite B" and t2: "b\B" and t3: "independent B" shows "\D>0. \\. norm (representation B \ b) \ norm \ * D" and "complete (span B)" proof - define repr where "repr = real_vector.representation B" define repr' where "repr' \ = Abs_euclidean_space (repr \ o rep)" for \ define comb where "comb l = (\b\B. l b *\<^sub>R b)" for l define comb' where "comb' l = comb (Rep_euclidean_space l o abs)" for l have comb_cong: "comb x = comb y" if "\z. z\B \ x z = y z" for x y unfolding comb_def using that by auto have comb_repr[simp]: "comb (repr \) = \" if "\ \ real_vector.span B" for \ using \comb \ \l. \b\B. l b *\<^sub>R b\ local.repr_def real_vector.sum_representation_eq t1 t3 that by fastforce have w5:"(\b | (b \ B \ x b \ 0) \ b \ B. x b *\<^sub>R b) = (\b\B. x b *\<^sub>R b)" for x using \finite B\ by (smt DiffD1 DiffD2 mem_Collect_eq real_vector.scale_eq_0_iff subset_eq sum.mono_neutral_left) have "representation B (\b\B. x b *\<^sub>R b) = (\b. if b \ B then x b else 0)" for x proof (rule real_vector.representation_eqI) show "independent B" by (simp add: t3) show "(\b\B. x b *\<^sub>R b) \ span B" by (meson real_vector.span_scale real_vector.span_sum real_vector.span_superset subset_iff) show "b \ B" if "(if b \ B then x b else 0) \ 0" for b :: 'b using that by meson show "finite {b. (if b \ B then x b else 0) \ 0}" using t1 by auto show "(\b | (if b \ B then x b else 0) \ 0. (if b \ B then x b else 0) *\<^sub>R b) = (\b\B. x b *\<^sub>R b)" using w5 by simp qed hence repr_comb[simp]: "repr (comb x) = (\b. if b\B then x b else 0)" for x unfolding repr_def comb_def. have repr_bad[simp]: "repr \ = (\_. 0)" if "\ \ real_vector.span B" for \ unfolding repr_def using that by (simp add: real_vector.representation_def) have [simp]: "repr' \ = 0" if "\ \ real_vector.span B" for \ unfolding repr'_def repr_bad[OF that] apply transfer by auto have comb'_repr'[simp]: "comb' (repr' \) = \" if "\ \ real_vector.span B" for \ proof - have x1: "(repr \ \ rep \ abs) z = repr \ z" if "z \ B" for z unfolding o_def using t that type_definition.Abs_inverse by fastforce have "comb' (repr' \) = comb ((repr \ \ rep) \ abs)" unfolding comb'_def repr'_def by (subst Abs_euclidean_space_inverse; simp) also have "\ = comb (repr \)" using x1 comb_cong by blast also have "\ = \" using that by simp finally show ?thesis by - qed have t1: "Abs_euclidean_space (Rep_euclidean_space t) = t" if "\x. rep x \ B" for t::"'a euclidean_space" apply (subst Rep_euclidean_space_inverse) by simp have "Abs_euclidean_space (\y. if rep y \ B then Rep_euclidean_space x y else 0) = x" for x using type_definition.Rep[OF t] apply simp using t1 by blast hence "Abs_euclidean_space (\y. if rep y \ B then Rep_euclidean_space x (abs (rep y)) else 0) = x" for x apply (subst type_definition.Rep_inverse[OF t]) by simp hence repr'_comb'[simp]: "repr' (comb' x) = x" for x unfolding comb'_def repr'_def o_def by simp have sphere: "compact (sphere 0 d :: 'basis euclidean_space set)" for d using compact_sphere by blast have "complete (UNIV :: 'basis euclidean_space set)" by (simp add: complete_UNIV) have "(\b\B. (Rep_euclidean_space (x + y) \ abs) b *\<^sub>R b) = (\b\B. (Rep_euclidean_space x \ abs) b *\<^sub>R b) + (\b\B. (Rep_euclidean_space y \ abs) b *\<^sub>R b)" for x :: "'basis euclidean_space" and y :: "'basis euclidean_space" apply (transfer fixing: abs) by (simp add: scaleR_add_left sum.distrib) moreover have "(\b\B. (Rep_euclidean_space (c *\<^sub>R x) \ abs) b *\<^sub>R b) = c *\<^sub>R (\b\B. (Rep_euclidean_space x \ abs) b *\<^sub>R b)" for c :: real and x :: "'basis euclidean_space" apply (transfer fixing: abs) by (simp add: real_vector.scale_sum_right) ultimately have blin_comb': "bounded_linear comb'" unfolding comb_def comb'_def by (rule bounded_linearI') hence "continuous_on X comb'" for X by (simp add: linear_continuous_on) hence "compact (comb' ` sphere 0 d)" for d using sphere by (rule compact_continuous_image) hence compact_norm_comb': "compact (norm ` comb' ` sphere 0 1)" using compact_continuous_image continuous_on_norm_id by blast have not0: "0 \ norm ` comb' ` sphere 0 1" proof (rule ccontr, simp) assume "0 \ norm ` comb' ` sphere 0 1" then obtain x where nc0: "norm (comb' x) = 0" and x: "x \ sphere 0 1" by auto hence "comb' x = 0" by simp hence "repr' (comb' x) = 0" unfolding repr'_def o_def repr_def apply simp by (smt repr'_comb' blin_comb' dist_0_norm linear_simps(3) mem_sphere norm_zero x) hence "x = 0" by auto with x show False by simp qed have "closed (norm ` comb' ` sphere 0 1)" using compact_imp_closed compact_norm_comb' by blast moreover have "0 \ norm ` comb' ` sphere 0 1" by (simp add: not0) ultimately have "\d>0. \x\norm ` comb' ` sphere 0 1. d \ dist 0 x" by (meson separate_point_closed) then obtain d where d: "x\norm ` comb' ` sphere 0 1 \ d \ dist 0 x" and "d > 0" for x by metis define D where "D = 1/d" hence "D > 0" using \d>0\ unfolding D_def by auto have "x \ d" if "x\norm ` comb' ` sphere 0 1" for x using d that apply auto by fastforce hence *: "norm (comb' x) \ d" if "norm x = 1" for x using that by auto have norm_comb': "norm (comb' x) \ d * norm x" for x proof (cases "x=0") show "d * norm x \ norm (comb' x)" if "x = 0" using that by simp show "d * norm x \ norm (comb' x)" if "x \ 0" using that using *[of "(1/norm x) *\<^sub>R x"] unfolding linear_simps(5)[OF blin_comb'] apply auto by (simp add: le_divide_eq) qed have *: "norm (repr' \) \ norm \ * D" for \ proof (cases "\ \ real_vector.span B") show "norm (repr' \) \ norm \ * D" if "\ \ span B" using that unfolding D_def using norm_comb'[of "repr' \"] \d>0\ by (simp_all add: linordered_field_class.mult_imp_le_div_pos mult.commute) show "norm (repr' \) \ norm \ * D" if "\ \ span B" using that \0 < D\ by auto qed hence "norm (Rep_euclidean_space (repr' \) (abs b)) \ norm \ * D" for \ proof - have "(Rep_euclidean_space (repr' \) (abs b)) = repr' \ \ euclidean_space_basis_vector (abs b)" apply (transfer fixing: abs b) by auto also have "\\\ \ norm (repr' \)" apply (rule Basis_le_norm) unfolding Basis_euclidean_space_def by simp also have "\ \ norm \ * D" using * by auto finally show ?thesis by simp qed hence "norm (repr \ b) \ norm \ * D" for \ unfolding repr'_def by (smt \comb' \ \l. comb (Rep_euclidean_space l \ abs)\ \repr' \ \\. Abs_euclidean_space (repr \ \ rep)\ comb'_repr' comp_apply norm_le_zero_iff repr_bad repr_comb) thus "\D>0. \\. norm (repr \ b) \ norm \ * D" using \D>0\ by auto from \d>0\ have complete_comb': "complete (comb' ` UNIV)" proof (rule complete_isometric_image) show "subspace (UNIV::'basis euclidean_space set)" by simp show "bounded_linear comb'" by (simp add: blin_comb') show "\x\UNIV. d * norm x \ norm (comb' x)" by (simp add: norm_comb') show "complete (UNIV::'basis euclidean_space set)" by (simp add: \complete UNIV\) qed have range_comb': "comb' ` UNIV = real_vector.span B" proof (auto simp: image_def) show "comb' x \ real_vector.span B" for x by (metis comb'_def comb_cong comb_repr local.repr_def repr_bad repr_comb real_vector.representation_zero real_vector.span_zero) next fix \ assume "\ \ real_vector.span B" then obtain f where f: "comb f = \" apply atomize_elim unfolding span_finite[OF \finite B\] comb_def by auto define f' where "f' b = (if b\B then f b else 0)" for b :: 'b have f': "comb f' = \" unfolding f[symmetric] apply (rule comb_cong) unfolding f'_def by simp define x :: "'basis euclidean_space" where "x = Abs_euclidean_space (f' o rep)" have "\ = comb' x" by (metis (no_types, lifting) \\ \ span B\ \repr' \ \\. Abs_euclidean_space (repr \ \ rep)\ comb'_repr' f' fun.map_cong repr_comb t type_definition.Rep_range x_def) thus "\x. \ = comb' x" by auto qed from range_comb' complete_comb' show "complete (real_vector.span B)" by simp qed lemma finite_span_complete[simp]: fixes A :: "'a::real_normed_vector set" assumes "finite A" shows "complete (span A)" text \The span of a finite set is complete.\ proof (cases "A \ {} \ A \ {0}") case True obtain B where BT: "real_vector.span B = real_vector.span A" and "independent B" and "finite B" by (meson True assms finite_subset real_vector.maximal_independent_subset real_vector.span_eq real_vector.span_superset subset_trans) have "B\{}" apply (rule ccontr, simp) using BT True by (metis real_vector.span_superset real_vector.span_empty subset_singletonD) (* The following generalizes finite_span_complete_aux to hold without the assumption that 'basis has type class finite *) { (* The type variable 'basisT must not be the same as the one used in finite_span_complete_aux, otherwise "internalize_sort" below fails *) assume "\(Rep :: 'basisT\'a) Abs. type_definition Rep Abs B" then obtain rep :: "'basisT \ 'a" and abs :: "'a \ 'basisT" where t: "type_definition rep abs B" by auto have basisT_finite: "class.finite TYPE('basisT)" apply intro_classes using \finite B\ t by (metis (mono_tags, opaque_lifting) ex_new_if_finite finite_imageI image_eqI type_definition_def) note finite_span_complete_aux(2)[internalize_sort "'basis::finite"] note this[OF basisT_finite t] } note this[cancel_type_definition, OF \B\{}\ \finite B\ _ \independent B\] hence "complete (real_vector.span B)" using \B\{}\ by auto thus "complete (real_vector.span A)" unfolding BT by simp next case False thus ?thesis using complete_singleton by auto qed lemma finite_span_representation_bounded: fixes B :: "'a::real_normed_vector set" assumes "finite B" and "independent B" shows "\D>0. \\ b. abs (representation B \ b) \ norm \ * D" text \ Assume $B$ is a finite linear independent set of vectors (in a real normed vector space). Let $\alpha^\psi_b$ be the coefficients of $\psi$ expressed as a linear combination over $B$. Then $\alpha$ is is uniformly cblinfun (i.e., $\lvert\alpha^\psi_b \leq D \lVert\psi\rVert\psi$ for some $D$ independent of $\psi,b$). (This also holds when $b$ is not in the span of $B$ because of the way \real_vector.representation\ is defined in this corner case.)\ proof (cases "B\{}") case True (* The following generalizes finite_span_complete_aux to hold without the assumption that 'basis has type class finite *) define repr where "repr = real_vector.representation B" { (* Step 1: Create a fake type definition by introducing a new type variable 'basis and then assuming the existence of the morphisms Rep/Abs to B This is then roughly equivalent to "typedef 'basis = B" *) (* The type variable 'basisT must not be the same as the one used in finite_span_complete_aux (I.e., we cannot call it 'basis) *) assume "\(Rep :: 'basisT\'a) Abs. type_definition Rep Abs B" then obtain rep :: "'basisT \ 'a" and abs :: "'a \ 'basisT" where t: "type_definition rep abs B" by auto (* Step 2: We show that our fake typedef 'basisT could be instantiated as type class finite *) have basisT_finite: "class.finite TYPE('basisT)" apply intro_classes using \finite B\ t by (metis (mono_tags, opaque_lifting) ex_new_if_finite finite_imageI image_eqI type_definition_def) (* Step 3: We take the finite_span_complete_aux and remove the requirement that 'basis::finite (instead, a precondition "class.finite TYPE('basisT)" is introduced) *) note finite_span_complete_aux(1)[internalize_sort "'basis::finite"] (* Step 4: We instantiate the premises *) note this[OF basisT_finite t] } (* Now we have the desired fact, except that it still assumes that B is isomorphic to some type 'basis together with the assumption that there are morphisms between 'basis and B. 'basis and that premise are removed using cancel_type_definition *) note this[cancel_type_definition, OF True \finite B\ _ \independent B\] hence d2:"\D. \\. D>0 \ norm (repr \ b) \ norm \ * D" if \b\B\ for b by (simp add: repr_def that True) have d1: " (\b. b \ B \ \D. \\. 0 < D \ norm (repr \ b) \ norm \ * D) \ \D. \b \. b \ B \ 0 < D b \ norm (repr \ b) \ norm \ * D b" apply (rule choice) by auto then obtain D where D: "D b > 0 \ norm (repr \ b) \ norm \ * D b" if "b\B" for b \ apply atomize_elim using d2 by blast hence Dpos: "D b > 0" and Dbound: "norm (repr \ b) \ norm \ * D b" if "b\B" for b \ using that by auto define Dall where "Dall = Max (D`B)" have "Dall > 0" unfolding Dall_def using \finite B\ \B\{}\ Dpos by (metis (mono_tags, lifting) Max_in finite_imageI image_iff image_is_empty) have "Dall \ D b" if "b\B" for b unfolding Dall_def using \finite B\ that by auto with Dbound have "norm (repr \ b) \ norm \ * Dall" if "b\B" for b \ using that by (smt mult_left_mono norm_not_less_zero) moreover have "norm (repr \ b) \ norm \ * Dall" if "b\B" for b \ unfolding repr_def using real_vector.representation_ne_zero True by (metis calculation empty_subsetI less_le_trans local.repr_def norm_ge_zero norm_zero not_less subsetI subset_antisym) ultimately show "\D>0. \\ b. abs (repr \ b) \ norm \ * D" using \Dall > 0\ real_norm_def by metis next case False thus ?thesis unfolding repr_def using real_vector.representation_ne_zero[of B] using nice_ordered_field_class.linordered_field_no_ub by fastforce qed hide_fact finite_span_complete_aux lemma finite_cspan_complete[simp]: fixes B :: "'a::complex_normed_vector set" assumes "finite B" shows "complete (cspan B)" by (simp add: assms cspan_as_span) lemma finite_span_closed[simp]: fixes B :: "'a::real_normed_vector set" assumes "finite B" shows "closed (real_vector.span B)" by (simp add: assms complete_imp_closed) lemma finite_cspan_closed[simp]: fixes S::\'a::complex_normed_vector set\ assumes a1: \finite S\ shows \closed (cspan S)\ by (simp add: assms complete_imp_closed) lemma closure_finite_cspan: fixes T::\'a::complex_normed_vector set\ assumes \finite T\ shows \closure (cspan T) = cspan T\ by (simp add: assms) lemma finite_cspan_crepresentation_bounded: fixes B :: "'a::complex_normed_vector set" assumes a1: "finite B" and a2: "cindependent B" shows "\D>0. \\ b. norm (crepresentation B \ b) \ norm \ * D" proof - define B' where "B' = (B \ scaleC \ ` B)" have independent_B': "independent B'" using B'_def \cindependent B\ by (simp add: real_independent_from_complex_independent a1) have "finite B'" unfolding B'_def using \finite B\ by simp obtain D' where "D' > 0" and D': "norm (real_vector.representation B' \ b) \ norm \ * D'" for \ b apply atomize_elim using independent_B' \finite B'\ by (simp add: finite_span_representation_bounded) define D where "D = 2*D'" from \D' > 0\ have \D > 0\ unfolding D_def by simp have "norm (crepresentation B \ b) \ norm \ * D" for \ b proof (cases "b\B") case True have d3: "norm \ = 1" by simp have "norm (\ *\<^sub>C complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b))) = norm \ * norm (complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b)))" using norm_scaleC by blast also have "\ = norm (complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b)))" using d3 by simp finally have d2:"norm (\ *\<^sub>C complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b))) = norm (complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b)))". have "norm (crepresentation B \ b) = norm (complex_of_real (real_vector.representation B' \ b) + \ *\<^sub>C complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b)))" by (simp add: B'_def True a1 a2 crepresentation_from_representation) also have "\ \ norm (complex_of_real (real_vector.representation B' \ b)) + norm (\ *\<^sub>C complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b)))" using norm_triangle_ineq by blast also have "\ = norm (complex_of_real (real_vector.representation B' \ b)) + norm (complex_of_real (real_vector.representation B' \ (\ *\<^sub>C b)))" using d2 by simp also have "\ = norm (real_vector.representation B' \ b) + norm (real_vector.representation B' \ (\ *\<^sub>C b))" by simp also have "\ \ norm \ * D' + norm \ * D'" by (rule add_mono; rule D') also have "\ \ norm \ * D" unfolding D_def by linarith finally show ?thesis by auto next case False hence "crepresentation B \ b = 0" using complex_vector.representation_ne_zero by blast thus ?thesis by (smt \0 < D\ norm_ge_zero norm_zero split_mult_pos_le) qed with \D > 0\ show ?thesis by auto qed lemma bounded_clinear_finite_dim[simp]: fixes f :: \'a::{cfinite_dim,complex_normed_vector} \ 'b::complex_normed_vector\ assumes \clinear f\ shows \bounded_clinear f\ proof - include notation_norm obtain basis :: \'a set\ where b1: "complex_vector.span basis = UNIV" and b2: "cindependent basis" and b3:"finite basis" using finite_basis by auto have "\C>0. \\ b. cmod (crepresentation basis \ b) \ \\\ * C" using finite_cspan_crepresentation_bounded[where B = basis] b2 b3 by blast then obtain C where s1: "cmod (crepresentation basis \ b) \ \\\ * C" and s2: "C > 0" for \ b by blast define M where "M = C * (\a\basis. \f a\)" have "\f x\ \ \x\ * M" for x proof- define r where "r b = crepresentation basis x b" for b have x_span: "x \ complex_vector.span basis" by (simp add: b1) have f0: "v \ basis" if "r v \ 0" for v using complex_vector.representation_ne_zero r_def that by auto have w:"{a|a. r a \ 0} \ basis" using f0 by blast hence f1: "finite {a|a. r a \ 0}" using b3 rev_finite_subset by auto have f2: "(\a| r a \ 0. r a *\<^sub>C a) = x" unfolding r_def using b2 complex_vector.sum_nonzero_representation_eq x_span Collect_cong by fastforce have g1: "(\a\basis. crepresentation basis x a *\<^sub>C a) = x" by (simp add: b2 b3 complex_vector.sum_representation_eq x_span) have f3: "(\a\basis. r a *\<^sub>C a) = x" unfolding r_def by (simp add: g1) hence "f x = f (\a\basis. r a *\<^sub>C a)" by simp also have "\ = (\a\basis. r a *\<^sub>C f a)" by (smt (verit, ccfv_SIG) assms complex_vector.linear_scale complex_vector.linear_sum sum.cong) finally have "f x = (\a\basis. r a *\<^sub>C f a)". hence "\f x\ = \(\a\basis. r a *\<^sub>C f a)\" by simp also have "\ \ (\a\basis. \r a *\<^sub>C f a\)" by (simp add: sum_norm_le) also have "\ \ (\a\basis. \r a\ * \f a\)" by simp also have "\ \ (\a\basis. \x\ * C * \f a\)" using sum_mono s1 unfolding r_def by (simp add: sum_mono mult_right_mono) also have "\ \ \x\ * C * (\a\basis. \f a\)" using sum_distrib_left by (smt sum.cong) also have "\ = \x\ * M" unfolding M_def by linarith finally show ?thesis . qed thus ?thesis using assms bounded_clinear_def bounded_clinear_axioms_def by blast qed subsection \Closed subspaces\ lemma csubspace_INF[simp]: "(\x. x \ A \ csubspace x) \ csubspace (\A)" by (simp add: complex_vector.subspace_Inter) locale closed_csubspace = fixes A::"('a::{complex_vector,topological_space}) set" assumes subspace: "csubspace A" assumes closed: "closed A" declare closed_csubspace.subspace[simp] lemma closure_is_csubspace[simp]: fixes A::"('a::complex_normed_vector) set" assumes \csubspace A\ shows \csubspace (closure A)\ proof- have "x \ closure A \ y \ closure A \ x+y \ closure A" for x y proof- assume \x\(closure A)\ then obtain xx where \\ n::nat. xx n \ A\ and \xx \ x\ using closure_sequential by blast assume \y\(closure A)\ then obtain yy where \\ n::nat. yy n \ A\ and \yy \ y\ using closure_sequential by blast have \\ n::nat. (xx n) + (yy n) \ A\ using \\n. xx n \ A\ \\n. yy n \ A\ assms complex_vector.subspace_def by (simp add: complex_vector.subspace_def) hence \(\ n. (xx n) + (yy n)) \ x + y\ using \xx \ x\ \yy \ y\ by (simp add: tendsto_add) thus ?thesis using \\ n::nat. (xx n) + (yy n) \ A\ by (meson closure_sequential) qed moreover have "x\(closure A) \ c *\<^sub>C x \ (closure A)" for x c proof- assume \x\(closure A)\ then obtain xx where \\ n::nat. xx n \ A\ and \xx \ x\ using closure_sequential by blast have \\ n::nat. c *\<^sub>C (xx n) \ A\ using \\n. xx n \ A\ assms complex_vector.subspace_def by (simp add: complex_vector.subspace_def) have \isCont (\ t. c *\<^sub>C t) x\ using bounded_clinear.bounded_linear bounded_clinear_scaleC_right linear_continuous_at by auto hence \(\ n. c *\<^sub>C (xx n)) \ c *\<^sub>C x\ using \xx \ x\ by (simp add: isCont_tendsto_compose) thus ?thesis using \\ n::nat. c *\<^sub>C (xx n) \ A\ by (meson closure_sequential) qed moreover have "0 \ (closure A)" using assms closure_subset complex_vector.subspace_def by (metis in_mono) ultimately show ?thesis by (simp add: complex_vector.subspaceI) qed lemma csubspace_set_plus: assumes \csubspace A\ and \csubspace B\ shows \csubspace (A + B)\ proof - define C where \C = {\+\| \ \. \\A \ \\B}\ have "x\C \ y\C \ x+y\C" for x y using C_def assms(1) assms(2) complex_vector.subspace_add complex_vector.subspace_sums by blast moreover have "c *\<^sub>C x \ C" if \x\C\ for x c proof - have "csubspace C" by (simp add: C_def assms(1) assms(2) complex_vector.subspace_sums) then show ?thesis using that by (simp add: complex_vector.subspace_def) qed moreover have "0 \ C" using \C = {\ + \ |\ \. \ \ A \ \ \ B}\ add.inverse_neutral add_uminus_conv_diff assms(1) assms(2) diff_0 mem_Collect_eq add.right_inverse by (metis (mono_tags, lifting) complex_vector.subspace_0) ultimately show ?thesis unfolding C_def complex_vector.subspace_def by (smt mem_Collect_eq set_plus_elim set_plus_intro) qed lemma closed_csubspace_0[simp]: "closed_csubspace ({0} :: ('a::{complex_vector,t1_space}) set)" proof- have \csubspace {0}\ using add.right_neutral complex_vector.subspace_def scaleC_right.zero by blast moreover have "closed ({0} :: 'a set)" by simp ultimately show ?thesis by (simp add: closed_csubspace_def) qed lemma closed_csubspace_UNIV[simp]: "closed_csubspace (UNIV::('a::{complex_vector,topological_space}) set)" proof- have \csubspace UNIV\ by simp moreover have \closed UNIV\ by simp ultimately show ?thesis unfolding closed_csubspace_def by auto qed lemma closed_csubspace_inter[simp]: assumes "closed_csubspace A" and "closed_csubspace B" shows "closed_csubspace (A\B)" proof- obtain C where \C = A \ B\ by blast have \csubspace C\ proof- have "x\C \ y\C \ x+y\C" for x y by (metis IntD1 IntD2 IntI \C = A \ B\ assms(1) assms(2) complex_vector.subspace_def closed_csubspace_def) moreover have "x\C \ c *\<^sub>C x \ C" for x c by (metis IntD1 IntD2 IntI \C = A \ B\ assms(1) assms(2) complex_vector.subspace_def closed_csubspace_def) moreover have "0 \ C" using \C = A \ B\ assms(1) assms(2) complex_vector.subspace_def closed_csubspace_def by fastforce ultimately show ?thesis by (simp add: complex_vector.subspace_def) qed moreover have \closed C\ using \C = A \ B\ by (simp add: assms(1) assms(2) closed_Int closed_csubspace.closed) ultimately show ?thesis using \C = A \ B\ by (simp add: closed_csubspace_def) qed lemma closed_csubspace_INF[simp]: assumes a1: "\A\\. closed_csubspace A" shows "closed_csubspace (\\)" proof- have \csubspace (\\)\ by (simp add: assms closed_csubspace.subspace complex_vector.subspace_Inter) moreover have \closed (\\)\ by (simp add: assms closed_Inter closed_csubspace.closed) ultimately show ?thesis by (simp add: closed_csubspace.intro) qed typedef (overloaded) ('a::"{complex_vector,topological_space}") ccsubspace = \{S::'a set. closed_csubspace S}\ morphisms space_as_set Abs_clinear_space using Complex_Vector_Spaces.closed_csubspace_UNIV by blast setup_lifting type_definition_ccsubspace lemma csubspace_space_as_set[simp]: \csubspace (space_as_set S)\ by (metis closed_csubspace_def mem_Collect_eq space_as_set) instantiation ccsubspace :: (complex_normed_vector) scaleC begin lift_definition scaleC_ccsubspace :: "complex \ 'a ccsubspace \ 'a ccsubspace" is "\c S. (*\<^sub>C) c ` S" proof show "csubspace ((*\<^sub>C) c ` S)" if "closed_csubspace S" for c :: complex and S :: "'a set" using that by (simp add: closed_csubspace.subspace complex_vector.linear_subspace_image) show "closed ((*\<^sub>C) c ` S)" if "closed_csubspace S" for c :: complex and S :: "'a set" using that by (simp add: closed_scaleC closed_csubspace.closed) qed lift_definition scaleR_ccsubspace :: "real \ 'a ccsubspace \ 'a ccsubspace" is "\c S. (*\<^sub>R) c ` S" proof show "csubspace ((*\<^sub>R) r ` S)" if "closed_csubspace S" for r :: real and S :: "'a set" using that using bounded_clinear_def bounded_clinear_scaleC_right scaleR_scaleC by (simp add: scaleR_scaleC closed_csubspace.subspace complex_vector.linear_subspace_image) show "closed ((*\<^sub>R) r ` S)" if "closed_csubspace S" for r :: real and S :: "'a set" using that by (simp add: closed_scaling closed_csubspace.closed) qed instance proof show "((*\<^sub>R) r::'a ccsubspace \ _) = (*\<^sub>C) (complex_of_real r)" for r :: real by (simp add: scaleR_scaleC scaleC_ccsubspace_def scaleR_ccsubspace_def) qed end instantiation ccsubspace :: ("{complex_vector,t1_space}") bot begin lift_definition bot_ccsubspace :: \'a ccsubspace\ is \{0}\ by simp instance.. end lemma zero_cblinfun_image[simp]: "0 *\<^sub>C S = bot" for S :: "_ ccsubspace" proof transfer have "(0::'b) \ (\x. 0) ` S" if "closed_csubspace S" for S::"'b set" using that unfolding closed_csubspace_def by (simp add: complex_vector.linear_subspace_image complex_vector.module_hom_zero complex_vector.subspace_0) thus "(*\<^sub>C) 0 ` S = {0::'b}" if "closed_csubspace (S::'b set)" for S :: "'b set" using that by (auto intro !: exI [of _ 0]) qed lemma csubspace_scaleC_invariant: fixes a S assumes \a \ 0\ and \csubspace S\ shows \(*\<^sub>C) a ` S = S\ proof- have \x \ (*\<^sub>C) a ` S \ x \ S\ for x using assms(2) complex_vector.subspace_scale by blast moreover have \x \ S \ x \ (*\<^sub>C) a ` S\ for x proof - assume "x \ S" hence "\c aa. (c / a) *\<^sub>C aa \ S \ c *\<^sub>C aa = x" using assms(2) complex_vector.subspace_def scaleC_one by metis hence "\aa. aa \ S \ a *\<^sub>C aa = x" using assms(1) by auto thus ?thesis by (meson image_iff) qed ultimately show ?thesis by blast qed lemma ccsubspace_scaleC_invariant[simp]: "a \ 0 \ a *\<^sub>C S = S" for S :: "_ ccsubspace" apply transfer by (simp add: closed_csubspace.subspace csubspace_scaleC_invariant) instantiation ccsubspace :: ("{complex_vector,topological_space}") "top" begin lift_definition top_ccsubspace :: \'a ccsubspace\ is \UNIV\ by simp instance .. end lemma ccsubspace_top_not_bot[simp]: "(top::'a::{complex_vector,t1_space,not_singleton} ccsubspace) \ bot" (* The type class t1_space is needed because the definition of bot in ccsubspace needs it *) by (metis UNIV_not_singleton bot_ccsubspace.rep_eq top_ccsubspace.rep_eq) lemma ccsubspace_bot_not_top[simp]: "(bot::'a::{complex_vector,t1_space,not_singleton} ccsubspace) \ top" using ccsubspace_top_not_bot by metis instantiation ccsubspace :: ("{complex_vector,topological_space}") "Inf" begin lift_definition Inf_ccsubspace::\'a ccsubspace set \ 'a ccsubspace\ is \\ S. \ S\ proof fix S :: "'a set set" assume closed: "closed_csubspace x" if \x \ S\ for x show "csubspace (\ S::'a set)" by (simp add: closed closed_csubspace.subspace) show "closed (\ S::'a set)" by (simp add: closed closed_csubspace.closed) qed instance .. end lift_definition ccspan :: "'a::complex_normed_vector set \ 'a ccsubspace" is "\G. closure (cspan G)" proof (rule closed_csubspace.intro) fix S :: "'a set" show "csubspace (closure (cspan S))" by (simp add: closure_is_csubspace) show "closed (closure (cspan S))" by simp qed lemma ccspan_canonical_basis[simp]: "ccspan (set canonical_basis) = top" using ccspan.rep_eq space_as_set_inject top_ccsubspace.rep_eq closure_UNIV is_generator_set by metis lemma ccspan_Inf_def: \ccspan A = Inf {S. A \ space_as_set S}\ for A::\('a::cbanach) set\ proof- have \x \ space_as_set (ccspan A) \ x \ space_as_set (Inf {S. A \ space_as_set S})\ for x::'a proof- assume \x \ space_as_set (ccspan A)\ hence "x \ closure (cspan A)" by (simp add: ccspan.rep_eq) hence \x \ closure (complex_vector.span A)\ unfolding ccspan_def by simp hence \\ y::nat \ 'a. (\ n. y n \ (complex_vector.span A)) \ y \ x\ by (simp add: closure_sequential) then obtain y where \\ n. y n \ (complex_vector.span A)\ and \y \ x\ by blast have \y n \ \ {S. (complex_vector.span A) \ S \ closed_csubspace S}\ for n using \\ n. y n \ (complex_vector.span A)\ by auto have \closed_csubspace S \ closed S\ for S::\'a set\ by (simp add: closed_csubspace.closed) hence \closed ( \ {S. (complex_vector.span A) \ S \ closed_csubspace S})\ by simp hence \x \ \ {S. (complex_vector.span A) \ S \ closed_csubspace S}\ using \y \ x\ using \\n. y n \ \ {S. complex_vector.span A \ S \ closed_csubspace S}\ closed_sequentially by blast moreover have \{S. A \ S \ closed_csubspace S} \ {S. (complex_vector.span A) \ S \ closed_csubspace S}\ using Collect_mono_iff by (simp add: Collect_mono_iff closed_csubspace.subspace complex_vector.span_minimal) ultimately have \x \ \ {S. A \ S \ closed_csubspace S}\ by blast moreover have "(x::'a) \ \ {x. A \ x \ closed_csubspace x}" if "(x::'a) \ \ {S. A \ S \ closed_csubspace S}" for x :: 'a and A :: "'a set" using that by simp ultimately show \x \ space_as_set (Inf {S. A \ space_as_set S})\ apply transfer. qed moreover have \x \ space_as_set (Inf {S. A \ space_as_set S}) \ x \ space_as_set (ccspan A)\ for x::'a proof- assume \x \ space_as_set (Inf {S. A \ space_as_set S})\ hence \x \ \ {S. A \ S \ closed_csubspace S}\ apply transfer by blast moreover have \{S. (complex_vector.span A) \ S \ closed_csubspace S} \ {S. A \ S \ closed_csubspace S}\ using Collect_mono_iff complex_vector.span_superset by fastforce ultimately have \x \ \ {S. (complex_vector.span A) \ S \ closed_csubspace S}\ by blast thus \x \ space_as_set (ccspan A)\ by (metis (no_types, lifting) Inter_iff space_as_set closure_subset mem_Collect_eq ccspan.rep_eq) qed ultimately have \space_as_set (ccspan A) = space_as_set (Inf {S. A \ space_as_set S})\ by blast thus ?thesis using space_as_set_inject by auto qed lemma cspan_singleton_scaleC[simp]: "(a::complex)\0 \ cspan { a *\<^sub>C \ } = cspan {\}" for \::"'a::complex_vector" by (smt complex_vector.dependent_single complex_vector.independent_insert complex_vector.scale_eq_0_iff complex_vector.span_base complex_vector.span_redundant complex_vector.span_scale doubleton_eq_iff insert_absorb insert_absorb2 insert_commute singletonI) lemma closure_is_closed_csubspace[simp]: fixes S::\'a::complex_normed_vector set\ assumes \csubspace S\ shows \closed_csubspace (closure S)\ proof- fix x y :: 'a and c :: complex have "x + y \ closure S" if "x \ closure S" and "y \ closure S" proof- have \\ r. (\ n::nat. r n \ S) \ r \ x\ using closure_sequential that(1) by auto then obtain r where \\ n::nat. r n \ S\ and \r \ x\ by blast have \\ s. (\ n::nat. s n \ S) \ s \ y\ using closure_sequential that(2) by auto then obtain s where \\ n::nat. s n \ S\ and \s \ y\ by blast have \\ n::nat. r n + s n \ S\ using \\n. r n \ S\ \\n. s n \ S\ assms complex_vector.subspace_add by blast moreover have \(\ n. r n + s n) \ x + y\ by (simp add: \r \ x\ \s \ y\ tendsto_add) ultimately show ?thesis using assms that(1) that(2) by (simp add: complex_vector.subspace_add) qed moreover have "c *\<^sub>C x \ closure S" if "x \ closure S" proof- have \\ y. (\ n::nat. y n \ S) \ y \ x\ using Elementary_Topology.closure_sequential that by auto then obtain y where \\ n::nat. y n \ S\ and \y \ x\ by blast have \isCont (scaleC c) x\ by simp hence \(\ n. scaleC c (y n)) \ scaleC c x\ using \y \ x\ by (simp add: isCont_tendsto_compose) from \\ n::nat. y n \ S\ have \\ n::nat. scaleC c (y n) \ S\ using assms complex_vector.subspace_scale by auto thus ?thesis using assms that by (simp add: complex_vector.subspace_scale) qed moreover have "0 \ closure S" by (simp add: assms complex_vector.subspace_0) moreover have "closed (closure S)" by auto ultimately show ?thesis by (simp add: assms closed_csubspace_def) qed lemma ccspan_singleton_scaleC[simp]: "(a::complex)\0 \ ccspan {a *\<^sub>C \} = ccspan {\}" apply transfer by simp lemma clinear_continuous_at: assumes \bounded_clinear f\ shows \isCont f x\ by (simp add: assms bounded_clinear.bounded_linear linear_continuous_at) lemma clinear_continuous_within: assumes \bounded_clinear f\ shows \continuous (at x within s) f\ by (simp add: assms bounded_clinear.bounded_linear linear_continuous_within) lemma antilinear_continuous_at: assumes \bounded_antilinear f\ shows \isCont f x\ by (simp add: assms bounded_antilinear.bounded_linear linear_continuous_at) lemma antilinear_continuous_within: assumes \bounded_antilinear f\ shows \continuous (at x within s) f\ by (simp add: assms bounded_antilinear.bounded_linear linear_continuous_within) lemma bounded_clinear_eq_on: fixes A B :: "'a::complex_normed_vector \ 'b::complex_normed_vector" assumes \bounded_clinear A\ and \bounded_clinear B\ and eq: \\x. x \ G \ A x = B x\ and t: \t \ closure (cspan G)\ shows \A t = B t\ proof - have eq': \A t = B t\ if \t \ cspan G\ for t using _ _ that eq apply (rule complex_vector.linear_eq_on) by (auto simp: assms bounded_clinear.clinear) have \A t - B t = 0\ using _ _ t apply (rule continuous_constant_on_closure) by (auto simp add: eq' assms(1) assms(2) clinear_continuous_at continuous_at_imp_continuous_on) then show ?thesis by auto qed instantiation ccsubspace :: ("{complex_vector,topological_space}") "order" begin lift_definition less_eq_ccsubspace :: \'a ccsubspace \ 'a ccsubspace \ bool\ is \(\)\. declare less_eq_ccsubspace_def[code del] lift_definition less_ccsubspace :: \'a ccsubspace \ 'a ccsubspace \ bool\ is \(\)\. declare less_ccsubspace_def[code del] instance proof fix x y z :: "'a ccsubspace" show "(x < y) = (x \ y \ \ y \ x)" by (simp add: less_eq_ccsubspace.rep_eq less_le_not_le less_ccsubspace.rep_eq) show "x \ x" by (simp add: less_eq_ccsubspace.rep_eq) show "x \ z" if "x \ y" and "y \ z" using that less_eq_ccsubspace.rep_eq by auto show "x = y" if "x \ y" and "y \ x" using that by (simp add: space_as_set_inject less_eq_ccsubspace.rep_eq) qed end lemma ccspan_leqI: assumes \M \ space_as_set S\ shows \ccspan M \ S\ using assms apply transfer by (simp add: closed_csubspace.closed closure_minimal complex_vector.span_minimal) lemma ccspan_mono: assumes \A \ B\ shows \ccspan A \ ccspan B\ apply (transfer fixing: A B) by (simp add: assms closure_mono complex_vector.span_mono) lemma bounded_sesquilinear_add: \bounded_sesquilinear (\ x y. A x y + B x y)\ if \bounded_sesquilinear A\ and \bounded_sesquilinear B\ proof fix a a' :: 'a and b b' :: 'b and r :: complex show "A (a + a') b + B (a + a') b = (A a b + B a b) + (A a' b + B a' b)" by (simp add: bounded_sesquilinear.add_left that(1) that(2)) show \A a (b + b') + B a (b + b') = (A a b + B a b) + (A a b' + B a b')\ by (simp add: bounded_sesquilinear.add_right that(1) that(2)) show \A (r *\<^sub>C a) b + B (r *\<^sub>C a) b = cnj r *\<^sub>C (A a b + B a b)\ by (simp add: bounded_sesquilinear.scaleC_left scaleC_add_right that(1) that(2)) show \A a (r *\<^sub>C b) + B a (r *\<^sub>C b) = r *\<^sub>C (A a b + B a b)\ by (simp add: bounded_sesquilinear.scaleC_right scaleC_add_right that(1) that(2)) show \\K. \a b. norm (A a b + B a b) \ norm a * norm b * K\ proof- have \\ KA. \ a b. norm (A a b) \ norm a * norm b * KA\ by (simp add: bounded_sesquilinear.bounded that(1)) then obtain KA where \\ a b. norm (A a b) \ norm a * norm b * KA\ by blast have \\ KB. \ a b. norm (B a b) \ norm a * norm b * KB\ by (simp add: bounded_sesquilinear.bounded that(2)) then obtain KB where \\ a b. norm (B a b) \ norm a * norm b * KB\ by blast have \norm (A a b + B a b) \ norm a * norm b * (KA + KB)\ for a b proof- have \norm (A a b + B a b) \ norm (A a b) + norm (B a b)\ using norm_triangle_ineq by blast also have \\ \ norm a * norm b * KA + norm a * norm b * KB\ using \\ a b. norm (A a b) \ norm a * norm b * KA\ \\ a b. norm (B a b) \ norm a * norm b * KB\ using add_mono by blast also have \\= norm a * norm b * (KA + KB)\ by (simp add: mult.commute ring_class.ring_distribs(2)) finally show ?thesis by blast qed thus ?thesis by blast qed qed lemma bounded_sesquilinear_uminus: \bounded_sesquilinear (\ x y. - A x y)\ if \bounded_sesquilinear A\ proof fix a a' :: 'a and b b' :: 'b and r :: complex show "- A (a + a') b = (- A a b) + (- A a' b)" by (simp add: bounded_sesquilinear.add_left that) show \- A a (b + b') = (- A a b) + (- A a b')\ by (simp add: bounded_sesquilinear.add_right that) show \- A (r *\<^sub>C a) b = cnj r *\<^sub>C (- A a b)\ by (simp add: bounded_sesquilinear.scaleC_left that) show \- A a (r *\<^sub>C b) = r *\<^sub>C (- A a b)\ by (simp add: bounded_sesquilinear.scaleC_right that) show \\K. \a b. norm (- A a b) \ norm a * norm b * K\ proof- have \\ KA. \ a b. norm (A a b) \ norm a * norm b * KA\ by (simp add: bounded_sesquilinear.bounded that(1)) then obtain KA where \\ a b. norm (A a b) \ norm a * norm b * KA\ by blast have \norm (- A a b) \ norm a * norm b * KA\ for a b by (simp add: \\a b. norm (A a b) \ norm a * norm b * KA\) thus ?thesis by blast qed qed lemma bounded_sesquilinear_diff: \bounded_sesquilinear (\ x y. A x y - B x y)\ if \bounded_sesquilinear A\ and \bounded_sesquilinear B\ proof - have \bounded_sesquilinear (\ x y. - B x y)\ using that(2) by (rule bounded_sesquilinear_uminus) then have \bounded_sesquilinear (\ x y. A x y + (- B x y))\ using that(1) by (rule bounded_sesquilinear_add[rotated]) then show ?thesis by auto qed lemma ccsubspace_leI: assumes t1: "space_as_set A \ space_as_set B" shows "A \ B" using t1 apply transfer by - lemma ccspan_of_empty[simp]: "ccspan {} = bot" proof transfer show "closure (cspan {}) = {0::'a}" by simp qed instantiation ccsubspace :: ("{complex_vector,topological_space}") inf begin lift_definition inf_ccsubspace :: "'a ccsubspace \ 'a ccsubspace \ 'a ccsubspace" is "(\)" by simp instance .. end lemma space_as_set_inf[simp]: "space_as_set (A \ B) = space_as_set A \ space_as_set B" by (rule inf_ccsubspace.rep_eq) instantiation ccsubspace :: ("{complex_vector,topological_space}") order_top begin instance proof show "a \ \" for a :: "'a ccsubspace" apply transfer by simp qed end instantiation ccsubspace :: ("{complex_vector,t1_space}") order_bot begin instance proof show "(\::'a ccsubspace) \ a" for a :: "'a ccsubspace" apply transfer apply auto using closed_csubspace.subspace complex_vector.subspace_0 by blast qed end instantiation ccsubspace :: ("{complex_vector,topological_space}") semilattice_inf begin instance proof fix x y z :: \'a ccsubspace\ show "x \ y \ x" apply transfer by simp show "x \ y \ y" apply transfer by simp show "x \ y \ z" if "x \ y" and "x \ z" using that apply transfer by simp qed end instantiation ccsubspace :: ("{complex_vector,t1_space}") zero begin definition zero_ccsubspace :: "'a ccsubspace" where [simp]: "zero_ccsubspace = bot" lemma zero_ccsubspace_transfer[transfer_rule]: \pcr_ccsubspace (=) {0} 0\ unfolding zero_ccsubspace_def by transfer_prover instance .. end subsection \Closed sums\ definition closed_sum:: \'a::{semigroup_add,topological_space} set \ 'a set \ 'a set\ where \closed_sum A B = closure (A + B)\ notation closed_sum (infixl "+\<^sub>M" 65) lemma closed_sum_comm: \A +\<^sub>M B = B +\<^sub>M A\ for A B :: "_::ab_semigroup_add" by (simp add: add.commute closed_sum_def) lemma closed_sum_left_subset: \0 \ B \ A \ A +\<^sub>M B\ for A B :: "_::monoid_add" by (metis add.right_neutral closed_sum_def closure_subset in_mono set_plus_intro subsetI) lemma closed_sum_right_subset: \0 \ A \ B \ A +\<^sub>M B\ for A B :: "_::monoid_add" by (metis add.left_neutral closed_sum_def closure_subset set_plus_intro subset_iff) lemma finite_cspan_closed_csubspace: assumes "finite (S::'a::complex_normed_vector set)" shows "closed_csubspace (cspan S)" by (simp add: assms closed_csubspace.intro) lemma closed_sum_is_sup: fixes A B C:: \('a::{complex_vector,topological_space}) set\ assumes \closed_csubspace C\ assumes \A \ C\ and \B \ C\ shows \(A +\<^sub>M B) \ C\ proof - have \A + B \ C\ using assms unfolding set_plus_def using closed_csubspace.subspace complex_vector.subspace_add by blast then show \(A +\<^sub>M B) \ C\ unfolding closed_sum_def using \closed_csubspace C\ by (simp add: closed_csubspace.closed closure_minimal) qed lemma closed_subspace_closed_sum: fixes A B::"('a::complex_normed_vector) set" assumes a1: \csubspace A\ and a2: \csubspace B\ shows \closed_csubspace (A +\<^sub>M B)\ using a1 a2 closed_sum_def by (metis closure_is_closed_csubspace csubspace_set_plus) lemma closed_sum_assoc: fixes A B C::"'a::real_normed_vector set" shows \A +\<^sub>M (B +\<^sub>M C) = (A +\<^sub>M B) +\<^sub>M C\ proof - have \A + closure B \ closure (A + B)\ for A B :: "'a set" by (meson closure_subset closure_sum dual_order.trans order_refl set_plus_mono2) then have \A +\<^sub>M (B +\<^sub>M C) = closure (A + (B + C))\ unfolding closed_sum_def by (meson antisym_conv closed_closure closure_minimal closure_mono closure_subset equalityD1 set_plus_mono2) moreover have \closure A + B \ closure (A + B)\ for A B :: "'a set" by (meson closure_subset closure_sum dual_order.trans order_refl set_plus_mono2) then have \(A +\<^sub>M B) +\<^sub>M C = closure ((A + B) + C)\ unfolding closed_sum_def by (meson closed_closure closure_minimal closure_mono closure_subset eq_iff set_plus_mono2) ultimately show ?thesis by (simp add: ab_semigroup_add_class.add_ac(1)) qed lemma closed_sum_zero_left[simp]: fixes A :: \('a::{monoid_add, topological_space}) set\ shows \{0} +\<^sub>M A = closure A\ unfolding closed_sum_def by (metis add.left_neutral set_zero) lemma closed_sum_zero_right[simp]: fixes A :: \('a::{monoid_add, topological_space}) set\ shows \A +\<^sub>M {0} = closure A\ unfolding closed_sum_def by (metis add.right_neutral set_zero) lemma closed_sum_closure_right[simp]: fixes A B :: \'a::real_normed_vector set\ shows \A +\<^sub>M closure B = A +\<^sub>M B\ by (metis closed_sum_assoc closed_sum_def closed_sum_zero_right closure_closure) lemma closed_sum_closure_left[simp]: fixes A B :: \'a::real_normed_vector set\ shows \closure A +\<^sub>M B = A +\<^sub>M B\ by (simp add: closed_sum_comm) lemma closed_sum_mono_left: assumes \A \ B\ shows \A +\<^sub>M C \ B +\<^sub>M C\ by (simp add: assms closed_sum_def closure_mono set_plus_mono2) lemma closed_sum_mono_right: assumes \A \ B\ shows \C +\<^sub>M A \ C +\<^sub>M B\ by (simp add: assms closed_sum_def closure_mono set_plus_mono2) instantiation ccsubspace :: (complex_normed_vector) sup begin lift_definition sup_ccsubspace :: "'a ccsubspace \ 'a ccsubspace \ 'a ccsubspace" \ \Note that \<^term>\A+B\ would not be a closed subspace, we need the closure. See, e.g., \<^url>\https://math.stackexchange.com/a/1786792/403528\.\ is "\A B::'a set. A +\<^sub>M B" by (simp add: closed_subspace_closed_sum) instance .. end lemma closed_sum_cspan[simp]: shows \cspan X +\<^sub>M cspan Y = closure (cspan (X \ Y))\ by (smt (verit, best) Collect_cong closed_sum_def complex_vector.span_Un set_plus_def) lemma closure_image_closed_sum: assumes \bounded_linear U\ shows \closure (U ` (A +\<^sub>M B)) = closure (U ` A) +\<^sub>M closure (U ` B)\ proof - have \closure (U ` (A +\<^sub>M B)) = closure (U ` closure (closure A + closure B))\ unfolding closed_sum_def by (smt (verit, best) closed_closure closure_minimal closure_mono closure_subset closure_sum set_plus_mono2 subset_antisym) also have \\ = closure (U ` (closure A + closure B))\ using assms closure_bounded_linear_image_subset_eq by blast also have \\ = closure (U ` closure A + U ` closure B)\ apply (subst image_set_plus) by (simp_all add: assms bounded_linear.linear) also have \\ = closure (closure (U ` A) + closure (U ` B))\ by (smt (verit, ccfv_SIG) assms closed_closure closure_bounded_linear_image_subset closure_bounded_linear_image_subset_eq closure_minimal closure_mono closure_sum dual_order.eq_iff set_plus_mono2) also have \\ = closure (U ` A) +\<^sub>M closure (U ` B)\ using closed_sum_def by blast finally show ?thesis by - qed lemma ccspan_union: "ccspan A \ ccspan B = ccspan (A \ B)" apply transfer by simp instantiation ccsubspace :: (complex_normed_vector) "Sup" begin lift_definition Sup_ccsubspace::\'a ccsubspace set \ 'a ccsubspace\ is \\S. closure (complex_vector.span (Union S))\ proof show "csubspace (closure (complex_vector.span (\ S::'a set)))" if "\x::'a set. x \ S \ closed_csubspace x" for S :: "'a set set" using that by (simp add: closure_is_closed_csubspace) show "closed (closure (complex_vector.span (\ S::'a set)))" if "\x. (x::'a set) \ S \ closed_csubspace x" for S :: "'a set set" using that by simp qed instance.. end instance ccsubspace :: ("{complex_normed_vector}") semilattice_sup proof fix x y z :: \'a ccsubspace\ show \x \ sup x y\ apply transfer by (simp add: closed_csubspace_def closed_sum_left_subset complex_vector.subspace_0) show "y \ sup x y" apply transfer by (simp add: closed_csubspace_def closed_sum_right_subset complex_vector.subspace_0) show "sup x y \ z" if "x \ z" and "y \ z" using that apply transfer apply (rule closed_sum_is_sup) by auto qed instance ccsubspace :: ("{complex_normed_vector}") complete_lattice proof show "Inf A \ x" if "x \ A" for x :: "'a ccsubspace" and A :: "'a ccsubspace set" using that apply transfer by auto have b1: "z \ \ A" if "Ball A closed_csubspace" and "closed_csubspace z" and "(\x. closed_csubspace x \ x \ A \ z \ x)" for z::"'a set" and A using that by auto show "z \ Inf A" if "\x::'a ccsubspace. x \ A \ z \ x" for A :: "'a ccsubspace set" and z :: "'a ccsubspace" using that apply transfer using b1 by blast show "x \ Sup A" if "x \ A" for x :: "'a ccsubspace" and A :: "'a ccsubspace set" using that apply transfer by (meson Union_upper closure_subset complex_vector.span_superset dual_order.trans) show "Sup A \ z" if "\x::'a ccsubspace. x \ A \ x \ z" for A :: "'a ccsubspace set" and z :: "'a ccsubspace" using that apply transfer proof - fix A :: "'a set set" and z :: "'a set" assume A_closed: "Ball A closed_csubspace" assume "closed_csubspace z" assume in_z: "\x. closed_csubspace x \ x \ A \ x \ z" from A_closed in_z have \V \ z\ if \V \ A\ for V by (simp add: that) then have \\ A \ z\ by (simp add: Sup_le_iff) with \closed_csubspace z\ show "closure (cspan (\ A)) \ z" by (simp add: closed_csubspace_def closure_minimal complex_vector.span_def subset_hull) qed show "Inf {} = (top::'a ccsubspace)" using \\z A. (\x. x \ A \ z \ x) \ z \ Inf A\ top.extremum_uniqueI by auto show "Sup {} = (bot::'a ccsubspace)" using \\z A. (\x. x \ A \ x \ z) \ Sup A \ z\ bot.extremum_uniqueI by auto qed instantiation ccsubspace :: (complex_normed_vector) comm_monoid_add begin definition plus_ccsubspace :: "'a ccsubspace \ _ \ _" where [simp]: "plus_ccsubspace = sup" instance proof fix a b c :: \'a ccsubspace\ show "a + b + c = a + (b + c)" using sup.assoc by auto show "a + b = b + a" by (simp add: sup.commute) show "0 + a = a" by (simp add: zero_ccsubspace_def) qed end lemma ccsubspace_plus_sup: "y \ x \ z \ x \ y + z \ x" for x y z :: "'a::complex_normed_vector ccsubspace" unfolding plus_ccsubspace_def by auto lemma ccsubspace_Sup_empty: "Sup {} = (0::_ ccsubspace)" unfolding zero_ccsubspace_def by auto lemma ccsubspace_add_right_incr[simp]: "a \ a + c" for a::"_ ccsubspace" by (simp add: add_increasing2) lemma ccsubspace_add_left_incr[simp]: "a \ c + a" for a::"_ ccsubspace" by (simp add: add_increasing) subsection \Conjugate space\ typedef 'a conjugate_space = "UNIV :: 'a set" morphisms from_conjugate_space to_conjugate_space .. setup_lifting type_definition_conjugate_space instantiation conjugate_space :: (complex_vector) complex_vector begin lift_definition scaleC_conjugate_space :: \complex \ 'a conjugate_space \ 'a conjugate_space\ is \\c x. cnj c *\<^sub>C x\. lift_definition scaleR_conjugate_space :: \real \ 'a conjugate_space \ 'a conjugate_space\ is \\r x. r *\<^sub>R x\. lift_definition plus_conjugate_space :: "'a conjugate_space \ 'a conjugate_space \ 'a conjugate_space" is "(+)". lift_definition uminus_conjugate_space :: "'a conjugate_space \ 'a conjugate_space" is \\x. -x\. lift_definition zero_conjugate_space :: "'a conjugate_space" is 0. lift_definition minus_conjugate_space :: "'a conjugate_space \ 'a conjugate_space \ 'a conjugate_space" is "(-)". instance apply (intro_classes; transfer) by (simp_all add: scaleR_scaleC scaleC_add_right scaleC_left.add) end instantiation conjugate_space :: (complex_normed_vector) complex_normed_vector begin lift_definition sgn_conjugate_space :: "'a conjugate_space \ 'a conjugate_space" is "sgn". lift_definition norm_conjugate_space :: "'a conjugate_space \ real" is norm. lift_definition dist_conjugate_space :: "'a conjugate_space \ 'a conjugate_space \ real" is dist. lift_definition uniformity_conjugate_space :: "('a conjugate_space \ 'a conjugate_space) filter" is uniformity. lift_definition open_conjugate_space :: "'a conjugate_space set \ bool" is "open". instance apply (intro_classes; transfer) by (simp_all add: dist_norm sgn_div_norm open_uniformity uniformity_dist norm_triangle_ineq) end instantiation conjugate_space :: (cbanach) cbanach begin instance apply intro_classes unfolding Cauchy_def convergent_def LIMSEQ_def apply transfer using Cauchy_convergent unfolding Cauchy_def convergent_def LIMSEQ_def by metis end lemma bounded_antilinear_to_conjugate_space[simp]: \bounded_antilinear to_conjugate_space\ by (rule bounded_antilinear_intro[where K=1]; transfer; auto) lemma bounded_antilinear_from_conjugate_space[simp]: \bounded_antilinear from_conjugate_space\ by (rule bounded_antilinear_intro[where K=1]; transfer; auto) lemma antilinear_to_conjugate_space[simp]: \antilinear to_conjugate_space\ by (rule antilinearI; transfer, auto) lemma antilinear_from_conjugate_space[simp]: \antilinear from_conjugate_space\ by (rule antilinearI; transfer, auto) lemma cspan_to_conjugate_space[simp]: "cspan (to_conjugate_space ` X) = to_conjugate_space ` cspan X" unfolding complex_vector.span_def complex_vector.subspace_def hull_def apply transfer apply simp by (metis (no_types, opaque_lifting) complex_cnj_cnj) lemma surj_to_conjugate_space[simp]: "surj to_conjugate_space" by (meson surj_def to_conjugate_space_cases) lemmas has_derivative_scaleC[simp, derivative_intros] = bounded_bilinear.FDERIV[OF bounded_cbilinear_scaleC[THEN bounded_cbilinear.bounded_bilinear]] lemma norm_to_conjugate_space[simp]: \norm (to_conjugate_space x) = norm x\ by (fact norm_conjugate_space.abs_eq) lemma norm_from_conjugate_space[simp]: \norm (from_conjugate_space x) = norm x\ by (simp add: norm_conjugate_space.rep_eq) lemma closure_to_conjugate_space: \closure (to_conjugate_space ` X) = to_conjugate_space ` closure X\ proof - have 1: \to_conjugate_space ` closure X \ closure (to_conjugate_space ` X)\ apply (rule closure_bounded_linear_image_subset) by (simp add: bounded_antilinear.bounded_linear) have \\ = to_conjugate_space ` from_conjugate_space ` closure (to_conjugate_space ` X)\ by (simp add: from_conjugate_space_inverse image_image) also have \\ \ to_conjugate_space ` closure (from_conjugate_space ` to_conjugate_space ` X)\ apply (rule image_mono) apply (rule closure_bounded_linear_image_subset) by (simp add: bounded_antilinear.bounded_linear) also have \\ = to_conjugate_space ` closure X\ by (simp add: to_conjugate_space_inverse image_image) finally show ?thesis using 1 by simp qed lemma closure_from_conjugate_space: \closure (from_conjugate_space ` X) = from_conjugate_space ` closure X\ proof - have 1: \from_conjugate_space ` closure X \ closure (from_conjugate_space ` X)\ apply (rule closure_bounded_linear_image_subset) by (simp add: bounded_antilinear.bounded_linear) have \\ = from_conjugate_space ` to_conjugate_space ` closure (from_conjugate_space ` X)\ by (simp add: to_conjugate_space_inverse image_image) also have \\ \ from_conjugate_space ` closure (to_conjugate_space ` from_conjugate_space ` X)\ apply (rule image_mono) apply (rule closure_bounded_linear_image_subset) by (simp add: bounded_antilinear.bounded_linear) also have \\ = from_conjugate_space ` closure X\ by (simp add: from_conjugate_space_inverse image_image) finally show ?thesis using 1 by simp qed lemma bounded_antilinear_eq_on: fixes A B :: "'a::complex_normed_vector \ 'b::complex_normed_vector" assumes \bounded_antilinear A\ and \bounded_antilinear B\ and eq: \\x. x \ G \ A x = B x\ and t: \t \ closure (cspan G)\ shows \A t = B t\ proof - let ?A = \\x. A (from_conjugate_space x)\ and ?B = \\x. B (from_conjugate_space x)\ and ?G = \to_conjugate_space ` G\ and ?t = \to_conjugate_space t\ have \bounded_clinear ?A\ and \bounded_clinear ?B\ by (auto intro!: bounded_antilinear_o_bounded_antilinear[OF \bounded_antilinear A\] bounded_antilinear_o_bounded_antilinear[OF \bounded_antilinear B\]) moreover from eq have \\x. x \ ?G \ ?A x = ?B x\ by (metis image_iff iso_tuple_UNIV_I to_conjugate_space_inverse) moreover from t have \?t \ closure (cspan ?G)\ by (metis bounded_antilinear.bounded_linear bounded_antilinear_to_conjugate_space closure_bounded_linear_image_subset cspan_to_conjugate_space imageI subsetD) ultimately have \?A ?t = ?B ?t\ by (rule bounded_clinear_eq_on) then show \A t = B t\ by (simp add: to_conjugate_space_inverse) qed instantiation complex :: basis_enum begin definition "canonical_basis = [1::complex]" instance proof show "distinct (canonical_basis::complex list)" by (simp add: canonical_basis_complex_def) show "cindependent (set (canonical_basis::complex list))" unfolding canonical_basis_complex_def by auto show "cspan (set (canonical_basis::complex list)) = UNIV" unfolding canonical_basis_complex_def apply (auto simp add: cspan_raw_def vector_space_over_itself.span_Basis) by (metis complex_scaleC_def complex_vector.span_base complex_vector.span_scale cspan_raw_def insertI1 mult.right_neutral) qed end lemma csubspace_is_convex[simp]: assumes a1: "csubspace M" shows "convex M" proof- have \\x\M. \y\ M. \u. \v. u *\<^sub>C x + v *\<^sub>C y \ M\ using a1 by (simp add: complex_vector.subspace_def) hence \\x\M. \y\M. \u::real. \v::real. u *\<^sub>R x + v *\<^sub>R y \ M\ by (simp add: scaleR_scaleC) hence \\x\M. \y\M. \u\0. \v\0. u + v = 1 \ u *\<^sub>R x + v *\<^sub>R y \M\ by blast thus ?thesis using convex_def by blast qed lemma kernel_is_csubspace[simp]: assumes a1: "clinear f" shows "csubspace (f -` {0})" proof- have w3: \t *\<^sub>C x \ {x. f x = 0}\ if b1: "x \ {x. f x = 0}" for x t by (metis assms complex_vector.linear_subspace_kernel complex_vector.subspace_def that) have \f 0 = 0\ by (simp add: assms complex_vector.linear_0) hence s2: \0 \ {x. f x = 0}\ by blast have w4: "x + y \ {x. f x = 0}" if c1: "x \ {x. f x = 0}" and c2: "y \ {x. f x = 0}" for x y using assms c1 c2 complex_vector.linear_add by fastforce have s4: \c *\<^sub>C t \ {x. f x = 0}\ if "t \ {x. f x = 0}" for t c using that w3 by auto have s5: "u + v \ {x. f x = 0}" if "u \ {x. f x = 0}" and "v \ {x. f x = 0}" for u v using w4 that(1) that(2) by auto have f3: "f -` {b. b = 0 \ b \ {}} = {a. f a = 0}" by blast have "csubspace {a. f a = 0}" by (metis complex_vector.subspace_def s2 s4 s5) thus ?thesis using f3 by auto qed lemma kernel_is_closed_csubspace[simp]: assumes a1: "bounded_clinear f" shows "closed_csubspace (f -` {0})" proof- have \csubspace (f -` {0})\ using assms bounded_clinear.clinear complex_vector.linear_subspace_vimage complex_vector.subspace_single_0 by blast have "L \ {x. f x = 0}" if "r \ L" and "\ n. r n \ {x. f x = 0}" for r and L proof- have d1: \\ n. f (r n) = 0\ using that(2) by auto have \(\ n. f (r n)) \ f L\ using assms clinear_continuous_at continuous_within_tendsto_compose' that(1) by fastforce hence \(\ n. 0) \ f L\ using d1 by simp hence \f L = 0\ using limI by fastforce thus ?thesis by blast qed then have s3: \closed (f -` {0})\ using closed_sequential_limits by force with \csubspace (f -` {0})\ show ?thesis using closed_csubspace.intro by blast qed lemma range_is_clinear[simp]: assumes a1: "clinear f" shows "csubspace (range f)" using assms complex_vector.linear_subspace_image complex_vector.subspace_UNIV by blast lemma ccspan_superset: \A \ space_as_set (ccspan A)\ for A :: \'a::complex_normed_vector set\ apply transfer by (meson closure_subset complex_vector.span_superset subset_trans) subsection \Product is a Complex Vector Space\ (* Follows closely Product_Vector.thy *) instantiation prod :: (complex_vector, complex_vector) complex_vector begin definition scaleC_prod_def: "scaleC r A = (scaleC r (fst A), scaleC r (snd A))" lemma fst_scaleC [simp]: "fst (scaleC r A) = scaleC r (fst A)" unfolding scaleC_prod_def by simp lemma snd_scaleC [simp]: "snd (scaleC r A) = scaleC r (snd A)" unfolding scaleC_prod_def by simp proposition scaleC_Pair [simp]: "scaleC r (a, b) = (scaleC r a, scaleC r b)" unfolding scaleC_prod_def by simp instance proof fix a b :: complex and x y :: "'a \ 'b" show "scaleC a (x + y) = scaleC a x + scaleC a y" by (simp add: scaleC_add_right scaleC_prod_def) show "scaleC (a + b) x = scaleC a x + scaleC b x" by (simp add: Complex_Vector_Spaces.scaleC_prod_def scaleC_left.add) show "scaleC a (scaleC b x) = scaleC (a * b) x" by (simp add: prod_eq_iff) show "scaleC 1 x = x" by (simp add: prod_eq_iff) show \(scaleR :: _ \ _ \ 'a*'b) r = (*\<^sub>C) (complex_of_real r)\ for r by (auto intro!: ext simp: scaleR_scaleC scaleC_prod_def scaleR_prod_def) qed end lemma module_prod_scale_eq_scaleC: "module_prod.scale (*\<^sub>C) (*\<^sub>C) = scaleC" apply (rule ext) apply (rule ext) apply (subst module_prod.scale_def) subgoal by unfold_locales by (simp add: scaleC_prod_def) interpretation complex_vector?: vector_space_prod "scaleC::_\_\'a::complex_vector" "scaleC::_\_\'b::complex_vector" rewrites "scale = ((*\<^sub>C)::_\_\('a \ 'b))" and "module.dependent (*\<^sub>C) = cdependent" and "module.representation (*\<^sub>C) = crepresentation" and "module.subspace (*\<^sub>C) = csubspace" and "module.span (*\<^sub>C) = cspan" and "vector_space.extend_basis (*\<^sub>C) = cextend_basis" and "vector_space.dim (*\<^sub>C) = cdim" and "Vector_Spaces.linear (*\<^sub>C) (*\<^sub>C) = clinear" subgoal by unfold_locales subgoal by (fact module_prod_scale_eq_scaleC) unfolding cdependent_raw_def crepresentation_raw_def csubspace_raw_def cspan_raw_def cextend_basis_raw_def cdim_raw_def clinear_def by (rule refl)+ subsection \Copying existing theorems into sublocales\ context bounded_clinear begin interpretation bounded_linear f by (rule bounded_linear) lemmas continuous = continuous lemmas uniform_limit = uniform_limit lemmas Cauchy = Cauchy end context bounded_antilinear begin interpretation bounded_linear f by (rule bounded_linear) lemmas continuous = continuous lemmas uniform_limit = uniform_limit end context bounded_cbilinear begin interpretation bounded_bilinear prod by simp lemmas tendsto = tendsto lemmas isCont = isCont end context bounded_sesquilinear begin interpretation bounded_bilinear prod by simp lemmas tendsto = tendsto lemmas isCont = isCont end lemmas tendsto_scaleC [tendsto_intros] = bounded_cbilinear.tendsto [OF bounded_cbilinear_scaleC] +unbundle no_lattice_syntax + end diff --git a/thys/Complex_Bounded_Operators/extra/Extra_Lattice.thy b/thys/Complex_Bounded_Operators/extra/Extra_Lattice.thy --- a/thys/Complex_Bounded_Operators/extra/Extra_Lattice.thy +++ b/thys/Complex_Bounded_Operators/extra/Extra_Lattice.thy @@ -1,271 +1,249 @@ section \\Extra_Lattice\ -- Additional results about lattices\ theory Extra_Lattice imports Main begin subsection\\Lattice_Missing\ -- Miscellaneous missing facts about lattices\ -text \Two bundles to activate and deactivate lattice specific notation (e.g., \\\ etc.). - Activate the notation locally via "@{theory_text \includes lattice_notation\}" in a lemma statement. - (Or sandwich a declaration using that notation between "@{theory_text \unbundle lattice_notation ... unbundle no_lattice_notation\}.)\ - -bundle lattice_notation begin -notation inf (infixl "\" 70) -notation sup (infixl "\" 65) -notation Inf ("\") -notation Sup ("\") -notation bot ("\") -notation top ("\") -end - -bundle no_lattice_notation begin -notation inf (infixl "\" 70) -notation sup (infixl "\" 65) -notation Inf ("\") -notation Sup ("\") -notation bot ("\") -notation top ("\") -end - -unbundle lattice_notation +unbundle lattice_syntax text \The following class \complemented_lattice\ describes complemented lattices (with \<^const>\uminus\ for the complement). The definition follows \<^url>\https://en.wikipedia.org/wiki/Complemented_lattice#Definition_and_basic_properties\. Additionally, it adopts the convention from \<^class>\boolean_algebra\ of defining \<^const>\minus\ in terms of the complement.\ class complemented_lattice = bounded_lattice + uminus + minus + assumes inf_compl_bot[simp]: "inf x (-x) = bot" and sup_compl_top[simp]: "sup x (-x) = top" and diff_eq: "x - y = inf x (- y)" begin lemma dual_complemented_lattice: "class.complemented_lattice (\x y. x \ (- y)) uminus sup greater_eq greater inf \ \" proof (rule class.complemented_lattice.intro) show "class.bounded_lattice (\) (\x y. (y::'a) \ x) (\x y. y < x) (\) \ \" by (rule dual_bounded_lattice) show "class.complemented_lattice_axioms (\x y. (x::'a) \ - y) uminus (\) (\) \ \" by (unfold_locales, auto simp add: diff_eq) qed lemma compl_inf_bot [simp]: "inf (- x) x = bot" by (simp add: inf_commute) lemma compl_sup_top [simp]: "sup (- x) x = top" by (simp add: sup_commute) end class complete_complemented_lattice = complemented_lattice + complete_lattice text \The following class \complemented_lattice\ describes orthocomplemented lattices, following \<^url>\https://en.wikipedia.org/wiki/Complemented_lattice#Orthocomplementation\.\ class orthocomplemented_lattice = complemented_lattice + assumes ortho_involution[simp]: "- (- x) = x" and ortho_antimono: "x \ y \ -x \ -y" begin lemma dual_orthocomplemented_lattice: "class.orthocomplemented_lattice (\x y. x \ - y) uminus sup greater_eq greater inf \ \" proof (rule class.orthocomplemented_lattice.intro) show "class.complemented_lattice (\x y. (x::'a) \ - y) uminus (\) (\x y. y \ x) (\x y. y < x) (\) \ \" by (rule dual_complemented_lattice) show "class.orthocomplemented_lattice_axioms uminus (\x y. (y::'a) \ x)" by (unfold_locales, auto simp add: diff_eq intro: ortho_antimono) qed lemma compl_eq_compl_iff [simp]: "- x = - y \ x = y" by (metis ortho_involution) lemma compl_bot_eq [simp]: "- bot = top" by (metis inf_compl_bot inf_top_left ortho_involution) lemma compl_top_eq [simp]: "- top = bot" using compl_bot_eq ortho_involution by blast text \De Morgan's law\ (* Proof from: https://planetmath.org/orthocomplementedlattice *) lemma compl_sup [simp]: "- (x \ y) = - x \ - y" proof - have "- (x \ y) \ - x" by (simp add: ortho_antimono) moreover have "- (x \ y) \ - y" by (simp add: ortho_antimono) ultimately have 1: "- (x \ y) \ - x \ - y" by (simp add: sup.coboundedI1) have \x \ - (-x \ -y)\ by (metis inf.cobounded1 ortho_antimono ortho_involution) moreover have \y \ - (-x \ -y)\ by (metis inf.cobounded2 ortho_antimono ortho_involution) ultimately have \x \ y \ - (-x \ -y)\ by auto hence 2: \-x \ -y \ - (x \ y)\ using ortho_antimono by fastforce from 1 2 show ?thesis using dual_order.antisym by blast qed text \De Morgan's law\ lemma compl_inf [simp]: "- (x \ y) = - x \ - y" using compl_sup by (metis ortho_involution) lemma compl_mono: assumes "x \ y" shows "- y \ - x" by (simp add: assms local.ortho_antimono) lemma compl_le_compl_iff [simp]: "- x \ - y \ y \ x" by (auto dest: compl_mono) lemma compl_le_swap1: assumes "y \ - x" shows "x \ -y" using assms ortho_antimono by fastforce lemma compl_le_swap2: assumes "- y \ x" shows "- x \ y" using assms local.ortho_antimono by fastforce lemma compl_less_compl_iff[simp]: "- x < - y \ y < x" by (auto simp add: less_le) lemma compl_less_swap1: assumes "y < - x" shows "x < - y" using assms compl_less_compl_iff by fastforce lemma compl_less_swap2: assumes "- y < x" shows "- x < y" using assms compl_le_swap1 compl_le_swap2 less_le_not_le by auto lemma sup_cancel_left1: "sup (sup x a) (sup (- x) b) = top" by (simp add: sup_commute sup_left_commute) lemma sup_cancel_left2: "sup (sup (- x) a) (sup x b) = top" by (simp add: sup.commute sup_left_commute) lemma inf_cancel_left1: "inf (inf x a) (inf (- x) b) = bot" by (simp add: inf.left_commute inf_commute) lemma inf_cancel_left2: "inf (inf (- x) a) (inf x b) = bot" using inf.left_commute inf_commute by auto lemma sup_compl_top_left1 [simp]: "sup (- x) (sup x y) = top" by (simp add: sup_assoc[symmetric]) lemma sup_compl_top_left2 [simp]: "sup x (sup (- x) y) = top" using sup_compl_top_left1[of "- x" y] by simp lemma inf_compl_bot_left1 [simp]: "inf (- x) (inf x y) = bot" by (simp add: inf_assoc[symmetric]) lemma inf_compl_bot_left2 [simp]: "inf x (inf (- x) y) = bot" using inf_compl_bot_left1[of "- x" y] by simp lemma inf_compl_bot_right [simp]: "inf x (inf y (- x)) = bot" by (subst inf_left_commute) simp end class complete_orthocomplemented_lattice = orthocomplemented_lattice + complete_lattice instance complete_orthocomplemented_lattice \ complete_complemented_lattice by intro_classes text \The following class \orthomodular_lattice\ describes orthomodular lattices, following \<^url>\https://en.wikipedia.org/wiki/Complemented_lattice#Orthomodular_lattices\.\ class orthomodular_lattice = orthocomplemented_lattice + assumes orthomodular: "x \ y \ sup x (inf (-x) y) = y" begin lemma dual_orthomodular_lattice: "class.orthomodular_lattice (\x y. x \ - y) uminus sup greater_eq greater inf \ \" proof (rule class.orthomodular_lattice.intro) show "class.orthocomplemented_lattice (\x y. (x::'a) \ - y) uminus (\) (\x y. y \ x) (\x y. y < x) (\) \ \" by (rule dual_orthocomplemented_lattice) show "class.orthomodular_lattice_axioms uminus (\) (\x y. (y::'a) \ x) (\)" proof (unfold_locales) show "(x::'a) \ (- x \ y) = y" if "(y::'a) \ x" for x :: 'a and y :: 'a using that local.compl_eq_compl_iff local.ortho_antimono local.orthomodular by fastforce qed qed end class complete_orthomodular_lattice = orthomodular_lattice + complete_lattice begin end instance complete_orthomodular_lattice \ complete_orthocomplemented_lattice by intro_classes instance boolean_algebra \ orthomodular_lattice proof fix x y :: 'a show "sup (x::'a) (inf (- x) y) = y" if "(x::'a) \ y" using that by (simp add: sup.absorb_iff2 sup_inf_distrib1) show "x - y = inf x (- y)" by (simp add: boolean_algebra_class.diff_eq) qed auto instance complete_boolean_algebra \ complete_orthomodular_lattice by intro_classes lemma image_of_maximum: fixes f::"'a::order \ 'b::conditionally_complete_lattice" assumes "mono f" and "\x. x:M \ x\m" and "m:M" shows "(SUP x\M. f x) = f m" by (smt (verit, ccfv_threshold) assms(1) assms(2) assms(3) cSup_eq_maximum imageE imageI monoD) lemma cSup_eq_cSup: fixes A B :: \'a::conditionally_complete_lattice set\ assumes bdd: \bdd_above A\ assumes B: \\a. a\A \ \b\B. b \ a\ assumes A: \\b. b\B \ \a\A. a \ b\ shows \Sup A = Sup B\ proof (cases \B = {}\) case True with A B have \A = {}\ by auto with True show ?thesis by simp next case False have \bdd_above B\ by (meson A bdd bdd_above_def order_trans) have \A \ {}\ using A False by blast moreover have \a \ Sup B\ if \a \ A\ for a proof - obtain b where \b \ B\ and \b \ a\ using B \a \ A\ by auto then show ?thesis apply (rule cSup_upper2) using \bdd_above B\ by simp qed moreover have \Sup B \ c\ if \\a. a \ A \ a \ c\ for c using False apply (rule cSup_least) using A that by fastforce ultimately show ?thesis by (rule cSup_eq_non_empty) qed -unbundle no_lattice_notation +unbundle no_lattice_syntax end diff --git a/thys/Registers/Quantum_Extra.thy b/thys/Registers/Quantum_Extra.thy --- a/thys/Registers/Quantum_Extra.thy +++ b/thys/Registers/Quantum_Extra.thy @@ -1,162 +1,163 @@ section \Derived facts about quantum registers\ theory Quantum_Extra imports Laws_Quantum Quantum begin no_notation meet (infixl "\\" 70) no_notation Group.mult (infixl "\\" 70) no_notation Order.top ("\\") +unbundle lattice_syntax unbundle register_notation unbundle cblinfun_notation lemma zero_not_register[simp]: \~ register (\_. 0)\ unfolding register_def by simp lemma register_pair_is_register_converse: \register (F;G) \ register F\ \register (F;G) \ register G\ using [[simproc del: Laws_Quantum.compatibility_warn]] apply (cases \register F\) apply (auto simp: register_pair_def)[2] apply (cases \register G\) by (auto simp: register_pair_def)[2] lemma register_id'[simp]: \register (\x. x)\ using register_id by (simp add: id_def) lemma register_projector: assumes "register F" assumes "is_Proj a" shows "is_Proj (F a)" using assms unfolding register_def is_Proj_algebraic by metis lemma register_unitary: assumes "register F" assumes "unitary a" shows "unitary (F a)" using assms by (smt (verit, best) register_def unitary_def) lemma compatible_proj_intersect: (* I think this also holds without is_Proj premises, but my proof ideas use the Penrose-Moore pseudoinverse or simultaneous diagonalization and we do not have an existence theorem for either. *) assumes "compatible R S" and "is_Proj a" and "is_Proj b" shows "(R a *\<^sub>S \) \ (S b *\<^sub>S \) = ((R a o\<^sub>C\<^sub>L S b) *\<^sub>S \)" proof (rule antisym) have "((R a o\<^sub>C\<^sub>L S b) *\<^sub>S \) \ (S b *\<^sub>S \)" apply (subst swap_registers[OF assms(1)]) by (simp add: cblinfun_compose_image cblinfun_image_mono) moreover have "((R a o\<^sub>C\<^sub>L S b) *\<^sub>S \) \ (R a *\<^sub>S \)" by (simp add: cblinfun_compose_image cblinfun_image_mono) ultimately show \((R a o\<^sub>C\<^sub>L S b) *\<^sub>S \) \ (R a *\<^sub>S \) \ (S b *\<^sub>S \)\ by auto have "is_Proj (R a)" using assms(1) assms(2) compatible_register1 register_projector by blast have "is_Proj (S b)" using assms(1) assms(3) compatible_register2 register_projector by blast show \(R a *\<^sub>S \) \ (S b *\<^sub>S \) \ (R a o\<^sub>C\<^sub>L S b) *\<^sub>S \\ proof (unfold less_eq_ccsubspace.rep_eq, rule) fix \ assume asm: \\ \ space_as_set ((R a *\<^sub>S \) \ (S b *\<^sub>S \))\ then have \\ \ space_as_set (R a *\<^sub>S \)\ by auto then have R: \R a *\<^sub>V \ = \\ using \is_Proj (R a)\ cblinfun_fixes_range is_Proj_algebraic by blast from asm have \\ \ space_as_set (S b *\<^sub>S \)\ by auto then have S: \S b *\<^sub>V \ = \\ using \is_Proj (S b)\ cblinfun_fixes_range is_Proj_algebraic by blast from R S have \\ = (R a o\<^sub>C\<^sub>L S b) *\<^sub>V \\ by (simp add: cblinfun_apply_cblinfun_compose) also have \\ \ space_as_set ((R a o\<^sub>C\<^sub>L S b) *\<^sub>S \)\ apply simp by (metis R S calculation cblinfun_apply_in_image) finally show \\ \ space_as_set ((R a o\<^sub>C\<^sub>L S b) *\<^sub>S \)\ by - qed qed lemma compatible_proj_mult: assumes "compatible R S" and "is_Proj a" and "is_Proj b" shows "is_Proj (R a o\<^sub>C\<^sub>L S b)" using [[simproc del: Laws_Quantum.compatibility_warn]] using assms unfolding is_Proj_algebraic compatible_def apply auto apply (metis (no_types, lifting) cblinfun_compose_assoc register_mult) by (simp add: assms(2) assms(3) is_proj_selfadj register_projector) lemma unitary_sandwich_register: \unitary a \ register (sandwich a)\ unfolding register_def apply (auto simp: sandwich_def) apply (metis (no_types, lifting) cblinfun_assoc_left(1) cblinfun_compose_id_right unitaryD1) by (simp add: lift_cblinfun_comp(2)) lemma sandwich_tensor: fixes a :: \'a::finite ell2 \\<^sub>C\<^sub>L 'a ell2\ and b :: \'b::finite ell2 \\<^sub>C\<^sub>L 'b ell2\ assumes \unitary a\ \unitary b\ shows "sandwich (a \\<^sub>o b) = sandwich a \\<^sub>r sandwich b" apply (rule tensor_extensionality) by (auto simp: unitary_sandwich_register assms sandwich_def register_tensor_is_register comp_tensor_op tensor_op_adjoint) lemma sandwich_grow_left: fixes a :: \'a::finite ell2 \\<^sub>C\<^sub>L 'a ell2\ assumes "unitary a" shows "sandwich a \\<^sub>r id = sandwich (a \\<^sub>o id_cblinfun)" by (simp add: unitary_sandwich_register assms sandwich_tensor sandwich_id) lemma register_sandwich: \register F \ F (sandwich a b) = sandwich (F a) (F b)\ by (smt (verit, del_insts) register_def sandwich_def) lemma assoc_ell2_sandwich: \assoc = sandwich assoc_ell2\ apply (rule tensor_extensionality3') apply (simp_all add: unitary_sandwich_register)[2] apply (rule equal_ket) apply (case_tac x) by (simp add: sandwich_def assoc_apply cblinfun_apply_cblinfun_compose tensor_op_ell2 assoc_ell2_tensor assoc_ell2'_tensor flip: tensor_ell2_ket) lemma assoc_ell2'_sandwich: \assoc' = sandwich assoc_ell2'\ apply (rule tensor_extensionality3) apply (simp_all add: unitary_sandwich_register)[2] apply (rule equal_ket) apply (case_tac x) by (simp add: sandwich_def assoc'_apply cblinfun_apply_cblinfun_compose tensor_op_ell2 assoc_ell2_tensor assoc_ell2'_tensor flip: tensor_ell2_ket) lemma swap_sandwich: "swap = sandwich Uswap" apply (rule tensor_extensionality) apply (auto simp: sandwich_def)[2] apply (rule tensor_ell2_extensionality) by (simp add: sandwich_def cblinfun_apply_cblinfun_compose tensor_op_ell2) lemma id_tensor_sandwich: fixes a :: "'a::finite ell2 \\<^sub>C\<^sub>L 'b::finite ell2" assumes "unitary a" shows "id \\<^sub>r sandwich a = sandwich (id_cblinfun \\<^sub>o a)" apply (rule tensor_extensionality) using assms by (auto simp: register_tensor_is_register comp_tensor_op sandwich_def tensor_op_adjoint unitary_sandwich_register) lemma compatible_selfbutter_join: assumes [register]: "compatible R S" shows "R (selfbutter \) o\<^sub>C\<^sub>L S (selfbutter \) = (R; S) (selfbutter (\ \\<^sub>s \))" apply (subst register_pair_apply[symmetric, where F=R and G=S]) using assms by auto lemma register_mult': assumes \register F\ shows \F a *\<^sub>V F b *\<^sub>V c = F (a o\<^sub>C\<^sub>L b) *\<^sub>V c\ by (simp add: assms lift_cblinfun_comp(4) register_mult) lemma register_scaleC: assumes \register F\ shows \F (c *\<^sub>C a) = c *\<^sub>C F a\ by (simp add: assms complex_vector.linear_scale) lemma register_bounded_clinear: \register F \ bounded_clinear F\ using bounded_clinear_finite_dim register_def by blast lemma register_adjoint: "F (a*) = (F a)*" if \register F\ using register_def that by blast end diff --git a/thys/ZFC_in_HOL/Kirby.thy b/thys/ZFC_in_HOL/Kirby.thy --- a/thys/ZFC_in_HOL/Kirby.thy +++ b/thys/ZFC_in_HOL/Kirby.thy @@ -1,1659 +1,1659 @@ section \Addition and Multiplication of Sets\ theory Kirby imports ZFC_Cardinals begin subsection \Generalised Addition\ text \Source: Laurence Kirby, Addition and multiplication of sets Math. Log. Quart. 53, No. 1, 52-65 (2007) / DOI 10.1002/malq.200610026 @{url "http://faculty.baruch.cuny.edu/lkirby/mlqarticlejan2007.pdf"}\ subsubsection \Addition is a monoid\ instantiation V :: plus begin text\This definition is credited to Tarski\ definition plus_V :: "V \ V \ V" where "plus_V x \ transrec (\f z. x \ set (f ` elts z))" instance .. end definition lift :: "V \ V \ V" where "lift x y \ set (plus x ` elts y)" lemma plus: "x + y = x \ set ((+)x ` elts y)" unfolding plus_V_def by (subst transrec) auto lemma plus_eq_lift: "x + y = x \ lift x y" unfolding lift_def using plus by blast text\Lemma 3.2\ lemma lift_sup_distrib: "lift x (a \ b) = lift x a \ lift x b" by (simp add: image_Un lift_def sup_V_def) lemma lift_Sup_distrib: "small Y \ lift x (\ Y) = \ (lift x ` Y)" by (auto simp: lift_def Sup_V_def image_Union) lemma add_Sup_distrib: - fixes x::V shows "y \ 0 \ x + (SUP z\elts y. f z) = (SUP z\elts y. x + f z)" + fixes x::V shows "y \ 0 \ x + (\z\elts y. f z) = (\z\elts y. x + f z)" by (auto simp: plus_eq_lift SUP_sup_distrib lift_Sup_distrib image_image) lemma Limit_add_Sup_distrib: - fixes x::V shows "Limit \ \ x + (SUP z\elts \. f z) = (SUP z\elts \. x + f z)" + fixes x::V shows "Limit \ \ x + (\z\elts \. f z) = (\z\elts \. x + f z)" using add_Sup_distrib by force text\Proposition 3.3(ii)\ instantiation V :: monoid_add begin instance proof show "a + b + c = a + (b + c)" for a b c :: V proof (induction c rule: eps_induct) case (step c) have "(a+b) + c = a + b \ set ((+) (a + b) ` elts c)" by (metis plus) also have "\ = a \ lift a b \ set ((\u. a + (b+u)) ` elts c)" using plus_eq_lift step.IH by auto also have "\ = a \ lift a (b + c)" proof - have "lift a b \ set ((\u. a + (b + u)) ` elts c) = lift a (b + c)" unfolding lift_def by (metis elts_of_set image_image lift_def lift_sup_distrib plus_eq_lift replacement small_elts) then show ?thesis by (simp add: sup_assoc) qed also have "\ = a + (b + c)" using plus_eq_lift by auto finally show ?case . qed show "0 + x = x" for x :: V proof (induction rule: eps_induct) case (step x) then show ?case by (subst plus) auto qed show "x + 0 = x" for x :: V by (subst plus) auto qed end lemma lift_0 [simp]: "lift 0 x = x" by (simp add: lift_def) lemma lift_by0 [simp]: "lift x 0 = 0" by (simp add: lift_def) lemma lift_by1 [simp]: "lift x 1 = set{x}" by (simp add: lift_def) lemma add_eq_0_iff [simp]: fixes x y::V shows "x+y = 0 \ x=0 \ y=0" proof safe show "x = 0" if "x + y = 0" by (metis that le_imp_less_or_eq not_less_0 plus sup_ge1) then show "y = 0" if "x + y = 0" using that by auto qed auto lemma plus_vinsert: "x + vinsert z y = vinsert (x+z) (x + y)" proof - have f1: "elts (x + y) = elts x \ (+) x ` elts y" by (metis elts_of_set lift_def plus_eq_lift replacement small_Un small_elts sup_V_def) moreover have "lift x (vinsert z y) = set ((+) x ` elts (set (insert z (elts y))))" using vinsert_def lift_def by presburger ultimately show ?thesis by (simp add: vinsert_def plus_eq_lift sup_V_def) qed lemma plus_V_succ_right: "x + succ y = succ (x + y)" by (metis plus_vinsert succ_def) lemma succ_eq_add1: "succ x = x + 1" by (simp add: plus_V_succ_right one_V_def) lemma ord_of_nat_add: "ord_of_nat (m+n) = ord_of_nat m + ord_of_nat n" by (induction n) (auto simp: plus_V_succ_right) lemma succ_0_plus_eq [simp]: assumes "\ \ elts \" shows "succ 0 + \ = succ \" proof - obtain n where "\ = ord_of_nat n" using assms elts_\ by blast then show ?thesis by (metis One_nat_def ord_of_nat.simps ord_of_nat_add plus_1_eq_Suc) qed lemma omega_closed_add [intro]: assumes "\ \ elts \" "\ \ elts \" shows "\+\ \ elts \" proof - obtain m n where "\ = ord_of_nat m" "\ = ord_of_nat n" using assms elts_\ by auto then have "\+\ = ord_of_nat (m+n)" using ord_of_nat_add by auto then show ?thesis by (simp add: \_def) qed lemma mem_plus_V_E: assumes l: "l \ elts (x + y)" obtains "l \ elts x" | z where "z \ elts y" "l = x + z" using l by (auto simp: plus [of x y] split: if_split_asm) lemma not_add_less_right: assumes "Ord y" shows "\ (x + y < x)" using assms proof (induction rule: Ord_induct) case (step i) then show ?case by (metis less_le_not_le plus sup_ge1) qed lemma not_add_mem_right: "\ (x + y \ elts x)" by (metis sup_ge1 mem_not_refl plus vsubsetD) text\Proposition 3.3(iii)\ lemma add_not_less_TC_self: "\ x + y \ x" proof (induction y arbitrary: x rule: eps_induct) case (step y) then show ?case using less_TC_imp_not_le plus_eq_lift by fastforce qed lemma TC_sup_lift: "TC x \ lift x y = 0" proof - have "elts (TC x) \ elts (set ((+) x ` elts y)) = {}" using add_not_less_TC_self by (auto simp: less_TC_def) then have "TC x \ set ((+) x ` elts y) = set {}" by (metis inf_V_def) then show ?thesis using lift_def by auto qed lemma lift_lift: "lift x (lift y z) = lift (x+y) z" using add.assoc by (auto simp: lift_def) lemma lift_self_disjoint: "x \ lift x u = 0" by (metis TC_sup_lift arg_subset_TC inf.absorb_iff2 inf_assoc inf_sup_aci(3) lift_0) lemma sup_lift_eq_lift: assumes "x \ lift x u = x \ lift x v" shows "lift x u = lift x v" by (metis (no_types) assms inf_sup_absorb inf_sup_distrib2 lift_self_disjoint sup_commute sup_inf_absorb) subsubsection \Deeper properties of addition\ text\Proposition 3.4(i)\ proposition lift_eq_lift: "lift x y = lift x z \ y = z" proof (induction y arbitrary: z rule: eps_induct) case (step y) show ?case proof (intro vsubsetI order_antisym) show "u \ elts z" if "u \ elts y" for u proof - have "x+u \ elts (lift x z)" using lift_def step.prems that by fastforce then obtain v where "v \ elts z" "x+u = x+v" using lift_def by auto then have "lift x u = lift x v" using sup_lift_eq_lift by (simp add: plus_eq_lift) then have "u=v" using step.IH that by blast then show ?thesis using \v \ elts z\ by blast qed show "u \ elts y" if "u \ elts z" for u proof - have "x+u \ elts (lift x y)" using lift_def step.prems that by fastforce then obtain v where "v \ elts y" "x+u = x+v" using lift_def by auto then have "lift x u = lift x v" using sup_lift_eq_lift by (simp add: plus_eq_lift) then have "u=v" using step.IH by (metis \v \ elts y\) then show ?thesis using \v \ elts y\ by auto qed qed qed corollary inj_lift: "inj_on (lift x) A" by (auto simp: inj_on_def dest: lift_eq_lift) corollary add_right_cancel [iff]: fixes x y z::V shows "x+y = x+z \ y=z" by (metis lift_eq_lift plus_eq_lift sup_lift_eq_lift) corollary add_mem_right_cancel [iff]: fixes x y z::V shows "x+y \ elts (x+z) \ y \ elts z" apply safe apply (metis mem_plus_V_E not_add_mem_right add_right_cancel) by (metis ZFC_in_HOL.ext dual_order.antisym elts_vinsert insert_subset order_refl plus_vinsert) corollary add_le_cancel_left [iff]: fixes x y z::V shows "x+y \ x+z \ y\z" by auto (metis add_mem_right_cancel mem_plus_V_E plus sup_ge1 vsubsetD) corollary add_less_cancel_left [iff]: fixes x y z::V shows "x+y < x+z \ y x \ y = 0" by (auto simp: inf.absorb_iff2 lift_eq_lift lift_self_disjoint) lemma succ_less_\_imp: "succ x < \ \ x < \" by (metis add_le_cancel_left add.right_neutral le_0 le_less_trans succ_eq_add1) text\Proposition 3.5\ lemma card_lift: "vcard (lift x y) = vcard y" proof (rule cardinal_cong) have "bij_betw ((+)x) (elts y) (elts (lift x y))" unfolding bij_betw_def by (simp add: inj_on_def lift_def) then show "elts (lift x y) \ elts y" using eqpoll_def eqpoll_sym by blast qed lemma eqpoll_lift: "elts (lift x y) \ elts y" by (metis card_lift cardinal_eqpoll eqpoll_sym eqpoll_trans) lemma vcard_add: "vcard (x + y) = vcard x \ vcard y" using card_lift [of x y] lift_self_disjoint [of x] by (simp add: plus_eq_lift vcard_disjoint_sup) lemma countable_add: assumes "countable (elts A)" "countable (elts B)" shows "countable (elts (A+B))" proof - have "vcard A \ \0" "vcard B \ \0" using assms countable_iff_le_Aleph0 by blast+ then have "vcard (A+B) \ \0" unfolding vcard_add by (metis Aleph_0 Card_\ InfCard_cdouble_eq InfCard_def cadd_le_mono order_refl) then show ?thesis by (simp add: countable_iff_le_Aleph0) qed text\Proposition 3.6\ proposition TC_add: "TC (x + y) = TC x \ lift x (TC y)" proof (induction y rule: eps_induct) case (step y) - have *: "\ (TC ` (+) x ` elts y) = TC x \ (SUP u\elts y. TC (set ((+) x ` elts u)))" + have *: "\ (TC ` (+) x ` elts y) = TC x \ (\u\elts y. TC (set ((+) x ` elts u)))" if "elts y \ {}" proof - obtain w where "w \ elts y" using \elts y \ {}\ by blast then have "TC x \ TC (x + w)" by (simp add: step.IH) - then have \: "TC x \ (SUP w\elts y. TC (x + w))" + then have \: "TC x \ (\w\elts y. TC (x + w))" using \w \ elts y\ by blast show ?thesis using that apply (intro conjI ballI impI order_antisym; clarsimp simp add: image_comp \) apply(metis TC_sup_distrib Un_iff elts_sup_iff plus) by (metis TC_least Transset_TC arg_subset_TC le_sup_iff plus vsubsetD) qed have "TC (x + y) = (x + y) \ \ (TC ` elts (x + y))" using TC by blast also have "\ = x \ lift x y \ \ (TC ` elts x) \ \ ((\u. TC (x+u)) ` elts y)" apply (simp add: plus_eq_lift image_Un Sup_Un_distrib sup.left_commute sup_assoc TC_sup_distrib SUP_sup_distrib) apply (simp add: lift_def sup.commute sup_aci *) done also have "\ = x \ \ (TC ` elts x) \ lift x y \ \ ((\u. TC x \ lift x (TC u)) ` elts y)" by (simp add: sup_aci step.IH) also have "\ = TC x \ lift x y \ \ ((\u. lift x (TC u)) ` elts y)" by (simp add: sup_aci SUP_sup_distrib flip: TC [of x]) also have "\ = TC x \ lift x (y \ \ (TC ` elts y))" by (metis (no_types) elts_of_set lift_Sup_distrib image_image lift_sup_distrib replacement small_elts sup_assoc) also have "\ = TC x \ lift x (TC y)" by (simp add: TC [of y]) finally show ?case . qed corollary TC_add': "z \ x + y \ z \ x \ (\v. v \ y \ z = x + v)" using TC_add by (force simp: less_TC_def lift_def) text\Corollary 3.7\ corollary vcard_TC_add: "vcard (TC (x+y)) = vcard (TC x) \ vcard (TC y)" by (simp add: TC_add TC_sup_lift card_lift vcard_disjoint_sup) text\Corollary 3.8\ corollary TC_lift: assumes "y \ 0" shows "TC (lift x y) = TC x \ lift x (TC y)" proof - have "TC (lift x y) = lift x y \ \ ((\u. TC(x+u)) ` elts y)" unfolding TC [of "lift x y"] by (simp add: lift_def image_image) - also have "\ = lift x y \ (SUP u\elts y. TC x \ lift x (TC u))" + also have "\ = lift x y \ (\u\elts y. TC x \ lift x (TC u))" by (simp add: TC_add) - also have "\ = lift x y \ TC x \ (SUP u\elts y. lift x (TC u))" + also have "\ = lift x y \ TC x \ (\u\elts y. lift x (TC u))" using assms by (auto simp: SUP_sup_distrib) also have "\ = TC x \ lift x (TC y)" by (simp add: TC [of y] sup_aci image_image lift_sup_distrib lift_Sup_distrib) finally show ?thesis . qed proposition rank_add_distrib: "rank (x+y) = rank x + rank y" proof (induction y rule: eps_induct) case (step y) show ?case proof (cases "y=0") case False then obtain e where e: "e \ elts y" by fastforce - have "rank (x+y) = (SUP u\elts (x \ ZFC_in_HOL.set ((+) x ` elts y)). succ (rank u))" + have "rank (x+y) = (\u\elts (x \ ZFC_in_HOL.set ((+) x ` elts y)). succ (rank u))" by (metis plus rank_Sup) - also have "\ = (SUP x\elts x. succ (rank x)) \ (SUP z\elts y. succ (rank x + rank z))" + also have "\ = (\x\elts x. succ (rank x)) \ (\z\elts y. succ (rank x + rank z))" apply (simp add: Sup_Un_distrib image_Un image_image) apply (simp add: step cong: SUP_cong_simp) done - also have "\ = (SUP z \ elts y. rank x + succ (rank z))" + also have "\ = (\z \ elts y. rank x + succ (rank z))" proof - - have "rank x \ (SUP z\elts y. ZFC_in_HOL.succ (rank x + rank z))" + have "rank x \ (\z\elts y. ZFC_in_HOL.succ (rank x + rank z))" using \y \ 0\ by (auto simp: plus_eq_lift intro: order_trans [OF _ cSUP_upper [OF e]]) then show ?thesis by (force simp: plus_V_succ_right simp flip: rank_Sup [of x] intro!: order_antisym) qed - also have "\ = rank x + (SUP z \ elts y. succ (rank z))" + also have "\ = rank x + (\z \ elts y. succ (rank z))" by (simp add: add_Sup_distrib False) also have "\ = rank x + rank y" by (simp add: rank_Sup [of y]) finally show ?thesis . qed auto qed lemma Ord_add [simp]: "\Ord x; Ord y\ \ Ord (x+y)" proof (induction y rule: eps_induct) case (step y) then show ?case by (metis Ord_rank rank_add_distrib rank_of_Ord) qed -lemma add_Sup_distrib_id: "A \ 0 \ x + \(elts A) = (SUP z\elts A. x + z)" +lemma add_Sup_distrib_id: "A \ 0 \ x + \(elts A) = (\z\elts A. x + z)" by (metis add_Sup_distrib image_ident image_image) -lemma add_Limit: "Limit \ \ x + \ = (SUP z\elts \. x + z)" +lemma add_Limit: "Limit \ \ x + \ = (\z\elts \. x + z)" by (metis Limit_add_Sup_distrib Limit_eq_Sup_self image_ident image_image) lemma add_le_left: assumes "Ord \" "Ord \" shows "\ \ \+\" using \Ord \\ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case (succ \) then show ?case by (auto simp: plus_V_succ_right Ord_mem_iff_lt assms(1)) next case (Limit \) - then have k: "\ = (SUP \ \ elts \. \)" + then have k: "\ = (\\ \ elts \. \)" by (simp add: Limit_eq_Sup_self) - also have "\ \ (SUP \ \ elts \. \ + \)" + also have "\ \ (\\ \ elts \. \ + \)" using Limit.IH by auto - also have "\ = \ + (SUP \ \ elts \. \)" + also have "\ = \ + (\\ \ elts \. \)" using Limit.hyps Limit_add_Sup_distrib by presburger finally show ?case using k by simp qed lemma plus_\_equals_\: assumes "\ \ elts \" shows "\ + \ = \" proof (rule antisym) show "\ + \ \ \" using Ord_trans assms by (auto simp: elim!: mem_plus_V_E) show "\ \ \ + \" by (simp add: add_le_left assms) qed lemma one_plus_\_equals_\ [simp]: "1 + \ = \" by (simp add: one_V_def plus_\_equals_\) subsubsection \Cancellation / set subtraction\ definition vle :: "V \ V \ bool" (infix "\" 50) where "x \ y \ \z::V. x+z = y" lemma vle_refl [iff]: "x \ x" by (metis (no_types) add.right_neutral vle_def) lemma vle_antisym: "\x \ y; y \ x\ \ x = y" by (metis V_equalityI plus_eq_lift sup_ge1 vle_def vsubsetD) lemma vle_trans [trans]: "\x \ y; y \ z\ \ x \ z" by (metis add.assoc vle_def) definition vle_comparable :: "V \ V \ bool" where "vle_comparable x y \ x \ y \ y \ x" text\Lemma 3.13\ lemma comparable: assumes "a+b = c+d" shows "vle_comparable a c" unfolding vle_comparable_def proof (rule ccontr) assume non: "\ (a \ c \ c \ a)" let ?\ = "\x. \z. a+x \ c+z" have "?\ x" for x proof (induction x rule: eps_induct) case (step x) show ?case proof (cases "x=0") case True with non nonzero_less_TC show ?thesis using vle_def by auto next case False then obtain v where "v \ elts x" using trad_foundation by blast show ?thesis proof clarsimp fix z assume eq: "a + x = c + z" then have "z \ 0" using vle_def non by auto have av: "a+v \ elts (a+x)" by (simp add: \v \ elts x\) moreover have "a+x = c \ lift c z" using eq plus_eq_lift by fastforce ultimately have "a+v \ elts (c \ lift c z)" by simp moreover define u where "u \ set (elts x - {v})" have u: "v \ elts u" and xeq: "x = vinsert v u" using \v \ elts x\ by (auto simp: u_def intro: order_antisym) have case1: "a+v \ elts c" proof assume avc: "a + v \ elts c" then have "a \ c" by clarify (metis Un_iff elts_sup_iff eq mem_not_sym mem_plus_V_E plus_eq_lift) moreover have "a \ lift a x = c \ lift c z" using eq by (simp add: plus_eq_lift) ultimately have "lift c z \ lift a x" by (metis inf.absorb_iff2 inf_commute inf_sup_absorb inf_sup_distrib2 lift_self_disjoint sup.commute) also have "\ = vinsert (a+v) (lift a u)" by (simp add: lift_def vinsert_def xeq) finally have *: "lift c z \ vinsert (a + v) (lift a u)" . have "lift c z \ lift a u" proof - have "a + v \ elts (lift c z)" using lift_self_disjoint [of c z] avc V_disjoint_iff by auto then show ?thesis using * less_eq_V_def by auto qed { fix e assume "e \ elts z" then have "c+e \ elts (lift c z)" by (simp add: lift_def) then have "c+e \ elts (lift a u)" using \lift c z \ lift a u\ by blast then obtain y where "y \ elts u" "c+e = a+y" using lift_def by auto then have False by (metis elts_vinsert insert_iff step.IH xeq) } then show False using \z \ 0\ by fastforce qed ultimately show False by (metis (no_types) \v \ elts x\ av case1 eq mem_plus_V_E step.IH) qed qed qed then show False using assms by blast qed lemma vle1: "x \ y \ x \ y" using vle_def plus_eq_lift by auto lemma vle2: "x \ y \ x \ y" by (metis (full_types) TC_add' add.right_neutral le_TC_def vle_def nonzero_less_TC) lemma vle_iff_le_Ord: assumes "Ord \" "Ord \" shows "\ \ \ \ \ \ \" proof show "\ \ \" if "\ \ \" using that by (simp add: vle1) show "\ \ \" if "\ \ \" using \Ord \\ \Ord \\ that proof (induction \ arbitrary: \ rule: Ord_induct) case (step \) then show ?case unfolding vle_def by (metis Ord_add Ord_linear add_le_left mem_not_refl mem_plus_V_E vsubsetD) qed qed lemma add_le_cancel_left0 [iff]: fixes x::V shows "x \ x+z" by (simp add: vle1 vle_def) lemma add_less_cancel_left0 [iff]: fixes x::V shows "x < x+z \ 0 \ \" "Ord \" "Ord \" obtains \ where "\+\ = \" "\ \ \" "Ord \" proof - obtain \ where \: "\+\ = \" "\ \ \" by (metis add_le_cancel_left add_le_left assms vle_def vle_iff_le_Ord) then have "Ord \" using Ord_def Transset_def \Ord \\ by force with \ that show thesis by blast qed lemma plus_Ord_le: assumes "\ \ elts \" "Ord \" shows "\+\ \ \+\" proof (cases "\ \ elts \") case True with assms have "\+\ = \+\" by (auto simp: elts_\ add.commute ord_of_nat_add [symmetric]) then show ?thesis by simp next case False then have "\ \ \" using Ord_linear2 Ord_mem_iff_lt \Ord \\ by auto then obtain \ where "\+\ = \" "\ \ \" "Ord \" using \Ord \\ le_Ord_diff by auto then have "\+\ = \" by (metis add.assoc assms(1) plus_\_equals_\) then show ?thesis by simp qed lemma add_right_mono: "\\ \ \; Ord \; Ord \; Ord \\ \ \+\ \ \+\" by (metis add_le_cancel_left add.assoc add_le_left le_Ord_diff) lemma add_strict_mono: "\\ < \; \ < \; Ord \; Ord \; Ord \; Ord \\ \ \+\ < \+\" by (metis order.strict_implies_order add_less_cancel_left add_right_mono le_less_trans) lemma add_right_strict_mono: "\\ \ \; \ < \; Ord \; Ord \; Ord \; Ord \\ \ \+\ < \+\" using add_strict_mono le_imp_less_or_eq by blast lemma Limit_add_Limit [simp]: assumes "Limit \" "Ord \" shows "Limit (\ + \)" unfolding Limit_def proof (intro conjI allI impI) show "Ord (\ + \)" using Limit_def assms by auto show "0 \ elts (\ + \)" using Limit_def add_le_left assms by auto next fix \ assume "\ \ elts (\ + \)" then consider "\ \ elts \" | \ where "\ \ elts \" "\ = \ + \" using mem_plus_V_E by blast then show "succ \ \ elts (\ + \)" proof cases case 1 then show ?thesis by (metis Kirby.add_strict_mono Limit_def Ord_add Ord_in_Ord Ord_mem_iff_lt assms one_V_def succ_eq_add1) next case 2 then show ?thesis by (metis Limit_def add_mem_right_cancel assms(1) plus_V_succ_right) qed qed subsection \Generalised Difference\ definition odiff where "odiff y x \ THE z::V. (x+z = y) \ (z=0 \ \ x \ y)" lemma vle_imp_odiff_eq: "x \ y \ x + (odiff y x) = y" by (auto simp: vle_def odiff_def) lemma not_vle_imp_odiff_0: "\ x \ y \ (odiff y x) = 0" by (auto simp: vle_def odiff_def) lemma Ord_odiff_eq: assumes "\ \ \" "Ord \" "Ord \" shows "\ + odiff \ \ = \" by (simp add: assms vle_iff_le_Ord vle_imp_odiff_eq) lemma Ord_odiff: assumes "Ord \" "Ord \" shows "Ord (odiff \ \)" proof (cases "\ \ \") case True then show ?thesis by (metis add_right_cancel assms le_Ord_diff vle1 vle_imp_odiff_eq) next case False then show ?thesis by (simp add: odiff_def vle_def) qed lemma Ord_odiff_le: assumes "Ord \" "Ord \" shows "odiff \ \ \ \" proof (cases "\ \ \") case True then show ?thesis by (metis add_right_cancel assms le_Ord_diff vle1 vle_imp_odiff_eq) next case False then show ?thesis by (simp add: odiff_def vle_def) qed lemma odiff_0_right [simp]: "odiff x 0 = x" by (metis add.left_neutral vle_def vle_imp_odiff_eq) lemma odiff_succ: "y \ x \ odiff (succ x) y = succ (odiff x y)" unfolding odiff_def by (metis add_right_cancel odiff_def plus_V_succ_right vle_def vle_imp_odiff_eq) lemma odiff_eq_iff: "z \ x \ odiff x z = y \ x = z + y" by (auto simp: odiff_def vle_def) lemma odiff_le_iff: "z \ x \ odiff x z \ y \ x \ z + y" by (auto simp: odiff_def vle_def) lemma odiff_less_iff: "z \ x \ odiff x z < y \ x < z + y" by (auto simp: odiff_def vle_def) lemma odiff_ge_iff: "z \ x \ odiff x z \ y \ x \ z + y" by (auto simp: odiff_def vle_def) lemma Ord_odiff_le_iff: "\\ \ x; Ord x; Ord \\ \ odiff x \ \ y \ x \ \ + y" by (simp add: odiff_le_iff vle_iff_le_Ord) lemma odiff_le_odiff: assumes "x \ y" shows "odiff x z \ odiff y z" proof (cases "z \ x") case True then show ?thesis using assms odiff_le_iff vle1 vle_imp_odiff_eq vle_trans by presburger next case False then show ?thesis by (simp add: not_vle_imp_odiff_0) qed lemma Ord_odiff_le_odiff: "\x \ y; Ord x; Ord y\ \ odiff x \ \ odiff y \" by (simp add: odiff_le_odiff vle_iff_le_Ord) lemma Ord_odiff_less_odiff: "\\ \ x; x < y; Ord x; Ord y; Ord \\ \ odiff x \ < odiff y \" by (metis Ord_odiff_eq Ord_odiff_le_odiff dual_order.strict_trans less_V_def) lemma Ord_odiff_less_imp_less: "\odiff x \ < odiff y \; Ord x; Ord y\ \ x < y" by (meson Ord_linear2 leD odiff_le_odiff vle_iff_le_Ord) lemma odiff_add_cancel [simp]: "odiff (x + y) x = y" by (simp add: odiff_eq_iff vle_def) lemma odiff_add_cancel_0 [simp]: "odiff x x = 0" by (simp add: odiff_eq_iff) lemma odiff_add_cancel_both [simp]: "odiff (x + y) (x + z) = odiff y z" by (simp add: add.assoc odiff_def vle_def) subsection \Generalised Multiplication\ text \Credited to Dana Scott\ instantiation V :: times begin text\This definition is credited to Tarski\ definition times_V :: "V \ V \ V" where "times_V x \ transrec (\f y. \ ((\u. lift (f u) x) ` elts y))" instance .. end -lemma mult: "x * y = (SUP u\elts y. lift (x * u) x)" +lemma mult: "x * y = (\u\elts y. lift (x * u) x)" unfolding times_V_def by (subst transrec) (force simp:) lemma elts_multE: assumes "z \ elts (x * y)" obtains u v where "u \ elts x" "v \ elts y" "z = x*v + u" using mult [of x y] lift_def assms by auto text \Lemma 4.2\ lemma mult_zero_right [simp]: fixes x::V shows "x * 0 = 0" by (metis ZFC_in_HOL.Sup_empty elts_0 image_empty mult) lemma mult_insert: "x * (vinsert y z) = x*z \ lift (x*y) x" by (metis (no_types, lifting) elts_vinsert image_insert replacement small_elts sup_commute mult Sup_V_insert) lemma mult_succ: "x * succ y = x*y + x" by (simp add: mult_insert plus_eq_lift succ_def) lemma ord_of_nat_mult: "ord_of_nat (m*n) = ord_of_nat m * ord_of_nat n" proof (induction n) case (Suc n) then show ?case by (simp add: add.commute [of m]) (simp add: ord_of_nat_add mult_succ) qed auto lemma omega_closed_mult [intro]: assumes "\ \ elts \" "\ \ elts \" shows "\*\ \ elts \" proof - obtain m n where "\ = ord_of_nat m" "\ = ord_of_nat n" using assms elts_\ by auto then have "\*\ = ord_of_nat (m*n)" by (simp add: ord_of_nat_mult) then show ?thesis by (simp add: \_def) qed lemma zero_imp_le_mult: "0 \ elts y \ x \ x*y" by (auto simp: mult [of x y]) subsubsection\Proposition 4.3\ lemma mult_zero_left [simp]: fixes x::V shows "0 * x = 0" proof (induction x rule: eps_induct) case (step x) then show ?case by (subst mult) auto qed lemma mult_sup_distrib: fixes x::V shows "x * (y \ z) = x*y \ x*z" unfolding mult [of x "y \ z"] mult [of x y] mult [of x z] by (simp add: Sup_Un_distrib image_Un) lemma mult_Sup_distrib: "small Y \ x * (\Y) = \ ((*) x ` Y)" for Y:: "V set" unfolding mult [of x "\Y"] by (simp add: cSUP_UNION) (metis mult) lemma mult_lift_imp_distrib: "x * (lift y z) = lift (x*y) (x*z) \ x * (y+z) = x*y + x*z" by (simp add: mult_sup_distrib plus_eq_lift) lemma mult_lift: "x * (lift y z) = lift (x*y) (x*z)" proof (induction z rule: eps_induct) case (step z) - have "x * lift y z = (SUP u\elts (lift y z). lift (x * u) x)" + have "x * lift y z = (\u\elts (lift y z). lift (x * u) x)" using mult by blast - also have "\ = (SUP v\elts z. lift (x * (y + v)) x)" + also have "\ = (\v\elts z. lift (x * (y + v)) x)" using lift_def by auto - also have "\ = (SUP v\elts z. lift (x * y + x * v) x)" + also have "\ = (\v\elts z. lift (x * y + x * v) x)" using mult_lift_imp_distrib step.IH by auto - also have "\ = (SUP v\elts z. lift (x * y) (lift (x * v) x))" + also have "\ = (\v\elts z. lift (x * y) (lift (x * v) x))" by (simp add: lift_lift) - also have "\ = lift (x * y) (SUP v\elts z. lift (x * v) x)" + also have "\ = lift (x * y) (\v\elts z. lift (x * v) x)" by (simp add: image_image lift_Sup_distrib) also have "\ = lift (x*y) (x*z)" by (metis mult) finally show ?case . qed lemma mult_Limit: "Limit \ \ x * \ = \ ((*) x ` elts \)" by (metis Limit_eq_Sup_self mult_Sup_distrib small_elts) lemma add_mult_distrib: "x * (y+z) = x*y + x*z" for x::V by (simp add: mult_lift mult_lift_imp_distrib) instantiation V :: monoid_mult begin instance proof show "1 * x = x" for x :: V proof (induction x rule: eps_induct) case (step x) then show ?case by (subst mult) auto qed show "x * 1 = x" for x :: V by (subst mult) auto show "(x * y) * z = x * (y * z)" for x y z::V proof (induction z rule: eps_induct) case (step z) - have "(x * y) * z = (SUP u\elts z. lift (x * y * u) (x * y))" + have "(x * y) * z = (\u\elts z. lift (x * y * u) (x * y))" using mult by blast - also have "\ = (SUP u\elts z. lift (x * (y * u)) (x * y))" + also have "\ = (\u\elts z. lift (x * (y * u)) (x * y))" using step.IH by auto - also have "\ = (SUP u\elts z. x * lift (y * u) y)" + also have "\ = (\u\elts z. x * lift (y * u) y)" using mult_lift by auto - also have "\ = x * (SUP u\elts z. lift (y * u) y)" + also have "\ = x * (\u\elts z. lift (y * u) y)" by (simp add: image_image mult_Sup_distrib) also have "\ = x * (y * z)" by (metis mult) finally show ?case . qed qed end lemma le_mult: assumes "Ord \" "\ \ 0" shows "\ \ \ * \" using assms proof (induction rule: Ord_induct3) case (succ \) then show ?case using mult_insert succ_def by fastforce next case (Limit \) have "\ \ (*) \ ` elts \" using Limit.hyps Limit_def one_V_def by (metis imageI mult.right_neutral) then have "\ \ \ ((*) \ ` elts \)" by auto then show ?case by (simp add: Limit.hyps mult_Limit) qed auto lemma mult_sing_1 [simp]: fixes x::V shows "x * set{1} = lift x x" by (subst mult) auto lemma mult_2_right [simp]: fixes x::V shows "x * set{0,1} = x+x" by (subst mult) (auto simp: Sup_V_insert plus_eq_lift) lemma Ord_mult [simp]: "\Ord y; Ord x\ \ Ord (x*y)" proof (induction y rule: Ord_induct3) case 0 then show ?case by auto next case (succ k) then show ?case by (simp add: mult_succ) next case (Limit k) then have "Ord (x * \ (elts k))" by (metis Ord_Sup imageE mult_Sup_distrib small_elts) then show ?case using Limit.hyps Limit_eq_Sup_self by auto qed subsubsection \Proposition 4.4-5\ proposition rank_mult_distrib: "rank (x*y) = rank x * rank y" proof (induction y rule: eps_induct) case (step y) - have "rank (x*y) = (SUP y\elts (SUP u\elts y. lift (x * u) x). succ (rank y))" + have "rank (x*y) = (\y\elts (\u\elts y. lift (x * u) x). succ (rank y))" by (metis rank_Sup mult) - also have "\ = (SUP u\elts y. SUP r\elts x. succ (rank (x * u + r)))" + also have "\ = (\u\elts y. \r\elts x. succ (rank (x * u + r)))" apply (simp add: lift_def image_image image_UN) apply (simp add: Sup_V_def) done - also have "\ = (SUP u\elts y. SUP r\elts x. succ (rank (x * u) + rank r))" + also have "\ = (\u\elts y. \r\elts x. succ (rank (x * u) + rank r))" using rank_add_distrib by auto - also have "\ = (SUP u\elts y. SUP r\elts x. succ (rank x * rank u + rank r))" + also have "\ = (\u\elts y. \r\elts x. succ (rank x * rank u + rank r))" using step arg_cong [where f = Sup] by auto - also have "\ = (SUP u\elts y. rank x * rank u + rank x)" + also have "\ = (\u\elts y. rank x * rank u + rank x)" proof (rule SUP_cong) - show "(SUP r\elts x. succ (rank x * rank u + rank r)) = rank x * rank u + rank x" + show "(\r\elts x. succ (rank x * rank u + rank r)) = rank x * rank u + rank x" if "u \ elts y" for u proof (cases "x=0") case False - have "(SUP r\elts x. succ (rank x * rank u + rank r)) = rank x * rank u + (SUP y\elts x. succ (rank y))" + have "(\r\elts x. succ (rank x * rank u + rank r)) = rank x * rank u + (\y\elts x. succ (rank y))" proof (rule order_antisym) - show "(SUP r\elts x. succ (rank x * rank u + rank r)) \ rank x * rank u + (SUP y\elts x. succ (rank y))" + show "(\r\elts x. succ (rank x * rank u + rank r)) \ rank x * rank u + (\y\elts x. succ (rank y))" by (auto simp: Sup_le_iff simp flip: plus_V_succ_right) - have "rank x * rank u + (SUP y\elts x. succ (rank y)) = (SUP y\elts x. rank x * rank u + succ (rank y))" + have "rank x * rank u + (\y\elts x. succ (rank y)) = (\y\elts x. rank x * rank u + succ (rank y))" by (simp add: add_Sup_distrib False) - also have "\ \ (SUP r\elts x. succ (rank x * rank u + rank r))" + also have "\ \ (\r\elts x. succ (rank x * rank u + rank r))" using plus_V_succ_right by auto - finally show "rank x * rank u + (SUP y\elts x. succ (rank y)) \ (SUP r\elts x. succ (rank x * rank u + rank r))" . + finally show "rank x * rank u + (\y\elts x. succ (rank y)) \ (\r\elts x. succ (rank x * rank u + rank r))" . qed also have "\ = rank x * rank u + rank x" by (metis rank_Sup) finally show ?thesis . qed auto qed auto also have "\ = rank x * rank y" by (simp add: rank_Sup [of y] mult_Sup_distrib mult_succ image_image) finally show ?case . qed lemma mult_le1: fixes y::V assumes "y \ 0" shows "x \ x * y" proof (cases "x = 0") case False then obtain r where r: "r \ elts x" by fastforce from \y \ 0\ show ?thesis proof (induction y rule: eps_induct) case (step y) show ?case proof (cases "y = 1") case False with \y \ 0\ obtain p where p: "p \ elts y" "p \ 0" by (metis V_equalityI elts_1 insertI1 singletonD trad_foundation) then have "x*p + r \ elts (lift (x*p) x)" by (simp add: lift_def r) moreover have "lift (x*p) x \ x*y" by (metis bdd_above_iff_small cSUP_upper2 order_refl \p \ elts y\ replacement small_elts mult) ultimately have "x*p + r \ elts (x*y)" by blast moreover have "x*p \ x*p + r" by (metis TC_add' V_equalityI add.right_neutral eps_induct le_TC_refl less_TC_iff less_imp_le_TC) ultimately show ?thesis using step.IH [OF p] le_TC_trans less_TC_iff by blast qed auto qed qed auto lemma mult_eq_0_iff [simp]: fixes y::V shows "x * y = 0 \ x=0 \ y=0" proof show "x = 0 \ y = 0" if "x * y = 0" by (metis le_0 le_TC_def less_TC_imp_not_le mult_le1 that) qed auto lemma lift_lemma: assumes "x \ 0" "y \ 0" shows "\ lift (x * y) x \ x" using assms mult_le1 [of concl: x y] by (auto simp: le_TC_def TC_lift less_TC_def less_TC_imp_not_le) lemma mult_le2: fixes y::V assumes "x \ 0" "y \ 0" "y \ 1" shows "x \ x * y" proof - obtain v where v: "v \ elts y" "v \ 0" using assms by fastforce have "x \ x * y" using lift_lemma [of x v] by (metis \x \ 0\ bdd_above_iff_small cSUP_upper2 order_refl replacement small_elts mult v) then show ?thesis using assms mult_le1 [of y x] by (auto simp: le_TC_def) qed lemma elts_mult_\E: assumes "x \ elts (y * \)" obtains n where "n \ 0" "x \ elts (y * ord_of_nat n)" "\m. m < n \ x \ elts (y * ord_of_nat m)" proof - obtain k where k: "k \ 0 \ x \ elts (y * ord_of_nat k)" using assms apply (simp add: mult_Limit elts_\) by (metis mult_eq_0_iff elts_0 ex_in_conv ord_of_eq_0_iff that) define n where "n \ (LEAST k. k \ 0 \ x \ elts (y * ord_of_nat k))" show thesis proof show "n \ 0" "x \ elts (y * ord_of_nat n)" unfolding n_def by (metis (mono_tags, lifting) LeastI_ex k)+ show "\m. m < n \ x \ elts (y * ord_of_nat m)" by (metis (mono_tags, lifting) mult_eq_0_iff elts_0 empty_iff n_def not_less_Least ord_of_eq_0_iff) qed qed subsubsection\Theorem 4.6\ theorem mult_eq_imp_0: assumes "a*x = a*y + b" "b \ a" shows "b=0" proof (cases "a=0 \ x=0") case True with assms show ?thesis by (metis add_le_cancel_left mult_eq_0_iff eq_iff le_0) next case False then have "a\0" "x\0" by auto then show ?thesis proof (cases "y=0") case True then show ?thesis using assms less_asym_TC mult_le2 by force next case False have "b=0" if "Ord \" "x \ elts (Vset \)" "y \ elts (Vset \)" for \ using that assms proof (induction \ arbitrary: x y b rule: Ord_induct3) case 0 then show ?case by auto next case (succ k) define \ where "\ \ \x y. \r. 0 \ r \ r \ a \ a*x = a*y + r" show ?case proof (rule ccontr) assume "b \ 0" then have "0 \ b" by (metis nonzero_less_TC) then have "\ x y" unfolding \_def using succ.prems by blast then obtain x' where "\ x' y" "x' \ x" and min: "\x''. x'' \ x' \ \ \ x'' y" using less_TC_minimal [of "\x. \ x y" x] by blast then obtain b' where "0 \ b'" "b' \ a" and eq: "a*x' = a*y + b'" using \_def by blast have "a*y \ a*x'" using TC_add' \0 \ b'\ eq by auto then obtain p where "p \ elts (a * x')" "a * y \ p" using less_TC_iff by blast then have "p \ elts (a * y)" using less_TC_iff less_irrefl_TC by blast then have "p \ \ (elts ` (\v. lift (a * v) a) ` elts x')" by (metis \p \ elts (a * x')\ elts_Sup replacement small_elts mult) then obtain u c where "u \ elts x'" "c \ elts a" "p = a*u + c" using lift_def by auto then have "p \ elts (lift (a*y) b')" using \p \ elts (a * x')\ \p \ elts (a * y)\ eq plus_eq_lift by auto then obtain d where d: "d \ elts b'" "p = a*y + d" "p = a*u + c" by (metis \p = a * u + c\ \p \ elts (a * x')\ \p \ elts (a * y)\ eq mem_plus_V_E) have noteq: "a*y \ a*u" proof assume "a*y = a*u" then have "lift (a*y) a = lift (a*u) a" by metis also have "\ \ a*x'" unfolding mult [of _ x'] using \u \ elts x'\ by (auto intro: cSUP_upper) also have "\ = a*y \ lift (a*y) b'" by (simp add: eq plus_eq_lift) finally have "lift (a*y) a \ a*y \ lift (a*y) b'" . then have "lift (a*y) a \ lift (a*y) b'" using add_le_cancel_left less_TC_imp_not_le plus_eq_lift \b' \ a\ by auto then have "a \ b'" by (simp add: le_iff_sup lift_eq_lift lift_sup_distrib) then show False using \b' \ a\ less_TC_imp_not_le by auto qed consider "a*y \ a*u" | "a*u \ a*y" using d comparable vle_comparable_def by auto then show False proof cases case 1 then obtain e where e: "a*u = a*y + e" "e \ 0" by (metis add.right_neutral noteq vle_def) moreover have "e + c = d" by (metis e add_right_cancel \p = a * u + c\ \p = a * y + d\ add.assoc) with \d \ elts b'\ \b' \ a\ have "e \ a" by (meson less_TC_iff less_TC_trans vle2 vle_def) ultimately show False \\contradicts minimality of @{term x'}\ using min unfolding \_def by (meson \u \ elts x'\ le_TC_def less_TC_iff nonzero_less_TC) next case 2 then obtain e where e: "a*y = a*u + e" "e \ 0" by (metis add.right_neutral noteq vle_def) moreover have "e + d = c" by (metis e add_right_cancel \p = a * u + c\ \p = a * y + d\ add.assoc) with \d \ elts b'\ \b' \ a\ have "e \ a" by (metis \c \ elts a\ less_TC_iff vle2 vle_def) ultimately have "\ y u" unfolding \_def using nonzero_less_TC by blast then obtain y' where "\ y' u" "y' \ y" and min: "\x''. x'' \ y' \ \ \ x'' u" using less_TC_minimal [of "\x. \ x u" y] by blast then obtain b' where "0 \ b'" "b' \ a" and eq: "a*y' = a*u + b'" using \_def by blast have u_k: "u \ elts (Vset k)" using \u \ elts x'\ \x' \ x\ succ Vset_succ_TC less_TC_iff less_le_TC_trans by blast have "a*u \ a*y'" using TC_add' \0 \ b'\ eq by auto then obtain p where "p \ elts (a * y')" "a * u \ p" using less_TC_iff by blast then have "p \ elts (a * u)" using less_TC_iff less_irrefl_TC by blast then have "p \ \ (elts ` (\v. lift (a * v) a) ` elts y')" by (metis \p \ elts (a * y')\ elts_Sup replacement small_elts mult) then obtain v c where "v \ elts y'" "c \ elts a" "p = a*v + c" using lift_def by auto then have "p \ elts (lift (a*u) b')" using \p \ elts (a * y')\ \p \ elts (a * u)\ eq plus_eq_lift by auto then obtain d where d: "d \ elts b'" "p = a*u + d" "p = a*v + c" by (metis \p = a * v + c\ \p \ elts (a * y')\ \p \ elts (a * u)\ eq mem_plus_V_E) have v_k: "v \ elts (Vset k)" using Vset_succ_TC \v \ elts y'\ \y' \ y\ less_TC_iff less_le_TC_trans succ.hyps succ.prems(2) by blast have noteq: "a*u \ a*v" proof assume "a*u = a*v" then have "lift (a*v) a \ a*y'" unfolding mult [of _ y'] using \v \ elts y'\ by (auto intro: cSUP_upper) also have "\ = a*u \ lift (a*u) b'" by (simp add: eq plus_eq_lift) finally have "lift (a*v) a \ a*u \ lift (a*u) b'" . then have "lift (a*u) a \ lift (a*u) b'" by (metis \a * u = a * v\ le_iff_sup lift_sup_distrib sup_left_commute sup_lift_eq_lift) then have "a \ b'" by (simp add: le_iff_sup lift_eq_lift lift_sup_distrib) then show False using \b' \ a\ less_TC_imp_not_le by auto qed consider "a*u \ a*v" | "a*v \ a*u" using d comparable vle_comparable_def by auto then show False proof cases case 1 then obtain e where e: "a*v = a*u + e" "e \ 0" by (metis add.right_neutral noteq vle_def) moreover have "e + c = d" by (metis add_right_cancel \p = a * u + d\ \p = a * v + c\ add.assoc e) with \d \ elts b'\ \b' \ a\ have "e \ a" by (meson less_TC_iff less_TC_trans vle2 vle_def) ultimately show False using succ.IH u_k v_k by blast next case 2 then obtain e where e: "a*u = a*v + e" "e \ 0" by (metis add.right_neutral noteq vle_def) moreover have "e + d = c" by (metis add_right_cancel add.assoc d e) with \d \ elts b'\ \b' \ a\ have "e \ a" by (metis \c \ elts a\ less_TC_iff vle2 vle_def) ultimately show False using succ.IH u_k v_k by blast qed qed qed next case (Limit k) obtain i j where k: "i \ elts k" "j \ elts k" and x: "x \ elts (Vset i)" and y: "y \ elts (Vset j)" using that Limit by (auto simp: Limit_Vfrom_eq) show ?case proof (rule Limit.IH [of "i \ j"]) show "i \ j \ elts k" by (meson k x y Limit.hyps Limit_def Ord_in_Ord Ord_mem_iff_lt Ord_sup union_less_iff) show "x \ elts (Vset (i \ j))" "y \ elts (Vset (i \ j))" using x y by (auto simp: Vfrom_sup) qed (use Limit.prems in auto) qed then show ?thesis by (metis two_in_Vset Ord_rank Ord_VsetI rank_lt) qed qed subsubsection\Theorem 4.7\ lemma mult_cancellation_half: assumes "a*x + r \ a*y + s" "r \ a" "s \ a" shows "x \ y" proof - have "x \ y" if "Ord \" "x \ elts (Vset \)" "y \ elts (Vset \)" for \ using that assms proof (induction \ arbitrary: x y r s rule: Ord_induct3) case 0 then show ?case by auto next case (succ k) show ?case proof fix u assume u: "u \ elts x" have u_k: "u \ elts (Vset k)" using Vset_succ succ.hyps succ.prems(1) u by auto obtain r' where "r' \ elts a" "r \ r'" using less_TC_iff succ.prems(4) by blast have "a*u + r' \ elts (lift (a*u) a)" by (simp add: \r' \ elts a\ lift_def) also have "\ \ elts (a*x)" using u by (force simp: mult [of _ x]) also have "\ \ elts (a*y + s)" using plus_eq_lift succ.prems(3) by auto also have "\ = elts (a*y) \ elts (lift (a*y) s)" by (simp add: plus_eq_lift) finally have "a * u + r' \ elts (a * y) \ elts (lift (a * y) s)" . then show "u \ elts y" proof assume *: "a * u + r' \ elts (a * y)" show "u \ elts y" proof - obtain v e where v: "v \ elts y" "e \ elts a" "a * u + r' = a * v + e" using * by (auto simp: mult [of _ y] lift_def) then have v_k: "v \ elts (Vset k)" using Vset_succ_TC less_TC_iff succ.prems(2) by blast then show ?thesis by (metis \r' \ elts a\ antisym le_TC_refl less_TC_iff order_refl succ.IH u_k v) qed next assume "a * u + r' \ elts (lift (a * y) s)" then obtain t where "t \ elts s" and t: "a * u + r' = a * y + t" using lift_def by auto have noteq: "a*y \ a*u" proof assume "a*y = a*u" then have "lift (a*y) a = lift (a*u) a" by metis also have "\ \ a*x" unfolding mult [of _ x] using \u \ elts x\ by (auto intro: cSUP_upper) also have "\ \ a*y \ lift (a*y) s" using \elts (a * x) \ elts (a * y + s)\ plus_eq_lift by auto finally have "lift (a*y) a \ a*y \ lift (a*y) s" . then have "lift (a*y) a \ lift (a*y) s" using add_le_cancel_left less_TC_imp_not_le plus_eq_lift \s \ a\ by auto then have "a \ s" by (simp add: le_iff_sup lift_eq_lift lift_sup_distrib) then show False using \s \ a\ less_TC_imp_not_le by auto qed consider "a * u \ a * y" | "a * y \ a * u" using t comparable vle_comparable_def by blast then have "False" proof cases case 1 then obtain c where "a*y = a*u + c" by (metis vle_def) then have "c+t = r'" by (metis add_right_cancel add.assoc t) then have "c \ a" using \r' \ elts a\ less_TC_iff vle2 vle_def by force moreover have "c \ 0" using \a * y = a * u + c\ noteq by auto ultimately show ?thesis using \a * y = a * u + c\ mult_eq_imp_0 by blast next case 2 then obtain c where "a*u = a*y + c" by (metis vle_def) then have "c+r' = t" by (metis add_right_cancel add.assoc t) then have "c \ a" by (metis \t \ elts s\ less_TC_iff less_TC_trans \s \ a\ vle2 vle_def) moreover have "c \ 0" using \a * u = a * y + c\ noteq by auto ultimately show ?thesis using \a * u = a * y + c\ mult_eq_imp_0 by blast qed then show "u \ elts y" .. qed qed next case (Limit k) obtain i j where k: "i \ elts k" "j \ elts k" and x: "x \ elts (Vset i)" and y: "y \ elts (Vset j)" using that Limit by (auto simp: Limit_Vfrom_eq) show ?case proof (rule Limit.IH [of "i \ j"]) show "i \ j \ elts k" by (meson k x y Limit.hyps Limit_def Ord_in_Ord Ord_mem_iff_lt Ord_sup union_less_iff) show "x \ elts (Vset (i \ j))" "y \ elts (Vset (i \ j))" using x y by (auto simp: Vfrom_sup) show "a * x + r \ a * y + s" by (simp add: Limit.prems) qed (auto simp: Limit.prems) qed then show ?thesis by (metis two_in_Vset Ord_rank Ord_VsetI rank_lt) qed theorem mult_cancellation_lemma: assumes "a*x + r = a*y + s" "r \ a" "s \ a" shows "x=y \ r=s" by (metis assms leD less_V_def mult_cancellation_half odiff_add_cancel order_refl) corollary mult_cancellation [simp]: fixes a::V assumes "a \ 0" shows "a*x = a*y \ x=y" by (metis assms nonzero_less_TC mult_cancellation_lemma) corollary mult_cancellation_less: assumes lt: "a*x + r < a*y + s" and "r \ a" "s \ a" obtains "x < y" | "x = y" "r < s" proof - have "x \ y" by (meson assms dual_order.strict_implies_order mult_cancellation_half) then consider "x < y" | "x = y" using less_V_def by blast with lt that show ?thesis by blast qed corollary lift_mult_TC_disjoint: fixes x::V assumes "x \ y" shows "lift (a*x) (TC a) \ lift (a*y) (TC a) = 0" apply (rule V_equalityI) using assms by (auto simp: less_TC_def inf_V_def lift_def image_iff dest: mult_cancellation_lemma) corollary lift_mult_disjoint: fixes x::V assumes "x \ y" shows "lift (a*x) a \ lift (a*y) a = 0" proof - have "lift (a*x) a \ lift (a*y) a \ lift (a*x) (TC a) \ lift (a*y) (TC a)" by (metis TC' inf_mono lift_sup_distrib sup_ge1) then show ?thesis using assms lift_mult_TC_disjoint by auto qed lemma mult_add_mem: assumes "a*x + r \ elts (a*y)" "r \ a" shows "x \ elts y" "r \ elts a" proof - obtain v s where v: "a * x + r = a * v + s" "v \ elts y" "s \ elts a" using assms unfolding mult [of a y] lift_def by auto then show "x \ elts y" by (metis arg_subset_TC assms(2) less_TC_def mult_cancellation_lemma vsubsetD) show "r \ elts a" by (metis arg_subset_TC assms(2) less_TC_def mult_cancellation_lemma v(1) v(3) vsubsetD) qed lemma mult_add_mem_0 [simp]: "a*x \ elts (a*y) \ x \ elts y \ 0 \ elts a" proof - have "x \ elts y" if "a * x \ elts (a * y) \ 0 \ elts a" using that using mult_add_mem [of a x 0] using nonzero_less_TC by force moreover have "a * x \ elts (a * y)" if "x \ elts y" "0 \ elts a" using that by (force simp: image_iff mult [of a y] lift_def) ultimately show ?thesis by (metis mult_eq_0_iff add.right_neutral mult_add_mem(2) nonzero_less_TC) qed lemma zero_mem_mult_iff: "0 \ elts (x*y) \ 0 \ elts x \ 0 \ elts y" by (metis Kirby.mult_zero_right mult_add_mem_0) lemma zero_less_mult_iff [simp]: "0 < x*y \ 0 < x \ 0 < y" if "Ord x" using Kirby.mult_eq_0_iff ZFC_in_HOL.neq0_conv by blast lemma mult_cancel_less_iff [simp]: "\Ord \; Ord \; Ord \\ \ \*\ < \*\ \ \ < \ \ 0 < \" using mult_add_mem_0 [of \ \ \] by (meson Ord_0 Ord_mem_iff_lt Ord_mult) lemma mult_cancel_le_iff [simp]: "\Ord \; Ord \; Ord \\ \ \*\ \ \*\ \ \ \ \ \ \=0" by (metis Ord_linear2 Ord_mult eq_iff leD mult_cancel_less_iff mult_cancellation) lemma mult_Suc_add_less: "\\ < \; \ < \; Ord \; Ord \; Ord \\ \ \ * ord_of_nat m + \ < \ * ord_of_nat (Suc m) + \" apply (simp add: mult_succ add.assoc) by (meson Ord_add Ord_linear2 le_less_trans not_add_less_right) lemma mult_nat_less_add_less: assumes "m < n" "\ < \" "\ < \" and ord: "Ord \" "Ord \" "Ord \" shows "\ * ord_of_nat m + \ < \ * ord_of_nat n + \" proof - have "Suc m \ n" using \m < n\ by auto have "\ * ord_of_nat m + \ < \ * ord_of_nat (Suc m) + \" using assms mult_Suc_add_less by blast also have "\ \ \ * ord_of_nat n + \" using Ord_mult Ord_ord_of_nat add_right_mono \Suc m \ n\ ord mult_cancel_le_iff ord_of_nat_mono_iff by presburger finally show ?thesis . qed lemma add_mult_less_add_mult: assumes "x < y" "x \ elts \" "y \ elts \" "\ \ elts \" "\ \ elts \" "Ord \" "Ord \" shows "\*x + \ < \*y + \" proof - obtain "Ord x" "Ord y" using Ord_in_Ord assms by blast then obtain \ where "0 \ elts \" "y = x + \" by (metis add.right_neutral \x < y\ le_Ord_diff less_V_def mem_0_Ord) then show ?thesis apply (simp add: add_mult_distrib add.assoc) by (meson OrdmemD add_le_cancel_left0 \\ \ elts \\ \Ord \\ less_le_trans zero_imp_le_mult) qed lemma add_mult_less: assumes "\ \ elts \" "\ \ elts \" "Ord \" "Ord \" shows "\ * \ + \ \ elts (\ * \)" proof - have "Ord \" using Ord_in_Ord assms by blast with assms show ?thesis by (metis Ord_mem_iff_lt Ord_succ add_mem_right_cancel mult_cancel_le_iff mult_succ succ_le_iff vsubsetD) qed lemma Ord_add_mult_iff: assumes "\ \ elts \" "\' \ elts \" "Ord \" "Ord \'" "Ord \" shows "\ * \ + \ \ elts (\ * \' + \') \ \ \ elts \' \ \ = \' \ \ \ elts \'" (is "?lhs \ ?rhs") proof assume L: ?lhs show ?rhs proof (cases "\ \ elts \'") case False with assms have "\ = \'" by (meson L Ord_linear Ord_mult Ord_trans add_mult_less not_add_mem_right) then show ?thesis using L less_V_def by auto qed auto next assume R: ?rhs then show ?lhs proof assume "\ \ elts \'" then obtain \ where "\' = \+\" by (metis OrdmemD assms(3) assms(4) le_Ord_diff less_V_def) show ?lhs using assms by (meson \\ \ elts \'\ add_le_cancel_left0 add_mult_less vsubsetD) next assume "\ = \' \ \ \ elts \'" then show ?lhs using less_V_def by auto qed qed lemma vcard_mult: "vcard (x * y) = vcard x \ vcard y" proof - have 1: "elts (lift (x * u) x) \ elts x" if "u \ elts y" for u by (metis cardinal_eqpoll eqpoll_sym eqpoll_trans card_lift) have 2: "pairwise (\u u'. disjnt (elts (lift (x * u) x)) (elts (lift (x * u') x))) (elts y)" by (simp add: pairwise_def disjnt_def) (metis V_disjoint_iff lift_mult_disjoint) - have "x * y = (SUP u\elts y. lift (x * u) x)" + have "x * y = (\u\elts y. lift (x * u) x)" using mult by blast then have "elts (x * y) \ (\u\elts y. elts (lift (x * u) x))" by simp also have "\ \ elts y \ elts x" using Union_eqpoll_Times [OF 1 2] . also have "\ \ elts x \ elts y" by (simp add: times_commute_eqpoll) also have "\ \ elts (vcard x) \ elts (vcard y)" using cardinal_eqpoll eqpoll_sym times_eqpoll_cong by blast also have "\ \ elts (vcard x \ vcard y)" by (simp add: cmult_def elts_vcard_VSigma_eqpoll eqpoll_sym) finally have "elts (x * y) \ elts (vcard x \ vcard y)" . then show ?thesis by (metis cadd_cmult_distrib cadd_def cardinal_cong cardinal_idem vsum_0_eqpoll) qed -proposition TC_mult: "TC(x * y) = (SUP r \ elts (TC x). SUP u \ elts (TC y). set{x * u + r})" +proposition TC_mult: "TC(x * y) = (\r \ elts (TC x). \u \ elts (TC y). set{x * u + r})" proof (cases "x = 0") case False - have *: "TC(x * y) = (SUP u \ elts (TC y). lift (x * u) (TC x))" for y + have *: "TC(x * y) = (\u \ elts (TC y). lift (x * u) (TC x))" for y proof (induction y rule: eps_induct) case (step y) - have "TC(x * y) = (SUP u \ elts y. TC (lift (x * u) x))" + have "TC(x * y) = (\u \ elts y. TC (lift (x * u) x))" by (simp add: mult [of x y] TC_Sup_distrib image_image) - also have "\ = (SUP u \ elts y. TC(x * u) \ lift (x * u) (TC x))" + also have "\ = (\u \ elts y. TC(x * u) \ lift (x * u) (TC x))" by (simp add: TC_lift False) - also have "\ = (SUP u \ elts y. (SUP z \ elts (TC u). lift (x * z) (TC x)) \ lift (x * u) (TC x))" + also have "\ = (\u \ elts y. (\z \ elts (TC u). lift (x * z) (TC x)) \ lift (x * u) (TC x))" by (simp add: step) - also have "\ = (SUP u \ elts (TC y). lift (x * u) (TC x))" + also have "\ = (\u \ elts (TC y). lift (x * u) (TC x))" by (auto simp: TC' [of y] image_Un Sup_Un_distrib TC_Sup_distrib cSUP_UNION SUP_sup_distrib) finally show ?case . qed show ?thesis by (force simp: * lift_def) qed auto corollary vcard_TC_mult: "vcard (TC(x * y)) = vcard (TC x) \ vcard (TC y)" proof - have "(\u\elts (TC x). \v\elts (TC y). {x * v + u}) = (\u\elts (TC x). (\v. x * v + u) ` elts (TC y))" by (simp add: UNION_singleton_eq_range) also have "\ \ (\x\elts (TC x). elts (lift (TC y * x) (TC y)))" proof (rule UN_eqpoll_UN) show "(\v. x * v + u) ` elts (TC y) \ elts (lift (TC y * u) (TC y))" if "u \ elts (TC x)" for u proof - have "inj_on (\v. x * v + u) (elts (TC y))" by (meson inj_onI less_TC_def mult_cancellation_lemma that) then have "(\v. x * v + u) ` elts (TC y) \ elts (TC y)" by (rule inj_on_image_eqpoll_self) also have "\ \ elts (lift (TC y * u) (TC y))" by (simp add: eqpoll_lift eqpoll_sym) finally show ?thesis . qed show "pairwise (\u ya. disjnt ((\v. x * v + u) ` elts (TC y)) ((\v. x * v + ya) ` elts (TC y))) (elts (TC x))" apply (auto simp: pairwise_def disjnt_def) using less_TC_def mult_cancellation_lemma by blast show "pairwise (\u ya. disjnt (elts (lift (TC y * u) (TC y))) (elts (lift (TC y * ya) (TC y)))) (elts (TC x))" apply (auto simp: pairwise_def disjnt_def) by (metis Int_iff V_disjoint_iff empty_iff lift_mult_disjoint) qed also have "\ = elts (TC y * TC x)" by (metis elts_Sup image_image mult replacement small_elts) finally have "(\u\elts (TC x). \v\elts (TC y). {x * v + u}) \ elts (TC y * TC x)" . then show ?thesis apply (subst cmult_commute) by (simp add: TC_mult cardinal_cong flip: vcard_mult) qed lemma countable_mult: assumes "countable (elts A)" "countable (elts B)" shows "countable (elts (A*B))" proof - have "vcard A \ \0" "vcard B \ \0" using assms countable_iff_le_Aleph0 by blast+ then have "vcard (A*B) \ \0" unfolding vcard_mult by (metis InfCard_csquare_eq cmult_le_mono Aleph_0 Card_\ InfCard_def order_refl) then show ?thesis by (simp add: countable_iff_le_Aleph0) qed subsection \Ordertype properties\ lemma ordertype_image_plus: assumes "Ord \" shows "ordertype ((+) u ` elts \) VWF = \" proof (subst ordertype_VWF_eq_iff) have 1: "(u + x, u + y) \ VWF" if "x \ elts \" "y \ elts \" "x < y" for x y using that by (meson Ord_in_Ord Ord_mem_iff_lt add_mem_right_cancel assms mem_imp_VWF) then have 2: "x < y" if "x \ elts \" "y \ elts \" "(u + x, u + y) \ VWF" for x y using that by (metis Ord_in_Ord Ord_linear_lt VWF_asym assms) show "\f. bij_betw f ((+) u ` elts \) (elts \) \ (\x\(+) u ` elts \. \y\(+) u ` elts \. (f x < f y) = ((x, y) \ VWF))" using 1 2 unfolding bij_betw_def inj_on_def by (rule_tac x="\x. odiff x u" in exI) (auto simp: image_iff) qed (use assms in auto) lemma ordertype_diff: assumes "\ + \ = \" and \: "\ \ elts \" "Ord \" shows "ordertype (elts \ - elts \) VWF = \" proof - have *: "elts \ - elts \ = ((+)\) ` elts \" proof show "elts \ - elts \ \ (+) \ ` elts \" by clarsimp (metis assms(1) image_iff mem_plus_V_E) show "(+) \ ` elts \ \ elts \ - elts \" using assms(1) not_add_mem_right by force qed have "ordertype ((+) \ ` elts \) VWF = \" proof (subst ordertype_VWF_inc_eq) show "elts \ \ ON" "ordertype (elts \) VWF = \" using \ elts_subset_ON ordertype_eq_Ord by blast+ qed (use "*" assms elts_subset_ON in auto) then show ?thesis by (simp add: *) qed lemma ordertype_interval_eq: assumes \: "Ord \" and \: "Ord \" shows "ordertype ({\ ..< \+\} \ ON) VWF = \" proof - have ON: "(+) \ ` elts \ \ ON" using assms Ord_add Ord_in_Ord by blast have "({\ ..< \+\} \ ON) = (+) \ ` elts \" using assms apply (simp add: image_def set_eq_iff) by (metis add_less_cancel_left Ord_add Ord_in_Ord Ord_linear2 Ord_mem_iff_lt le_Ord_diff not_add_less_right) moreover have "ordertype (elts \) VWF = ordertype ((+) \ ` elts \) VWF" using ON \ elts_subset_ON ordertype_VWF_inc_eq by auto ultimately show ?thesis using \ by auto qed lemma ordertype_Times: assumes "small A" "small B" and r: "wf r" "trans r" "total_on A r" and s: "wf s" "trans s" "total_on B s" shows "ordertype (A\B) (r <*lex*> s) = ordertype B s * ordertype A r" (is "_ = ?\ * ?\") proof (subst ordertype_eq_iff) show "Ord (?\ * ?\)" by (intro wf_Ord_ordertype Ord_mult r s; simp) define f where "f \ \(x,y). ?\ * ordermap A r x + (ordermap B s y)" show "\f. bij_betw f (A \ B) (elts (?\ * ?\)) \ (\x\A \ B. \y\A \ B. (f x < f y) = ((x, y) \ (r <*lex*> s)))" unfolding bij_betw_def proof (intro exI conjI strip) show "inj_on f (A \ B)" proof (clarsimp simp: f_def inj_on_def) fix x y x' y' assume "x \ A" "y \ B" "x' \ A" "y' \ B" and eq: "?\ * ordermap A r x + ordermap B s y = ?\ * ordermap A r x' + ordermap B s y'" have "ordermap A r x = ordermap A r x' \ ordermap B s y = ordermap B s y'" proof (rule mult_cancellation_lemma [OF eq]) show "ordermap B s y \ ?\" using ordermap_in_ordertype [OF \y \ B\, of s] less_TC_iff \small B\ by blast show "ordermap B s y' \ ?\" using ordermap_in_ordertype [OF \y' \ B\, of s] less_TC_iff \small B\ by blast qed then show "x = x' \ y = y'" using \x \ A\ \x' \ A\ \y \ B\ \y' \ B\ r s \small A\ \small B\ by auto qed show "f ` (A \ B) = elts (?\ * ?\)" (is "?lhs = ?rhs") proof show "f ` (A \ B) \ elts (?\ * ?\)" apply (auto simp: f_def add_mult_less ordermap_in_ordertype wf_Ord_ordertype r s) by (simp add: add_mult_less assms ordermap_in_ordertype wf_Ord_ordertype) show "elts (?\ * ?\) \ f ` (A \ B)" proof (clarsimp simp: f_def image_iff elim !: elts_multE split: prod.split) fix u v assume u: "u \ elts (?\)" and v: "v \ elts ?\" have "inv_into B (ordermap B s) u \ B" by (simp add: inv_into_ordermap u) moreover have "inv_into A (ordermap A r) v \ A" by (simp add: inv_into_ordermap v) ultimately show "\x\A. \y\B. ?\ * v + u = ?\ * ordermap A r x + ordermap B s y" by (metis \small A\ \small B\ bij_betw_inv_into_right ordermap_bij r(1) r(3) s(1) s(3) u v) qed qed next fix p q assume "p \ A \ B" and "q \ A \ B" then obtain u v x y where \
: "p = (u,v)" "u \ A" "v \ B" "q = (x,y)" "x \ A" "y \ B" by blast show "((f p) < f q) = ((p, q) \ (r <*lex*> s))" proof assume "f p < f q" with \
assms have "(u, x) \ r \ u=x \ (v, y) \ s" apply (simp add: f_def) by (metis Ord_add Ord_add_mult_iff Ord_mem_iff_lt Ord_mult wf_Ord_ordermap converse_ordermap_mono ordermap_eq_iff ordermap_in_ordertype wf_Ord_ordertype) then show "(p,q) \ (r <*lex*> s)" by (simp add: \
) next assume "(p,q) \ (r <*lex*> s)" then have "(u, x) \ r \ u = x \ (v, y) \ s" by (simp add: \
) then show "f p < f q" proof assume ux: "(u, x) \ r" have oo: "\x. Ord (ordermap A r x)" "\y. Ord (ordermap B s y)" by (simp_all add: r s) show "f p < f q" proof (clarsimp simp: f_def split: prod.split) fix a b a' b' assume "p = (a, b)" and "q = (a', b')" then have "?\ * ordermap A r a + ordermap B s b < ?\ * ordermap A r a'" using ux assms \
by (metis Ord_mult wf_Ord_ordermap OrdmemD Pair_inject add_mult_less ordermap_in_ordertype ordermap_mono wf_Ord_ordertype) also have "\ \ ?\ * ordermap A r a' + ordermap B s b'" by simp finally show "?\ * ordermap A r a + ordermap B s b < ?\ * ordermap A r a' + ordermap B s b'" . qed next assume "u = x \ (v, y) \ s" then show "f p < f q" using \
assms by (fastforce simp: f_def split: prod.split intro: ordermap_mono_less) qed qed qed qed (use assms small_Times in auto) end diff --git a/thys/ZFC_in_HOL/Ordinal_Exp.thy b/thys/ZFC_in_HOL/Ordinal_Exp.thy --- a/thys/ZFC_in_HOL/Ordinal_Exp.thy +++ b/thys/ZFC_in_HOL/Ordinal_Exp.thy @@ -1,589 +1,589 @@ section \Exponentiation of ordinals\ theory Ordinal_Exp imports Kirby begin text \Source: Schlöder, Julian. Ordinal Arithmetic; available online at \url{http://www.math.uni-bonn.de/ag/logik/teaching/2012WS/Set%20theory/oa.pdf}\ definition oexp :: "[V,V] \ V" (infixr "\" 80) where "oexp a b \ transrec (\f x. if x=0 then 1 - else if Limit x then if a=0 then 0 else SUP \ \ elts x. f \ + else if Limit x then if a=0 then 0 else \\ \ elts x. f \ else f (\(elts x)) * a) b" text \@{term "0\\ = 1"} if we don't make a special case for Limit ordinals and zero\ lemma oexp_0_right [simp]: "\\0 = 1" by (simp add: def_transrec [OF oexp_def]) lemma oexp_succ [simp]: "Ord \ \ \\(succ \) = \\\ * \" by (simp add: def_transrec [OF oexp_def]) -lemma oexp_Limit: "Limit \ \ \\\ = (if \=0 then 0 else SUP \ \ elts \. \\\)" +lemma oexp_Limit: "Limit \ \ \\\ = (if \=0 then 0 else \\ \ elts \. \\\)" by (auto simp: def_transrec [OF oexp_def, of _ \]) lemma oexp_1_right [simp]: "\\1 = \" using one_V_def oexp_succ by fastforce lemma oexp_1 [simp]: "Ord \ \ 1\\ = 1" by (induction rule: Ord_induct3) (use Limit_def oexp_Limit in auto) lemma oexp_0 [simp]: "Ord \ \ 0\\ = (if \ = 0 then 1 else 0)" by (induction rule: Ord_induct3) (use Limit_def oexp_Limit in auto) lemma oexp_eq_0_iff [simp]: assumes "Ord \" shows "\\\ = 0 \ \=0 \ \\0" using \Ord \\ proof (induction rule: Ord_induct3) case (Limit \) then show ?case using Limit_def oexp_Limit by auto qed auto lemma oexp_gt_0_iff [simp]: assumes "Ord \" shows "\\\ > 0 \ \>0 \ \=0" by (simp add: assms less_V_def) lemma ord_of_nat_oexp: "ord_of_nat (m^n) = ord_of_nat m\ord_of_nat n" proof (induction n) case (Suc n) then show ?case by (simp add: mult.commute [of m]) (simp add: ord_of_nat_mult) qed auto lemma omega_closed_oexp [intro]: assumes "\ \ elts \" "\ \ elts \" shows "\\\ \ elts \" proof - obtain m n where "\ = ord_of_nat m" "\ = ord_of_nat n" using assms elts_\ by auto then have "\\\ = ord_of_nat (m^n)" by (simp add: ord_of_nat_oexp) then show ?thesis by (simp add: \_def) qed lemma Ord_oexp [simp]: assumes "Ord \" "Ord \" shows "Ord (\\\)" using \Ord \\ proof (induction rule: Ord_induct3) case (Limit \) then show ?case by (auto simp: oexp_Limit image_iff intro: Ord_Sup) qed (auto intro: Ord_mult assms) text \Lemma 3.19\ lemma le_oexp: assumes "Ord \" "Ord \" "\ \ 0" shows "\ \ \\\" using \Ord \\ \\ \ 0\ proof (induction rule: Ord_induct3) case (succ \) then show ?case by simp (metis \Ord \\ le_0 le_mult mult.left_neutral oexp_0_right order_refl order_trans) next case (Limit \) then show ?case by (metis Limit_def Limit_eq_Sup_self ZFC_in_HOL.Sup_upper eq_iff image_eqI image_ident oexp_1_right oexp_Limit replacement small_elts one_V_def) qed auto text \Lemma 3.20\ lemma le_oexp': assumes "Ord \" "1 < \" "Ord \" shows "\ \ \\\" proof (cases "\ = 0") case True then show ?thesis by auto next case False show ?thesis using \Ord \\ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case (succ \) then have "\\\ * 1 < \\\ * \" using \Ord \\ \1 < \\ by (metis le_mult less_V_def mult.right_neutral mult_cancellation not_less_0 oexp_eq_0_iff succ.hyps) then have " \ < \\succ \" using succ.IH succ.hyps by auto then show ?case using False \Ord \\ \1 < \\ succ by (metis Ord_mem_iff_lt Ord_oexp Ord_succ elts_succ insert_subset less_eq_V_def less_imp_le) next case (Limit \) with False \1 < \\ show ?case by (force simp: Limit_def oexp_Limit intro: elts_succ) qed qed lemma oexp_Limit_le: assumes "\ < \" "Limit \" "Ord \" "\ > 0" shows "\\\ \ \\\" proof - have "Ord \" using Limit_def assms(2) by blast with assms show ?thesis using Ord_mem_iff_lt ZFC_in_HOL.Sup_upper oexp_Limit by auto qed proposition oexp_less: assumes \: "\ \ elts \" and "Ord \" and \: "\ > 1" "Ord \" shows "\\\ < \\\" proof - obtain "\ < \" "Ord \" using Ord_in_Ord OrdmemD assms by auto have gt0: "\\\ > 0" using \Ord \\ \ dual_order.order_iff_strict by auto show ?thesis using \Ord \\ \ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case (succ \) then consider "\ = \" | "\ < \" using OrdmemD elts_succ by blast then show ?case proof cases case 1 then have "(\\\) * 1 < (\\\) * \" using Ord_1 Ord_oexp \ gt0 mult_cancel_less_iff succ.hyps by metis then show ?thesis by (simp add: succ.hyps) next case 2 then have "(\\\) * 1 < (\\\) * \" by (meson Ord_1 Ord_mem_iff_lt Ord_oexp \Ord \\ \ gt0 less_trans mult_cancel_less_iff succ) with 2 show ?thesis using Ord_mem_iff_lt \Ord \\ succ by auto qed next case (Limit \) then obtain "Ord \" "succ \ < \" using Limit_def Ord_in_Ord OrdmemD assms by auto have "\\\ = (\\\) * 1" by simp also have "\ < (\\\) * \" using Ord_oexp \Ord \\ assms gt0 mult_cancel_less_iff by blast also have "\ = \\succ \" by (simp add: \Ord \\) - also have "\ \ (SUP \ \ elts \. \\\)" + also have "\ \ (\\ \ elts \. \\\)" proof - have "succ \ \ elts \" using Limit.hyps Limit.prems Limit_def by auto then show ?thesis by (simp add: ZFC_in_HOL.Sup_upper) qed finally - have "\\\ < (SUP \ \ elts \. \\\)" . + have "\\\ < (\\ \ elts \. \\\)" . then show ?case using Limit.hyps oexp_Limit \\ > 1\ by auto qed qed corollary oexp_less_iff: assumes "\ > 0" "Ord \" "Ord \" "Ord \" shows "\\\ < \\\ \ \ \ elts \ \ \ > 1" proof safe show "\ \ elts \" "1 < \" if "\\\ < \\\" proof - show "\ > 1" proof (rule ccontr) assume "\ \ > 1" then consider "\=0" | "\=1" using \Ord \\ less_V_def mem_0_Ord by fastforce then show False by cases (use that \\ > 0\ \Ord \\ \Ord \\ in \auto split: if_split_asm\) qed show \: "\ \ elts \" proof (rule ccontr) assume "\ \ elts \" then have "\ \ \" by (meson Ord_linear_le Ord_mem_iff_lt assms less_le_not_le) then consider "\ = \" | "\ < \" using less_V_def by blast then show False proof cases case 1 then show ?thesis using that by blast next case 2 with \\ > 1\ have "\\\ < \\\" by (simp add: Ord_mem_iff_lt assms oexp_less) with that show ?thesis by auto qed qed qed show "\\\ < \\\" if "\ \ elts \" "1 < \" using that by (simp add: assms oexp_less) qed lemma \_oexp_iff [simp]: "\Ord \; Ord \\ \ \\\ = \\\ \ \=\" by (metis Ord_\ Ord_linear \_gt1 less_irrefl oexp_less) lemma Limit_oexp: assumes "Limit \" "Ord \" "\ > 1" shows "Limit (\\\)" unfolding Limit_def proof safe show O\\: "Ord (\\\)" using Limit_def Ord_oexp \Limit \\ assms(2) by blast show 0: "0 \ elts (\\\)" using Limit_def oexp_Limit \Limit \\ \\ > 1\ by fastforce have "Ord \" using Limit_def \Limit \\ by blast fix x assume x: "x \ elts (\\\)" with \Limit \\ \\ > 1\ obtain \ where "\ < \" "Ord \" "Ord x" and x\: "x \ elts (\\\)" apply (simp add: oexp_Limit split: if_split_asm) using Ord_in_Ord OrdmemD \Ord \\ O\\ x by blast then have O\\: "Ord (\\\)" using Ord_oexp assms(2) by blast have "\ \ elts \" by (simp add: Ord_mem_iff_lt \Ord \\ \Ord \\ \\ < \\) moreover have "\ \ 0" using \\ > 1\ by blast ultimately have \\\: "\\\ \ \\\" by (simp add: Sup_upper oexp_Limit \Limit \\) have "succ x \ \\\" by (simp add: OrdmemD O\\ \Ord x\ succ_le_iff x\) then consider "succ x < \\\" | "succ x = \\\" using le_neq_trans by blast then show "succ x \ elts (\\\)" proof cases case 1 with \\\ show ?thesis using O\\ Ord_mem_iff_lt \Ord x\ by blast next case 2 then have "succ \ < \" using Limit_def OrdmemD \\ \ elts \\ assms(1) by auto have ge1: "1 \ \\\" by (metis "2" Ord_0 \Ord x\ le_0 le_succ_iff one_V_def) have "succ x < succ (\\\)" using "2" O\\ succ_le_iff by auto also have "\ \ (\\\) + (\\\)" using ge1 by (simp add: succ_eq_add1) also have "\ = (\\\) * succ (succ 0)" by (simp add: mult_succ) also have "\ \ (\\\) * \" using O\\ Ord_succ assms(2) assms(3) one_V_def succ_le_iff by auto also have "\ = \\succ \" by (simp add: \Ord \\) also have "\ \ \\\" by (meson Limit_def \\ \ elts \\ assms dual_order.order_iff_strict oexp_less) finally show ?thesis by (simp add: "2" O\\ O\\ Ord_mem_iff_lt) qed qed lemma oexp_mono: assumes \: "Ord \" "\ \ 0" and \: "Ord \" "\ \ \" shows "\\\ \ \\\" using \ proof (induction rule: Ord_induct3) case 0 then show ?case by simp next case (succ \) with \ le_mult show ?case by (auto simp: le_TC_succ) next case (Limit \) then have "\\\ \ \ ((\) \ ` elts \)" using Limit.hyps Ord_less_TC_mem \\ \ 0\ le_TC_def by (auto simp: oexp_Limit Limit_def) then show ?case using \ by (simp add: oexp_Limit Limit.hyps) qed lemma oexp_mono_le: assumes "\ \ \" "\ \ 0" "Ord \" "Ord \" "Ord \" shows "\\\ \ \\\" by (simp add: assms oexp_mono vle2 vle_iff_le_Ord) lemma oexp_sup: assumes "\ \ 0" "Ord \" "Ord \" "Ord \" shows "\\(\ \ \) = \\\ \ \\\" by (metis Ord_linear_le assms oexp_mono_le sup.absorb2 sup.orderE) lemma oexp_Sup: assumes \: "\ \ 0" "Ord \" and X: "X \ ON" "small X" "X \ {}" shows "\\\ X = \ ((\) \ ` X)" proof (rule order_antisym) show "\ ((\) \ ` X) \ \\\ X" by (metis ON_imp_Ord Ord_Sup ZFC_in_HOL.Sup_upper assms cSUP_least oexp_mono_le) next have "Ord (Sup X)" using Ord_Sup X by auto then show "\\\ X \ \ ((\) \ ` X)" proof (cases rule: Ord_cases) case 0 then show ?thesis using X dual_order.antisym by fastforce next case (succ \) then show ?thesis using ZFC_in_HOL.Sup_upper X succ_in_Sup_Ord by auto next case limit show ?thesis proof (clarsimp simp: assms oexp_Limit limit) fix x y z assume x: "x \ elts (\ \ y)" and "z \ X" "y \ elts z" then have "\ \ y \ \ \ z" by (meson ON_imp_Ord Ord_in_Ord OrdmemD \ \X \ ON\ le_less oexp_mono_le) with x have "x \ elts (\ \ z)" by blast then show "\u\X. x \ elts (\ \ u)" using \z \ X\ by blast qed qed qed lemma omega_le_Limit: assumes "Limit \" shows "\ \ \" proof fix \ assume "\ \ elts \" then obtain n where "\ = ord_of_nat n" using elts_\ by auto have "ord_of_nat n \ elts \" by (induction n) (use Limit_def assms in auto) then show "\ \ elts \" using \\ = ord_of_nat n\ by auto qed lemma finite_omega_power [simp]: assumes "1 < n" "n \ elts \" shows "n\\ = \" proof (rule order_antisym) have "\ ((\) (ord_of_nat k) ` elts \) \ \" for k proof (induction k) case 0 then show ?case by auto next case (Suc k) then show ?case by (metis Ord_\ OrdmemD Sup_eq_0_iff ZFC_in_HOL.SUP_le_iff le_0 le_less omega_closed_oexp ord_of_nat_\) qed then show "n\\ \ \" using assms by (simp add: elts_\ oexp_Limit) metis show "\ \ n\\" using Ord_in_Ord assms le_oexp' by blast qed proposition oexp_add: assumes "Ord \" "Ord \" "Ord \" shows "\\(\ + \) = \\\ * \\\" proof (cases \\ = 0\) case True then show ?thesis using assms by simp next case False show ?thesis using \Ord \\ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case (succ \) then show ?case using \Ord \\ by (auto simp: plus_V_succ_right mult.assoc) next case (Limit \) - have "\\(\ + (SUP \\elts \. \)) = (SUP \\elts (\ + \). \\\)" + have "\\(\ + (\\\elts \. \)) = (\\\elts (\ + \). \\\)" by (simp add: Limit.hyps oexp_Limit assms False) - also have "\ = (SUP \ \ {\. Ord \ \ \ + \ < \ + \}. \\(\ + \))" + also have "\ = (\\ \ {\. Ord \ \ \ + \ < \ + \}. \\(\ + \))" proof (rule Sup_eq_Sup) show "(\\. \\(\ + \)) ` {\. Ord \ \ \ + \ < \ + \} \ (\) \ ` elts (\ + \)" using Limit.hyps Limit_def Ord_mem_iff_lt imageI by blast fix x assume "x \ (\) \ ` elts (\ + \)" then obtain \ where \: "\ \ elts (\ + \)" and x: "x = \\\" by auto have "\\. Ord \ \ \ < \ \ \\\ \ \\(\ + \)" proof (rule mem_plus_V_E [OF \]) assume "\ \ elts \" then have "\\\ \ \\\" by (meson arg_subset_TC assms False le_TC_def less_TC_def oexp_mono vsubsetD) with zero_less_Limit [OF \Limit \\] show "\\. Ord \ \ \ < \ \ \\\ \ \\(\ + \)" by force next fix \ assume "\ \ elts \" and "\ = \ + \" have "Ord \" using Limit.hyps Limit_def Ord_in_Ord \\ \ elts \\ by blast moreover have "\ < \" using Limit.hyps Limit_def OrdmemD \\ \ elts \\ by auto ultimately show "\\. Ord \ \ \ < \ \ \\\ \ \\(\ + \)" using \\ = \ + \\ by blast qed then show "\y\(\\. \\(\ + \)) ` {\. Ord \ \ \ + \ < \ + \}. x \ y" using x by auto qed auto - also have "\ = (SUP \\elts \. \\(\ + \))" + also have "\ = (\\\elts \. \\(\ + \))" using \Limit \\ by (simp add: Ord_Collect_lt Limit_def) - also have "\ = (SUP \\elts \. \\\ * \\\)" + also have "\ = (\\\elts \. \\\ * \\\)" using Limit.IH by auto - also have "\ = \\\ * \\(SUP \\elts \. \)" + also have "\ = \\\ * \\(\\\elts \. \)" using \\ \ 0\ Limit.hyps by (simp add: image_image oexp_Limit mult_Sup_distrib) finally show ?case . qed qed proposition oexp_mult: assumes "Ord \" "Ord \" "Ord \" shows "\\(\ * \) = (\\\)\\" proof (cases "\ = 0 \ \ = 0") case True then show ?thesis by (auto simp: \Ord \\ \Ord \\) next case False show ?thesis using \Ord \\ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case succ then show ?case using assms by (auto simp: mult_succ oexp_add) next case (Limit \) have Lim: "Limit (\ ((*) \ ` elts \))" unfolding Limit_def proof (intro conjI allI impI) show "Ord (\ ((*) \ ` elts \))" using Limit.hyps Limit_def Ord_in_Ord \Ord \\ by (auto intro: Ord_Sup) have "succ 0 \ elts \" using Limit.hyps Limit_def by blast then show "0 \ elts (\ ((*) \ ` elts \))" using False \Ord \\ mem_0_Ord by force show "succ y \ elts (\ ((*) \ ` elts \))" if "y \ elts (\ ((*) \ ` elts \))" for y using that False Limit.hyps apply (clarsimp simp: Limit_def) by (metis Ord_in_Ord Ord_linear Ord_mem_iff_lt Ord_mult Ord_succ assms(2) less_V_def mult_cancellation mult_succ not_add_mem_right succ_le_iff succ_ne_self) qed - have "\\(\ * (SUP \\elts \. \)) = \\\ ((*) \ ` elts \)" + have "\\(\ * (\\\elts \. \)) = \\\ ((*) \ ` elts \)" by (simp add: mult_Sup_distrib) also have "\ = \ (\x\elts \. (\) \ ` elts (\ * x))" using False Lim oexp_Limit by fastforce - also have "\ = (SUP x\elts \. \\(\ * x))" + also have "\ = (\x\elts \. \\(\ * x))" proof (rule Sup_eq_Sup) show "(\x. \\(\ * x)) ` elts \ \ (\x\elts \. (\) \ ` elts (\ * x))" using \Ord \\ \Ord \\ False Limit apply clarsimp by (metis Limit_def elts_succ imageI insertI1 mem_0_Ord mult_add_mem_0) show "\y\(\x. \\(\ * x)) ` elts \. x \ y" if "x \ (\x\elts \. (\) \ ` elts (\ * x))" for x using that \Ord \\ \Ord \\ False Limit by clarsimp (metis Limit_def Ord_in_Ord Ord_mult VWO_TC_le mem_imp_VWO oexp_mono) qed auto - also have "\ = \ ((\) (\\\) ` elts (SUP \\elts \. \))" + also have "\ = \ ((\) (\\\) ` elts (\\\elts \. \))" using Limit.IH Limit.hyps by auto - also have "\ = (\\\)\(SUP \\elts \. \)" + also have "\ = (\\\)\(\\\elts \. \)" using False Limit.hyps oexp_Limit \Ord \\ by auto finally show ?case . qed qed lemma Limit_omega_oexp: assumes "Ord \" "\ \ 0" shows "Limit (\\\)" using assms proof (cases \ rule: Ord_cases) case 0 then show ?thesis using assms(2) by blast next case (succ l) have *: "succ \ \ elts (\\l * n + \\l)" if n: "n \ elts \" and \: "\ \ elts (\\l * n)" for n \ proof - obtain "Ord n" "Ord \" by (meson Ord_\ Ord_in_Ord Ord_mult Ord_oexp \ n succ(1)) obtain oo: "Ord (\\l)" "Ord (\\l * n)" by (simp add: \Ord n\ succ(1)) moreover have f4: "\ < \\l * n" using oo Ord_mem_iff_lt \Ord \\ \\ \ elts (\\l * n)\ by blast moreover have f5: "Ord (succ \)" using \Ord \\ by blast moreover have "\\l \ 0" using oexp_eq_0_iff omega_nonzero succ(1) by blast ultimately show ?thesis by (metis add_less_cancel_left Ord_\ Ord_add Ord_mem_iff_lt OrdmemD \Ord \\ add.right_neutral dual_order.strict_trans2 oexp_gt_0_iff succ(1) succ_le_iff zero_in_omega) qed show ?thesis using succ apply (clarsimp simp: Limit_def mem_0_Ord) apply (simp add: mult_Limit) by (metis * mult_succ succ_in_omega) next case limit then show ?thesis by (metis Limit_oexp Ord_\ OrdmemD one_V_def succ_in_omega zero_in_omega) qed lemma oexp_mult_commute: fixes j::nat assumes "Ord \" shows "(\ \ j) * \ = \ * (\ \ j)" proof - have "(\ \ j) * \ = \ \ (1 + ord_of_nat j)" by (simp add: one_V_def) also have "... = \ * (\ \ j)" by (simp add: assms oexp_add) finally show ?thesis . qed -lemma oexp_\_Limit: "Limit \ \ \\\ = (SUP \ \ elts \. \\\)" +lemma oexp_\_Limit: "Limit \ \ \\\ = (\\ \ elts \. \\\)" by (simp add: oexp_Limit) lemma \_power_succ_gtr: "Ord \ \ \ \ \ * ord_of_nat n < \ \ succ \" by (simp add: OrdmemD) lemma countable_oexp: assumes \: "\ \ elts \1" shows "\ \ \ \ elts \1" proof - have "Ord \" using Ord_\1 Ord_in_Ord assms by blast then show ?thesis using assms proof (induction rule: Ord_induct3) case 0 then show ?case by (simp add: Ord_mem_iff_lt) next case (succ \) then have "countable (elts (\ \ \ * \))" by (simp add: succ_in_Limit_iff countable_mult less_\1_imp_countable) then show ?case using Ord_mem_iff_lt countable_iff_less_\1 succ.hyps by auto next case (Limit \) with Ord_\1 have "countable (\\\elts \. elts (\ \ \))" "Ord (\ \ \ (elts \))" by (force simp: Limit_def intro: Ord_trans less_\1_imp_countable)+ then have "\ \ \ (elts \) < \1" using Limit.hyps countable_iff_less_\1 oexp_Limit by fastforce then show ?case using Limit.hyps Limit_def Ord_mem_iff_lt by auto qed qed end diff --git a/thys/ZFC_in_HOL/ZFC_Cardinals.thy b/thys/ZFC_in_HOL/ZFC_Cardinals.thy --- a/thys/ZFC_in_HOL/ZFC_Cardinals.thy +++ b/thys/ZFC_in_HOL/ZFC_Cardinals.thy @@ -1,2541 +1,2538 @@ section \Cartesian products, Disjoint Sums, Ranks, Cardinals\ theory ZFC_Cardinals imports ZFC_in_HOL begin declare [[coercion_enabled]] declare [[coercion "ord_of_nat :: nat \ V"]] subsection \Ordered Pairs\ lemma singleton_eq_iff [iff]: "set {a} = set {b} \ a=b" by simp lemma doubleton_eq_iff: "set {a,b} = set {c,d} \ (a=c \ b=d) \ (a=d \ b=c)" by (simp add: Set.doubleton_eq_iff) definition vpair :: "V \ V \ V" where "vpair a b = set {set {a},set {a,b}}" definition vfst :: "V \ V" where "vfst p \ THE x. \y. p = vpair x y" definition vsnd :: "V \ V" where "vsnd p \ THE y. \x. p = vpair x y" definition vsplit :: "[[V, V] \ 'a, V] \ 'a::{}" \ \for pattern-matching\ where "vsplit c \ \p. c (vfst p) (vsnd p)" nonterminal Vs syntax (ASCII) "_Tuple" :: "[V, Vs] \ V" ("<(_,/ _)>") "_hpattern" :: "[pttrn, patterns] \ pttrn" ("<_,/ _>") syntax "" :: "V \ Vs" ("_") "_Enum" :: "[V, Vs] \ Vs" ("_,/ _") "_Tuple" :: "[V, Vs] \ V" ("\(_,/ _)\") "_hpattern" :: "[pttrn, patterns] \ pttrn" ("\_,/ _\") translations "" \ ">" "" \ "CONST vpair x y" "" \ ">" "\. b" \ "CONST vsplit(\x . b)" "\. b" \ "CONST vsplit(\x y. b)" lemma vpair_def': "vpair a b = set {set {a,a},set {a,b}}" by (simp add: vpair_def) lemma vpair_iff [simp]: "vpair a b = vpair a' b' \ a=a' \ b=b'" unfolding vpair_def' doubleton_eq_iff by auto lemmas vpair_inject = vpair_iff [THEN iffD1, THEN conjE, elim!] lemma vfst_conv [simp]: "vfst \a,b\ = a" by (simp add: vfst_def) lemma vsnd_conv [simp]: "vsnd \a,b\ = b" by (simp add: vsnd_def) lemma vsplit [simp]: "vsplit c \a,b\ = c a b" by (simp add: vsplit_def) lemma vpair_neq_fst: "\a,b\ \ a" by (metis elts_of_set insertI1 mem_not_sym small_upair vpair_def') lemma vpair_neq_snd: "\a,b\ \ b" by (metis elts_of_set insertI1 mem_not_sym small_upair subsetD subset_insertI vpair_def') lemma vpair_nonzero [simp]: "\x,y\ \ 0" by (metis elts_0 elts_of_set empty_not_insert small_upair vpair_def) lemma zero_notin_vpair: "0 \ elts \x,y\" by (auto simp: vpair_def) lemma inj_on_vpair [simp]: "inj_on (\(x, y). \x, y\) A" by (auto simp: inj_on_def) subsection \Generalized Cartesian product\ definition VSigma :: "V \ (V \ V) \ V" where "VSigma A B \ set(\x \ elts A. \y \ elts (B x). {\x,y\})" abbreviation vtimes where "vtimes A B \ VSigma A (\x. B)" definition pairs :: "V \ (V * V)set" where "pairs r \ {(x,y). \x,y\ \ elts r} " lemma pairs_iff_elts: "(x,y) \ pairs z \ \x,y\ \ elts z" by (simp add: pairs_def) lemma VSigma_iff [simp]: "\a,b\ \ elts (VSigma A B) \ a \ elts A \ b \ elts (B a)" by (auto simp: VSigma_def UNION_singleton_eq_range) lemma VSigmaI [intro!]: "\ a \ elts A; b \ elts (B a)\ \ \a,b\ \ elts (VSigma A B)" by simp lemmas VSigmaD1 = VSigma_iff [THEN iffD1, THEN conjunct1] lemmas VSigmaD2 = VSigma_iff [THEN iffD1, THEN conjunct2] text \The general elimination rule\ lemma VSigmaE [elim!]: assumes "c \ elts (VSigma A B)" obtains x y where "x \ elts A" "y \ elts (B x)" "c=\x,y\" using assms by (auto simp: VSigma_def split: if_split_asm) lemma VSigmaE2 [elim!]: assumes "\a,b\ \ elts (VSigma A B)" obtains "a \ elts A" and "b \ elts (B a)" using assms by auto lemma VSigma_empty1 [simp]: "VSigma 0 B = 0" by auto lemma times_iff [simp]: "\a,b\ \ elts (vtimes A B) \ a \ elts A \ b \ elts B" by simp lemma timesI [intro!]: "\a \ elts A; b \ elts B\ \ \a,b\ \ elts (vtimes A B)" by simp lemma times_empty2 [simp]: "vtimes A 0 = 0" using elts_0 by blast lemma times_empty_iff: "VSigma A B = 0 \ A=0 \ (\x \ elts A. B x = 0)" by (metis VSigmaE VSigmaI elts_0 empty_iff trad_foundation) lemma elts_VSigma: "elts (VSigma a b) = (\(x,y). vpair x y) ` Sigma (elts a) (\x. elts (b x))" by auto lemma small_Times [simp]: assumes "small A" "small B" shows "small (A \ B)" proof - obtain f a g b where "inj_on f A" "inj_on g B" and f: "f ` A = elts a" and g: "g ` B = elts b" using assms by (auto simp: small_def) define h where "h \ \(x,y). \f x, g y\" show ?thesis unfolding small_def proof (intro exI conjI) show "inj_on h (A \ B)" using \inj_on f A\ \inj_on g B\ by (simp add: h_def inj_on_def) have "h ` (A \ B) = elts (vtimes a b)" using f g by (fastforce simp: h_def image_iff split: prod.split) then show "h ` (A \ B) \ range elts" by blast qed qed subsection \Disjoint Sum\ definition vsum :: "V \ V \ V" (infixl "\" 65) where "A \ B \ (VSigma (set {0}) (\x. A)) \ (VSigma (set {1}) (\x. B))" definition Inl :: "V\V" where "Inl a \ \0,a\" definition Inr :: "V\V" where "Inr b \ \1,b\" lemmas sum_defs = vsum_def Inl_def Inr_def lemma Inl_nonzero [simp]:"Inl x \ 0" by (metis Inl_def vpair_nonzero) lemma Inr_nonzero [simp]:"Inr x \ 0" by (metis Inr_def vpair_nonzero) subsubsection\Equivalences for the injections and an elimination rule\ lemma Inl_in_sum_iff [iff]: "Inl a \ elts (A \ B) \ a \ elts A" by (auto simp: sum_defs) lemma Inr_in_sum_iff [iff]: "Inr b \ elts (A \ B) \ b \ elts B" by (auto simp: sum_defs) lemma sumE [elim!]: assumes u: "u \ elts (A \ B)" obtains x where "x \ elts A" "u=Inl x" | y where "y \ elts B" "u=Inr y" using u by (auto simp: sum_defs) subsubsection \Injection and freeness equivalences, for rewriting\ lemma Inl_iff [iff]: "Inl a=Inl b \ a=b" by (simp add: sum_defs) lemma Inr_iff [iff]: "Inr a=Inr b \ a=b" by (simp add: sum_defs) lemma inj_on_Inl [simp]: "inj_on Inl A" by (simp add: inj_on_def) lemma inj_on_Inr [simp]: "inj_on Inr A" by (simp add: inj_on_def) lemma Inl_Inr_iff [iff]: "Inl a=Inr b \ False" by (simp add: sum_defs) lemma Inr_Inl_iff [iff]: "Inr b=Inl a \ False" by (simp add: sum_defs) lemma sum_empty [simp]: "0 \ 0 = 0" by auto lemma elts_vsum: "elts (a \ b) = Inl ` (elts a) \ Inr ` (elts b)" by auto lemma sum_iff: "u \ elts (A \ B) \ (\x. x \ elts A \ u=Inl x) \ (\y. y \ elts B \ u=Inr y)" by blast lemma sum_subset_iff: "A\B \ C\D \ A\C \ B\D" by (auto simp: less_eq_V_def) lemma sum_equal_iff: fixes A :: V shows "A\B = C\D \ A=C \ B=D" by (simp add: eq_iff sum_subset_iff) definition is_sum :: "V \ bool" where "is_sum z = (\x. z = Inl x \ z = Inr x)" definition sum_case :: "(V \ 'a) \ (V \ 'a) \ V \ 'a" where "sum_case f g a \ THE z. (\x. a = Inl x \ z = f x) \ (\y. a = Inr y \ z = g y) \ (\ is_sum a \ z = undefined)" lemma sum_case_Inl [simp]: "sum_case f g (Inl x) = f x" by (simp add: sum_case_def is_sum_def) lemma sum_case_Inr [simp]: "sum_case f g (Inr y) = g y" by (simp add: sum_case_def is_sum_def) lemma sum_case_non [simp]: "\ is_sum a \ sum_case f g a = undefined" by (simp add: sum_case_def is_sum_def) lemma is_sum_cases: "(\x. z = Inl x \ z = Inr x) \ \ is_sum z" by (auto simp: is_sum_def) lemma sum_case_split: "P (sum_case f g a) \ (\x. a = Inl x \ P(f x)) \ (\y. a = Inr y \ P(g y)) \ (\ is_sum a \ P undefined)" by (cases "is_sum a") (auto simp: is_sum_def) lemma sum_case_split_asm: "P (sum_case f g a) \ \ ((\x. a = Inl x \ \ P(f x)) \ (\y. a = Inr y \ \ P(g y)) \ (\ is_sum a \ \ P undefined))" by (auto simp: sum_case_split) subsubsection \Applications of disjoint sums and pairs: general union theorems for small sets\ lemma small_Un: assumes X: "small X" and Y: "small Y" shows "small (X \ Y)" proof - obtain f g :: "'a\V" where f: "inj_on f X" and g: "inj_on g Y" by (meson assms small_def) define h where "h \ \z. if z \ X then Inl (f z) else Inr (g z)" show ?thesis unfolding small_def proof (intro exI conjI) show "inj_on h (X \ Y)" using f g by (auto simp add: inj_on_def h_def) show "h ` (X \ Y) \ range elts" by (metis X Y image_Un replacement small_iff_range small_sup_iff) qed qed lemma small_UN [simp,intro]: assumes X: "small X" and B: "\x. x \ X \ small (B x)" shows "small (\x\X. B x)" proof - obtain f :: "'a\V" where f: "inj_on f X" by (meson assms small_def) have "\g. inj_on g (B x) \ g ` (B x) \ range elts" if "x \ X" for x using B small_def that by auto then obtain g::"'a \ 'b \ V" where g: "\x. x \ X \ inj_on (g x) (B x)" by metis define \ where "\ \ \y. @x. x \ X \ y \ B x" have \: "\ y \ X \ y \ B (\ y)" if "y \ (\x\X. B x)" for y unfolding \_def by (metis (mono_tags, lifting) UN_E someI that) define h where "h \ \y. \f (\ y), g (\ y) y\" show ?thesis unfolding small_def proof (intro exI conjI) show "inj_on h (\ (B ` X))" using f g \ unfolding h_def inj_on_def by (metis vpair_inject) have "small (h ` \ (B ` X))" by (simp add: B X image_UN) then show "h ` \ (B ` X) \ range elts" using small_iff_range by blast qed qed lemma small_Union [simp,intro]: assumes "\ \ Collect small" "small \" shows "small (\ \)" using small_UN [of \ "\x. x"] assms by (simp add: subset_iff) subsection\Generalised function space and lambda\ definition VLambda :: "V \ (V \ V) \ V" where "VLambda A b \ set ((\x. \x,b x\) ` elts A)" definition app :: "[V,V] \ V" where "app f x \ THE y. \x,y\ \ elts f" lemma beta [simp]: assumes "x \ elts A" shows "app (VLambda A b) x = b x" using assms by (auto simp: VLambda_def app_def) definition VPi :: "V \ (V \ V) \ V" where "VPi A B \ set {f \ elts (VPow(VSigma A B)). elts A \ Domain (pairs f) \ single_valued (pairs f)}" lemma VPi_I: assumes "\x. x \ elts A \ b x \ elts (B x)" shows "VLambda A b \ elts (VPi A B)" proof (clarsimp simp: VPi_def, intro conjI impI) show "VLambda A b \ VSigma A B" by (auto simp: assms VLambda_def split: if_split_asm) show "elts A \ Domain (pairs (VLambda A b))" by (force simp: VLambda_def pairs_iff_elts) show "single_valued (pairs (VLambda A b))" by (auto simp: VLambda_def single_valued_def pairs_iff_elts) show "small {f. f \ VSigma A B \ elts A \ Domain (pairs f) \ single_valued (pairs f)}" by (metis (mono_tags, lifting) down VPow_iff mem_Collect_eq subsetI) qed lemma apply_pair: assumes f: "f \ elts (VPi A B)" and x: "x \ elts A" shows "\x, app f x\ \ elts f" proof - have "x \ Domain (pairs f)" by (metis (no_types, lifting) VPi_def assms elts_of_set empty_iff mem_Collect_eq subsetD) then obtain y where y: "\x,y\ \ elts f" using pairs_iff_elts by auto show ?thesis unfolding app_def proof (rule theI) show "\x, y\ \ elts f" by (rule y) show "z = y" if "\x, z\ \ elts f" for z using f unfolding VPi_def by (metis (mono_tags, lifting) that elts_of_set empty_iff mem_Collect_eq pairs_iff_elts single_valued_def y) qed qed lemma VPi_D: assumes f: "f \ elts (VPi A B)" and x: "x \ elts A" shows "app f x \ elts (B x)" proof - have "f \ VSigma A B" by (metis (no_types, lifting) VPi_def elts_of_set empty_iff f VPow_iff mem_Collect_eq) then show ?thesis using apply_pair [OF assms] by blast qed lemma VPi_memberD: assumes f: "f \ elts (VPi A B)" and p: "p \ elts f" obtains x where "x \ elts A" "p = \x, app f x\" proof - have "f \ VSigma A B" by (metis (no_types, lifting) VPi_def elts_of_set empty_iff f VPow_iff mem_Collect_eq) then obtain x y where "p = \x,y\" "x \ elts A" using p by blast then have "y = app f x" by (metis (no_types, lifting) VPi_def apply_pair elts_of_set equals0D f mem_Collect_eq p pairs_iff_elts single_valuedD) then show thesis using \p = \x, y\\ \x \ elts A\ that by blast qed lemma fun_ext: assumes "f \ elts (VPi A B)" "g \ elts (VPi A B)" "\x. x \ elts A \ app f x = app g x" shows "f = g" by (metis VPi_memberD V_equalityI apply_pair assms) lemma eta[simp]: assumes "f \ elts (VPi A B)" shows "VLambda A ((app)f) = f" proof (rule fun_ext [OF _ assms]) show "VLambda A (app f) \ elts (VPi A B)" using VPi_D VPi_I assms by auto qed auto lemma fst_pairs_VLambda: "fst ` pairs (VLambda A f) = elts A" by (force simp: VLambda_def pairs_def) lemma snd_pairs_VLambda: "snd ` pairs (VLambda A f) = f ` elts A" by (force simp: VLambda_def pairs_def) lemma VLambda_eq_D1: "VLambda A f = VLambda B g \ A = B" by (metis ZFC_in_HOL.ext fst_pairs_VLambda) lemma VLambda_eq_D2: "\VLambda A f = VLambda A g; x \ elts A\ \ f x = g x" by (metis beta) subsection\Transitive closure of a set\ definition TC :: "V\V" where "TC \ transrec (\f x. x \ \ (f ` elts x))" lemma TC: "TC a = a \ \ (TC ` elts a)" by (metis (no_types, lifting) SUP_cong TC_def restrict_apply' transrec) lemma TC_0 [simp]: "TC 0 = 0" by (metis TC ZFC_in_HOL.Sup_empty elts_0 image_is_empty sup_V_0_left) lemma arg_subset_TC: "a \ TC a" by (metis (no_types) TC sup_ge1) lemma Transset_TC: "Transset(TC a)" proof (induction a rule: eps_induct) case (step x) have 1: "v \ elts (TC x)" if "v \ elts u" "u \ elts x" for u v using that unfolding TC [of x] using arg_subset_TC by fastforce have 2: "v \ elts (TC x)" if "v \ elts u" "\x\elts x. u \ elts (TC x)" for u v using that step unfolding TC [of x] Transset_def by auto show ?case unfolding Transset_def by (subst TC) (force intro: 1 2) qed lemma TC_least: "\Transset x; a\x\ \ TC a \ x" proof (induction a rule: eps_induct) case (step y) show ?case proof (cases "y=0") case True then show ?thesis by auto next case False have "\ (TC ` elts y) \ x" proof (rule cSup_least) show "TC ` elts y \ {}" using False by auto show "z \ x" if "z \ TC ` elts y" for z using that by (metis Transset_def image_iff step.IH step.prems vsubsetD) qed then show ?thesis by (simp add: step TC [of y]) qed qed definition less_TC (infix "\" 50) where "x \ y \ x \ elts (TC y)" definition le_TC (infix "\" 50) where "x \ y \ x \ y \ x=y" lemma less_TC_imp_not_le: "x \ a \ \ a \ x" proof (induction a arbitrary: x rule: eps_induct) case (step a) then show ?case unfolding TC[of a] less_TC_def using Transset_TC Transset_def by force qed lemma non_TC_less_0 [iff]: "\ (x \ 0)" using less_TC_imp_not_le by blast lemma less_TC_iff: "x \ y \ (\z \ elts y. x \ z)" by (auto simp: less_TC_def le_TC_def TC [of y]) lemma nonzero_less_TC: "x \ 0 \ 0 \ x" by (metis eps_induct le_TC_def less_TC_iff trad_foundation) lemma less_irrefl_TC [simp]: "\ x \ x" using less_TC_imp_not_le by blast lemma less_asym_TC: "\x \ y; y \ x\ \ False" by (metis TC_least Transset_TC Transset_def antisym_conv less_TC_def less_TC_imp_not_le order_refl) lemma le_antisym_TC: "\x \ y; y \ x\ \ x = y" using less_asym_TC by blast lemma less_imp_le_TC [iff]: "x \ y \ x \ y" by (simp add: le_TC_def) lemma le_TC_refl [iff]: "x \ x" by (simp add: le_TC_def) lemma less_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" by (meson TC_least Transset_TC Transset_def less_TC_def less_eq_V_def subsetD) lemma less_le_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" using le_TC_def less_TC_trans by blast lemma le_less_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" using le_TC_def less_TC_trans by blast lemma le_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" using le_TC_def le_less_TC_trans by blast lemma TC_sup_distrib: "TC (x \ y) = TC x \ TC y" by (simp add: Sup_Un_distrib TC [of "x \ y"] TC [of x] TC [of y] image_Un sup.assoc sup_left_commute) lemma TC_Sup_distrib: assumes "small X" shows "TC (\X) = \(TC ` X)" proof - have "\ X \ \ (\x\X. TC ` elts x) \ \ (TC ` X)" using assms apply (auto simp: Sup_le_iff) using arg_subset_TC apply blast by (metis TC_least Transset_TC Transset_def arg_subset_TC vsubsetD) moreover have "\ (TC ` X) \ \ X \ \ (\x\X. TC ` elts x)" proof (clarsimp simp add: Sup_le_iff assms) show "\x\X. y \ elts x" if "x \ X" "y \ elts (TC x)" "\x\X. \u\elts x. y \ elts (TC u)" for x y using that by (auto simp: TC [of x]) qed ultimately show ?thesis using Sup_Un_distrib TC [of "\X"] image_Union assms by (simp add: image_Union inf_sup_aci(5) sup.absorb_iff2) qed lemma TC': "TC x = x \ TC (\ (elts x))" by (simp add: TC [of x] TC_Sup_distrib) lemma TC_eq_0_iff [simp]: "TC x = 0 \ x=0" using arg_subset_TC by fastforce text\A distinctive induction principle\ lemma TC_induct_down_lemma: assumes ab: "a \ b" and base: "b \ d" and step: "\y z. \y \ b; y \ elts d; z \ elts y\ \ z \ elts d" shows "a \ elts d" proof - have "Transset (TC b \ d)" using Transset_TC unfolding Transset_def by (metis inf.bounded_iff less_TC_def less_eq_V_def local.step subsetI vsubsetD) moreover have "b \ TC b \ d" by (simp add: arg_subset_TC base) ultimately show ?thesis using TC_least [THEN vsubsetD] ab unfolding less_TC_def by (meson TC_least le_inf_iff vsubsetD) qed lemma TC_induct_down [consumes 1, case_names base step small]: assumes "a \ b" and "\y. y \ elts b \ P y" and "\y z. \y \ b; P y; z \ elts y\ \ P z" and "small (Collect P)" shows "P a" using TC_induct_down_lemma [of a b "set (Collect P)"] assms by (metis elts_of_set mem_Collect_eq vsubsetI) subsection\Rank of a set\ definition rank :: "V\V" where "rank a \ transrec (\f x. set (\y\elts x. elts (succ(f y)))) a" lemma rank: "rank a = set(\y \ elts a. elts (succ(rank y)))" by (subst rank_def [THEN def_transrec], simp) lemma rank_Sup: "rank a = \((\y. succ(rank y)) ` elts a)" by (metis elts_Sup image_image rank replacement set_of_elts small_elts) lemma Ord_rank [simp]: "Ord(rank a)" proof (induction a rule: eps_induct) case (step x) then show ?case unfolding rank_Sup [of x] by (metis (mono_tags, lifting) Ord_Sup Ord_succ imageE) qed lemma rank_of_Ord: "Ord i \ rank i = i" apply (induction rule: Ord_induct) by (metis (no_types, lifting) Ord_equality SUP_cong rank_Sup) lemma Ord_iff_rank: "Ord x \ rank x = x" using Ord_rank [of x] rank_of_Ord by fastforce lemma rank_lt: "a \ elts b \ rank a < rank b" apply (subst rank [of b]) by (metis (no_types, lifting) Ord_mem_iff_lt Ord_rank small_UN UN_iff elts_of_set elts_succ insert_iff rank small_elts) lemma rank_0 [simp]: "rank 0 = 0" unfolding rank_def using transrec by fastforce lemma rank_succ [simp]: "rank(succ x) = succ(rank x)" proof (rule order_antisym) show "rank (succ x) \ succ (rank x)" apply (subst rank [of "succ x"]) apply (metis (no_types, lifting) Sup_insert elts_of_set elts_succ equals0D image_insert rank small_sup_iff subset_insertI sup.orderE vsubsetI) done show "succ (rank x) \ rank (succ x)" by (metis (mono_tags, lifting) ZFC_in_HOL.Sup_upper elts_succ image_insert insertI1 rank_Sup replacement small_elts) qed lemma rank_mono: "a \ b \ rank a \ rank b" apply (rule vsubsetI) using rank [of a] rank [of b] small_UN by auto lemma VsetI: "rank b \ i \ b \ elts (Vset i)" proof (induction i arbitrary: b rule: eps_induct) case (step x) then consider "rank b \ elts x" | "(\y\elts x. rank b \ elts (TC y))" using le_TC_def less_TC_def less_TC_iff by fastforce then have "\y\elts x. b \ Vset y" proof cases case 1 then have "b \ Vset (rank b)" unfolding less_eq_V_def subset_iff by (meson Ord_mem_iff_lt Ord_rank le_TC_refl less_TC_iff rank_lt step.IH) then show ?thesis using "1" by blast next case 2 then show ?thesis using step.IH unfolding less_eq_V_def subset_iff less_TC_def by (meson Ord_mem_iff_lt Ord_rank Transset_TC Transset_def rank_lt vsubsetD) qed then show ?case by (simp add: Vset [of x]) qed lemma Ord_VsetI: "\Ord i; rank b < i\ \ b \ elts (Vset i)" by (meson Ord_mem_iff_lt Ord_rank VsetI arg_subset_TC less_TC_def vsubsetD) lemma arg_le_Vset_rank: "a \ Vset(rank a)" by (simp add: Ord_VsetI rank_lt vsubsetI) lemma two_in_Vset: obtains \ where "x \ elts (Vset \)" "y \ elts (Vset \)" by (metis Ord_rank Ord_VsetI elts_of_set insert_iff rank_lt small_elts small_insert_iff) lemma rank_eq_0_iff [simp]: "rank x = 0 \ x=0" using arg_le_Vset_rank by fastforce lemma small_ranks_imp_small: assumes "small (rank ` A)" shows "small A" proof - define i where "i \ set (\(elts ` (rank ` A)))" have "Ord i" unfolding i_def using Ord_Union Ord_rank assms imageE by blast have *: "Vset (rank x) \ (Vset i)" if "x \ A" for x unfolding i_def by (metis Ord_rank Sup_V_def ZFC_in_HOL.Sup_upper Vfrom_mono assms imageI le_less that) have "A \ elts (VPow (Vset i))" by (meson "*" VPow_iff arg_le_Vset_rank order.trans subsetI) then show ?thesis using down by blast qed lemma rank_Union: "rank(\ A) = \ (rank ` A)" proof (rule order_antisym) - have "elts (SUP y\elts (\ A). succ (rank y)) \ elts (\ (rank ` A))" + have "elts (\y\elts (\ A). succ (rank y)) \ elts (\ (rank ` A))" apply auto(*SLOW*) using Ord_mem_iff_lt Ord_rank rank_lt apply blast by (meson less_le_not_le rank_lt vsubsetD) then show "rank (\ A) \ \ (rank ` A)" by (metis less_eq_V_def rank_Sup) show "\ (rank ` A) \ rank (\ A)" proof (cases "small A") case True then show ?thesis by (metis (mono_tags, lifting) ZFC_in_HOL.Sup_least ZFC_in_HOL.Sup_upper image_iff rank_mono) next case False then have "\ small (rank ` A)" using small_ranks_imp_small by blast then show ?thesis by blast qed qed lemma small_bounded_rank: "small {x. rank x \ elts a}" proof - have "{x. rank x \ elts a} \ {x. rank x \ a}" using less_TC_iff by auto also have "\ \ elts (Vset a)" using VsetI by blast finally show ?thesis using down by simp qed lemma small_bounded_rank_le: "small {x. rank x \ a}" using small_bounded_rank [of "VPow a"] VPow_iff [of _ a] by simp lemma TC_rank_lt: "a \ b \ rank a < rank b" proof (induction rule: TC_induct_down) case (base y) then show ?case by (simp add: rank_lt) next case (step y z) then show ?case using less_trans rank_lt by blast next case small show ?case apply (rule smaller_than_small [OF small_bounded_rank_le [of "rank b"]]) by (simp add: Collect_mono less_V_def) qed lemma TC_rank_mem: "x \ y \ rank x \ elts (rank y)" by (simp add: Ord_mem_iff_lt TC_rank_lt) lemma wf_TC_less: "wf {(x,y). x \ y}" proof (rule wf_subset [OF wf_inv_image [OF foundation, of rank]]) show "{(x, y). x \ y} \ inv_image {(x, y). x \ elts y} rank" by (auto simp: TC_rank_mem inv_image_def) qed lemma less_TC_minimal: assumes "P a" obtains x where "P x" "x \ a" "\y. y \ x \ \ P y" using wfE_min' [OF wf_TC_less, of "{x. P x \ x \ a}"] by simp (metis le_TC_def less_le_TC_trans assms) lemma Vfrom_rank_eq: "Vfrom A (rank(x)) = Vfrom A x" proof (rule order_antisym) show "Vfrom A (rank x) \ Vfrom A x" proof (induction x rule: eps_induct) case (step x) - have "(SUP j\elts (rank x). VPow (Vfrom A j)) \ (SUP j\elts x. VPow (Vfrom A j))" + have "(\j\elts (rank x). VPow (Vfrom A j)) \ (\j\elts x. VPow (Vfrom A j))" apply (rule Sup_least, clarify) apply (simp add: rank [of x]) using step.IH by (metis Ord_rank OrdmemD Vfrom_mono2 dual_order.trans inf_sup_aci(5) less_V_def sup.orderE) then show ?case by (simp add: Vfrom [of _ x] Vfrom [of _ "rank(x)"] sup.coboundedI2) qed show "Vfrom A x \ Vfrom A (rank x)" proof (induction x rule: eps_induct) case (step x) - have "(SUP j\elts x. VPow (Vfrom A j)) \ (SUP j\elts (rank x). VPow (Vfrom A j))" + have "(\j\elts x. VPow (Vfrom A j)) \ (\j\elts (rank x). VPow (Vfrom A j))" using step.IH TC_rank_mem less_TC_iff by force then show ?case by (simp add: Vfrom [of _ x] Vfrom [of _ "rank(x)"] sup.coboundedI2) qed qed lemma Vfrom_succ: "Vfrom A (succ(i)) = A \ VPow(Vfrom A i)" by (metis Ord_rank Vfrom_rank_eq Vfrom_succ_Ord rank_succ) lemma Vset_succ_TC: assumes "x \ elts (Vset (ZFC_in_HOL.succ k))" "u \ x" shows "u \ elts (Vset k)" using assms apply (simp add: Vfrom_succ) using TC_least Transset_Vfrom less_TC_def by auto subsection\Cardinal Numbers\ text\We extend the membership relation to a wellordering\ definition VWO :: "(V \ V) set" where "VWO \ @r. {(x,y). x \ elts y} \ r \ Well_order r \ Field r = UNIV" lemma VWO: "{(x,y). x \ elts y} \ VWO \ Well_order VWO \ Field VWO = UNIV" unfolding VWO_def by (metis (mono_tags, lifting) VWO_def foundation someI_ex total_well_order_extension) lemma wf_VWO: "wf(VWO - Id)" using VWO well_order_on_def by blast lemma wf_Ord_less: "wf {(x, y). Ord y \ x < y}" by (metis (no_types, lifting) Ord_mem_iff_lt eps_induct wfPUNIVI wfP_def) lemma refl_VWO: "refl VWO" using VWO order_on_defs by fastforce lemma trans_VWO: "trans VWO" using VWO by (simp add: VWO wo_rel.TRANS wo_rel_def) lemma antisym_VWO: "antisym VWO" using VWO by (simp add: VWO wo_rel.ANTISYM wo_rel_def) lemma total_VWO: "total VWO" using VWO by (metis wo_rel.TOTAL wo_rel.intro) lemma total_VWOId: "total (VWO-Id)" by (simp add: total_VWO) lemma Linear_order_VWO: "Linear_order VWO" using VWO well_order_on_def by blast lemma wo_rel_VWO: "wo_rel VWO" using VWO wo_rel_def by blast subsubsection \Transitive Closure and VWO\ lemma mem_imp_VWO: "x \ elts y \ (x,y) \ VWO" using VWO by blast lemma less_TC_imp_VWO: "x \ y \ (x,y) \ VWO" unfolding less_TC_def proof (induction y arbitrary: x rule: eps_induct) case (step y' u) then consider "u \ elts y'" | v where "v \ elts y'" "u \ elts (TC v)" by (auto simp: TC [of y']) then show ?case proof cases case 2 then show ?thesis by (meson mem_imp_VWO step.IH transD trans_VWO) qed (use mem_imp_VWO in blast) qed lemma le_TC_imp_VWO: "x \ y \ (x,y) \ VWO" apply (auto simp: le_TC_def less_TC_imp_VWO) by (metis Diff_iff Linear_order_VWO Linear_order_in_diff_Id UNIV_I VWO) lemma le_TC_0_iff [simp]: "x \ 0 \ x = 0" by (simp add: le_TC_def) lemma less_TC_succ: " x \ succ \ \ x \ \ \ x = \" by (metis elts_succ insert_iff le_TC_def less_TC_iff) lemma le_TC_succ: "x \ succ \ \ x \ \ \ x = succ \" by (simp add: le_TC_def less_TC_succ) lemma Transset_TC_eq [simp]: "Transset x \ TC x = x" by (simp add: TC_least arg_subset_TC eq_iff) lemma Ord_TC_less_iff: "\Ord \; Ord \\ \ \ \ \ \ \ < \" by (metis Ord_def Ord_mem_iff_lt Transset_TC_eq less_TC_def) lemma Ord_mem_iff_less_TC: "Ord l \ k \ elts l \ k \ l" by (simp add: Ord_def less_TC_def) lemma le_TC_Ord: "\\ \ \; Ord \\ \ Ord \" by (metis Ord_def Ord_in_Ord Transset_TC_eq le_TC_def less_TC_def) lemma Ord_less_TC_mem: assumes "Ord \" "\ \ \" shows "\ \ elts \" using Ord_def assms less_TC_def by auto lemma VWO_TC_le: "\Ord \; Ord \; (\, \) \ VWO\ \ \ \ \" proof (induct \ arbitrary: \ rule: Ord_induct) case (step \) then show ?case by (metis Diff_iff Linear_order_VWO Linear_order_in_diff_Id Ord_TC_less_iff Ord_linear2 UNIV_I VWO le_TC_def le_less less_TC_imp_VWO pair_in_Id_conv) qed lemma VWO_iff_Ord_le [simp]: "\Ord \; Ord \\ \ (\, \) \ VWO \ \ \ \" by (metis VWO_TC_le Ord_TC_less_iff le_TC_def le_TC_imp_VWO le_less) lemma zero_TC_le [iff]: "0 \ y" using le_TC_def nonzero_less_TC by auto lemma succ_le_TC_iff: "Ord j \ succ i \ j \ i \ j" by (metis Ord_in_Ord Ord_linear Ord_mem_iff_less_TC Ord_succ le_TC_def less_TC_succ less_asym_TC) lemma VWO_0_iff [simp]: "(x,0) \ VWO \ x=0" proof show "x = 0" if "(x, 0) \ VWO" using zero_TC_le [of x] le_TC_imp_VWO that by (metis DiffI Linear_order_VWO Linear_order_in_diff_Id UNIV_I VWO pair_in_Id_conv) qed auto lemma VWO_antisym: assumes "(x,y) \ VWO" "(y,x) \ VWO" shows "x=y" by (metis Diff_iff IdD Linear_order_VWO Linear_order_in_diff_Id UNIV_I VWO assms) subsubsection \Relation VWF\ definition VWF where "VWF \ VWO - Id" lemma wf_VWF [iff]: "wf VWF" by (simp add: VWF_def wf_VWO) lemma trans_VWF [iff]: "trans VWF" by (simp add: VWF_def antisym_VWO trans_VWO trans_diff_Id) lemma asym_VWF [iff]: "asym VWF" by (metis VWF_def asym.intros irrefl_diff_Id wf_VWF wf_not_sym) lemma total_VWF [iff]: "total VWF" using VWF_def total_VWOId by auto lemma total_on_VWF [iff]: "total_on A VWF" by (meson UNIV_I total_VWF total_on_def) lemma VWF_asym: assumes "(x,y) \ VWF" "(y,x) \ VWF" shows False using VWF_def assms wf_VWO wf_not_sym by fastforce lemma VWF_non_refl [iff]: "(x,x) \ VWF" by simp lemma VWF_iff_Ord_less [simp]: "\Ord \; Ord \\ \ (\,\) \ VWF \ \ < \" by (simp add: VWF_def less_V_def) lemma mem_imp_VWF: "x \ elts y \ (x,y) \ VWF" using VWF_def mem_imp_VWO by fastforce subsection\Order types\ definition ordermap :: "'a set \ ('a \ 'a) set \ 'a \ V" where "ordermap A r \ wfrec r (\f x. set (f ` {y \ A. (y,x) \ r}))" definition ordertype :: "'a set \ ('a \ 'a) set \ V" where "ordertype A r \ set (ordermap A r ` A)" lemma ordermap_type: "small A \ ordermap A r \ A \ elts (ordertype A r)" by (simp add: ordertype_def) lemma ordermap_in_ordertype [intro]: "\a \ A; small A\ \ ordermap A r a \ elts (ordertype A r)" by (simp add: ordertype_def) lemma ordermap: "wf r \ ordermap A r a = set (ordermap A r ` {y \ A. (y,a) \ r})" unfolding ordermap_def by (auto simp: wfrec_fixpoint adm_wf_def) lemma wf_Ord_ordermap [iff]: assumes "wf r" "trans r" shows "Ord (ordermap A r x)" using \wf r\ proof (induction x rule: wf_induct_rule) case (less u) have "Transset (set (ordermap A r ` {y \ A. (y, u) \ r}))" proof (clarsimp simp add: Transset_def) show "x \ ordermap A r ` {y \ A. (y, u) \ r}" if "small (ordermap A r ` {y \ A. (y, u) \ r})" and x: "x \ elts (ordermap A r y)" and "y \ A" "(y, u) \ r" for x y proof - have "ordermap A r y = ZFC_in_HOL.set (ordermap A r ` {a \ A. (a, y) \ r})" using ordermap assms(1) by force then have "x \ ordermap A r ` {z \ A. (z, y) \ r}" by (metis (no_types, lifting) elts_of_set empty_iff x) then have "\v. v \ A \ (v, u) \ r \ x = ordermap A r v" using that transD [OF \trans r\] by blast then show ?thesis by blast qed qed moreover have "Ord x" if "x \ elts (set (ordermap A r ` {y \ A. (y, u) \ r}))" for x using that less by (auto simp: split: if_split_asm) ultimately show ?case by (metis (full_types) Ord_def ordermap assms(1)) qed lemma wf_Ord_ordertype: assumes "wf r" "trans r" shows "Ord(ordertype A r)" proof - have "y \ set (ordermap A r ` A)" if "y = ordermap A r x" "x \ A" "small (ordermap A r ` A)" for x y using that by (auto simp: less_eq_V_def ordermap [OF \wf r\, of A x]) moreover have "z \ y" if "y \ ordermap A r ` A" "z \ elts y" for y z by (metis wf_Ord_ordermap OrdmemD assms imageE order.strict_implies_order that) ultimately show ?thesis unfolding ordertype_def Ord_def Transset_def by simp qed lemma Ord_ordertype [simp]: "Ord(ordertype A VWF)" using wf_Ord_ordertype by blast lemma Ord_ordermap [simp]: "Ord (ordermap A VWF x)" by blast lemma ordertype_singleton [simp]: assumes "wf r" shows "ordertype {x} r = 1" proof - have \: "{y. y = x \ (y, x) \ r} = {}" using assms by auto show ?thesis by (auto simp add: ordertype_def assms \ ordermap [where a=x]) qed subsubsection\@{term ordermap} preserves the orderings in both directions\ lemma ordermap_mono: assumes wx: "(w, x) \ r" and "wf r" "w \ A" "small A" shows "ordermap A r w \ elts (ordermap A r x)" proof - have "small {a \ A. (a, x) \ r} \ w \ A \ (w, x) \ r" by (simp add: assms) then show ?thesis using assms ordermap [of r A] by (metis (no_types, lifting) elts_of_set image_eqI mem_Collect_eq replacement) qed lemma converse_ordermap_mono: assumes "ordermap A r y \ elts (ordermap A r x)" "wf r" "total_on A r" "x \ A" "y \ A" "small A" shows "(y, x) \ r" proof (cases "x = y") case True then show ?thesis using assms(1) mem_not_refl by blast next case False then consider "(x,y) \ r" | "(y,x) \ r" using \total_on A r\ assms by (meson UNIV_I total_on_def) then show ?thesis by (meson ordermap_mono assms mem_not_sym) qed lemma converse_ordermap_mono_iff: assumes "wf r" "total_on A r" "x \ A" "y \ A" "small A" shows "ordermap A r y \ elts (ordermap A r x) \ (y, x) \ r" by (metis assms converse_ordermap_mono ordermap_mono) lemma ordermap_surj: "elts (ordertype A r) \ ordermap A r ` A" unfolding ordertype_def by simp lemma ordermap_bij: assumes "wf r" "total_on A r" "small A" shows "bij_betw (ordermap A r) A (elts (ordertype A r))" unfolding bij_betw_def proof (intro conjI) show "inj_on (ordermap A r) A" unfolding inj_on_def by (metis assms mem_not_refl ordermap_mono total_on_def) show "ordermap A r ` A = elts (ordertype A r)" by (metis ordertype_def \small A\ elts_of_set replacement) qed lemma ordermap_eq_iff [simp]: "\x \ A; y \ A; wf r; total_on A r; small A\ \ ordermap A r x = ordermap A r y \ x = y" by (metis bij_betw_iff_bijections ordermap_bij) lemma inv_into_ordermap: "\ \ elts (ordertype A r) \ inv_into A (ordermap A r) \ \ A" by (meson in_mono inv_into_into ordermap_surj) lemma ordertype_nat_imp_finite: assumes "ordertype A r = ord_of_nat m" "small A" "wf r" "total_on A r" shows "finite A" proof - have "A \ elts m" using eqpoll_def assms ordermap_bij by fastforce then show ?thesis using eqpoll_finite_iff finite_Ord_omega by blast qed lemma wf_ordertype_eqpoll: assumes "wf r" "total_on A r" "small A" shows "elts (ordertype A r) \ A" using assms eqpoll_def eqpoll_sym ordermap_bij by blast lemma ordertype_eqpoll: assumes "small A" shows "elts (ordertype A VWF) \ A" using assms wf_ordertype_eqpoll total_VWF wf_VWF by (simp add: wf_ordertype_eqpoll total_on_def) subsection \More advanced @{term ordertype} and @{term ordermap} results\ lemma ordermap_VWF_0 [simp]: "ordermap A VWF 0 = 0" by (simp add: ordermap wf_VWO VWF_def) lemma ordertype_empty [simp]: "ordertype {} r = 0" by (simp add: ordertype_def) lemma ordertype_eq_0_iff [simp]: "\small X; wf r\ \ ordertype X r = 0 \ X = {}" by (metis ordertype_def elts_of_set replacement image_is_empty zero_V_def) lemma ordermap_mono_less: assumes "(w, x) \ r" and "wf r" "trans r" and "w \ A" "x \ A" and "small A" shows "ordermap A r w < ordermap A r x" by (simp add: OrdmemD assms ordermap_mono) lemma ordermap_mono_le: assumes "(w, x) \ r \ w=x" and "wf r" "trans r" and "w \ A" "x \ A" and "small A" shows "ordermap A r w \ ordermap A r x" by (metis assms dual_order.strict_implies_order eq_refl ordermap_mono_less) lemma converse_ordermap_le_mono: assumes "ordermap A r y \ ordermap A r x" "wf r" "total r" "x \ A" "small A" shows "(y, x) \ r \ y=x" by (meson UNIV_I assms mem_not_refl ordermap_mono total_on_def vsubsetD) lemma ordertype_mono: assumes "X \ Y" and r: "wf r" "trans r" and "small Y" shows "ordertype X r \ ordertype Y r" proof - have "small X" using assms smaller_than_small by fastforce have *: "ordermap X r x \ ordermap Y r x" for x using \wf r\ proof (induction x rule: wf_induct_rule) case (less x) have "ordermap X r z < ordermap Y r x" if "z \ X" and zx: "(z,x) \ r" for z using less [OF zx] assms by (meson Ord_linear2 OrdmemD wf_Ord_ordermap ordermap_mono in_mono leD that(1) vsubsetD zx) then show ?case by (auto simp add: ordermap [of _ X x] \small X\ Ord_mem_iff_lt set_image_le_iff less_eq_V_def r) qed show ?thesis proof - have "ordermap Y r ` Y = elts (ordertype Y r)" by (metis ordertype_def \small Y\ elts_of_set replacement) then have "ordertype Y r \ ordermap X r ` X" using "*" \X \ Y\ by fastforce then show ?thesis by (metis Ord_linear2 Ord_mem_iff_lt ordertype_def wf_Ord_ordertype \small X\ elts_of_set replacement r) qed qed corollary ordertype_VWF_mono: assumes "X \ Y" "small Y" shows "ordertype X VWF \ ordertype Y VWF" using assms by (simp add: ordertype_mono) lemma ordertype_UNION_ge: assumes "A \ \" "wf r" "trans r" "\ \ Collect small" "small \" shows "ordertype A r \ ordertype (\\) r" by (rule ordertype_mono) (use assms in auto) lemma inv_ordermap_mono_less: assumes "(inv_into M (ordermap M r) \, inv_into M (ordermap M r) \) \ r" and "small M" and \: "\ \ elts (ordertype M r)" and \: "\ \ elts (ordertype M r)" and "wf r" "trans r" shows "\ < \" proof - have "\ = ordermap M r (inv_into M (ordermap M r) \)" by (metis \ f_inv_into_f ordermap_surj subset_eq) also have "\ < ordermap M r (inv_into M (ordermap M r) \)" by (meson \ \ assms in_mono inv_into_into ordermap_mono_less ordermap_surj) also have "\ = \" by (meson \ f_inv_into_f in_mono ordermap_surj) finally show ?thesis . qed lemma inv_ordermap_mono_eq: assumes "inv_into M (ordermap M r) \ = inv_into M (ordermap M r) \" and "\ \ elts (ordertype M r)" "\ \ elts (ordertype M r)" shows "\ = \" by (metis assms f_inv_into_f ordermap_surj subsetD) lemma inv_ordermap_VWF_mono_le: assumes "inv_into M (ordermap M VWF) \ \ inv_into M (ordermap M VWF) \" and "M \ ON" "small M" and \: "\ \ elts (ordertype M VWF)" and \: "\ \ elts (ordertype M VWF)" shows "\ \ \" proof - have "\ = ordermap M VWF (inv_into M (ordermap M VWF) \)" by (metis \ f_inv_into_f ordermap_surj subset_eq) also have "\ \ ordermap M VWF (inv_into M (ordermap M VWF) \)" by (metis ON_imp_Ord VWF_iff_Ord_less assms dual_order.strict_implies_order elts_of_set eq_refl inv_into_into order.not_eq_order_implies_strict ordermap_mono_less ordertype_def replacement trans_VWF wf_VWF) also have "\ = \" by (meson \ f_inv_into_f in_mono ordermap_surj) finally show ?thesis . qed lemma inv_ordermap_VWF_mono_iff: assumes "M \ ON" "small M" and "\ \ elts (ordertype M VWF)" and "\ \ elts (ordertype M VWF)" shows "inv_into M (ordermap M VWF) \ \ inv_into M (ordermap M VWF) \ \ \ \ \" by (metis ON_imp_Ord Ord_linear_le assms dual_order.eq_iff inv_into_ordermap inv_ordermap_VWF_mono_le) lemma inv_ordermap_VWF_strict_mono_iff: assumes "M \ ON" "small M" and "\ \ elts (ordertype M VWF)" and "\ \ elts (ordertype M VWF)" shows "inv_into M (ordermap M VWF) \ < inv_into M (ordermap M VWF) \ \ \ < \" by (simp add: assms inv_ordermap_VWF_mono_iff less_le_not_le) lemma strict_mono_on_ordertype: assumes "M \ ON" "small M" obtains f where "f \ elts (ordertype M VWF) \ M" "strict_mono_on f (elts (ordertype M VWF))" proof show "inv_into M (ordermap M VWF) \ elts (ordertype M VWF) \ M" by (meson Pi_I' in_mono inv_into_into ordermap_surj) show "strict_mono_on (inv_into M (ordermap M VWF)) (elts (ordertype M VWF))" proof (clarsimp simp: strict_mono_on_def) fix x y assume "x \ elts (ordertype M VWF)" "y \ elts (ordertype M VWF)" "x < y" then show "inv_into M (ordermap M VWF) x < inv_into M (ordermap M VWF) y" using assms by (meson ON_imp_Ord Ord_linear2 inv_into_into inv_ordermap_VWF_mono_le leD ordermap_surj subsetD) qed qed lemma ordermap_inc_eq: assumes "x \ A" "small A" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ s" and r: "wf r" "total_on A r" and "wf s" shows "ordermap (\ ` A) s (\ x) = ordermap A r x" using \wf r\ \x \ A\ proof (induction x rule: wf_induct_rule) case (less x) then have 1: "{y \ A. (y, x) \ r} = A \ {y. (y, x) \ r}" using r by auto have 2: "{y \ \ ` A. (y, \ x) \ s} = \ ` A \ {y. (y, \ x) \ s}" by auto have inv\: "\x y. \x\A; y\A; (\ x, \ y) \ s\ \ (x, y) \ r" by (metis \ \wf s\ \total_on A r\ total_on_def wf_not_sym) have eq: "f ` (\ ` A \ {y. (y, \ x) \ s}) = (f \ \) ` (A \ {y. (y, x) \ r})" for f :: "'b \ V" using less by (auto simp: image_subset_iff inv\ \) show ?case using less by (simp add: ordermap [OF \wf r\, of _ x] ordermap [OF \wf s\, of _ "\ x"] 1 2 eq) qed lemma ordertype_inc_eq: assumes "small A" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ s" and r: "wf r" "total_on A r" and "wf s" shows "ordertype (\ ` A) s = ordertype A r" proof - have "ordermap (\ ` A) s (\ x) = ordermap A r x" if "x \ A" for x using assms that by (auto simp: ordermap_inc_eq) then show ?thesis unfolding ordertype_def by (metis (no_types, lifting) image_cong image_image) qed lemma ordertype_inc_le: assumes "small A" "small B" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ s" and r: "wf r" "total_on A r" and "wf s" "trans s" and "\ ` A \ B" shows "ordertype A r \ ordertype B s" by (metis assms ordertype_inc_eq ordertype_mono) corollary ordertype_VWF_inc_eq: assumes "A \ ON" "\ ` A \ ON" "small A" and "\x y. \x\A; y\A; x \ \ x < \ y" shows "ordertype (\ ` A) VWF = ordertype A VWF" proof (rule ordertype_inc_eq) show "(\ x, \ y) \ VWF" if "x \ A" "y \ A" "(x, y) \ VWF" for x y using that ON_imp_Ord assms by auto show "total_on A VWF" by (meson UNIV_I total_VWF total_on_def) qed (use assms in auto) lemma ordertype_image_ordermap: assumes "small A" "X \ A" "wf r" "trans r" "total_on X r" shows "ordertype (ordermap A r ` X) VWF = ordertype X r" proof (rule ordertype_inc_eq) show "small X" by (meson assms smaller_than_small) show "(ordermap A r x, ordermap A r y) \ VWF" if "x \ X" "y \ X" "(x, y) \ r" for x y by (meson that wf_Ord_ordermap VWF_iff_Ord_less assms ordermap_mono_less subsetD) qed (use assms in auto) lemma ordertype_map_image: assumes "B \ A" "small A" shows "ordertype (ordermap A VWF ` A - ordermap A VWF ` B) VWF = ordertype (A - B) VWF" proof - have "ordermap A VWF ` A - ordermap A VWF ` B = ordermap A VWF ` (A - B)" using assms by auto then have "ordertype (ordermap A VWF ` A - ordermap A VWF ` B) VWF = ordertype (ordermap A VWF ` (A - B)) VWF" by simp also have "\ = ordertype (A - B) VWF" using \small A\ ordertype_image_ordermap by fastforce finally show ?thesis . qed proposition ordertype_le_ordertype: assumes r: "wf r" "total_on A r" and "small A" assumes s: "wf s" "total_on B s" "trans s" and "small B" shows "ordertype A r \ ordertype B s \ (\f \ A \ B. inj_on f A \ (\x \ A. \y \ A. ((x,y) \ r \ (f x, f y) \ s)))" (is "?lhs = ?rhs") proof assume L: ?lhs define f where "f \ inv_into B (ordermap B s) \ ordermap A r" show ?rhs proof (intro bexI conjI ballI impI) have AB: "elts (ordertype A r) \ ordermap B s ` B" by (metis L assms(7) ordertype_def replacement set_of_elts small_elts subset_iff_less_eq_V) have bijA: "bij_betw (ordermap A r) A (elts (ordertype A r))" using ordermap_bij \small A\ r by blast have "inv_into B (ordermap B s) (ordermap A r i) \ B" if "i \ A" for i by (meson L \small A\ inv_into_into ordermap_in_ordertype ordermap_surj subsetD that vsubsetD) then show "f \ A \ B" by (auto simp: Pi_iff f_def) show "inj_on f A" proof (clarsimp simp add: f_def inj_on_def) fix x y assume "x \ A" "y \ A" and "inv_into B (ordermap B s) (ordermap A r x) = inv_into B (ordermap B s) (ordermap A r y)" then have "ordermap A r x = ordermap A r y" by (meson AB \small A\ inv_into_injective ordermap_in_ordertype subsetD) then show "x = y" by (metis \x \ A\ \y \ A\ bijA bij_betw_inv_into_left) qed next fix x y assume "x \ A" "y \ A" and "(x, y) \ r" have \: "ordermap A r y \ ordermap B s ` B" by (meson L \y \ A\ \small A\ in_mono ordermap_in_ordertype ordermap_surj vsubsetD) moreover have \: "\x. inv_into B (ordermap B s) (ordermap A r x) = f x" by (simp add: f_def) then have *: "ordermap B s (f y) = ordermap A r y" using \ by (metis f_inv_into_f) moreover have "ordermap A r x \ ordermap B s ` B" by (meson L \x \ A\ \small A\ in_mono ordermap_in_ordertype ordermap_surj vsubsetD) moreover have "ordermap A r x < ordermap A r y" using * r s by (metis (no_types) wf_Ord_ordermap OrdmemD \(x, y) \ r\ \x \ A\ \small A\ ordermap_mono) ultimately show "(f x, f y) \ s" using \ s by (metis assms(7) f_inv_into_f inv_into_into less_asym ordermap_mono_less total_on_def) qed next assume R: ?rhs then obtain f where f: "f\A \ B" "inj_on f A" "\x\A. \y\A. (x, y) \ r \ (f x, f y) \ s" by blast show ?lhs by (rule ordertype_inc_le [where \=f]) (use f assms in auto) qed lemma iso_imp_ordertype_eq_ordertype: assumes iso: "iso r r' f" and "wf r" and "Total r" and sm: "small (Field r)" shows "ordertype (Field r) r = ordertype (Field r') r'" by (metis (no_types, lifting) iso_forward iso_wf assms iso_Field ordertype_inc_eq sm) lemma ordertype_infinite_ge_\: assumes "infinite A" "small A" shows "ordertype A VWF \ \" proof - have "inj_on (ordermap A VWF) A" by (meson ordermap_bij \small A\ bij_betw_def total_on_VWF wf_VWF) then have "infinite (ordermap A VWF ` A)" using \infinite A\ finite_image_iff by blast then show ?thesis using Ord_ordertype \small A\ infinite_Ord_omega by (auto simp: ordertype_def) qed lemma ordertype_eqI: assumes "wf r" "total_on A r" "small A" "wf s" "bij_betw f A B" "(\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r)" shows "ordertype A r = ordertype B s" by (metis assms bij_betw_imp_surj_on ordertype_inc_eq) lemma ordermap_eq_self: assumes "Ord \" and x: "x \ elts \" shows "ordermap (elts \) VWF x = x" using Ord_in_Ord [OF assms] x proof (induction x rule: Ord_induct) case (step x) have 1: "{y \ elts \. (y, x) \ VWF} = elts x" (is "?A = _") proof show "?A \ elts x" using \Ord \\ by clarify (meson Ord_in_Ord Ord_mem_iff_lt VWF_iff_Ord_less step.hyps) show "elts x \ ?A" using \Ord \\ by clarify (meson Ord_in_Ord Ord_trans OrdmemD VWF_iff_Ord_less step.prems) qed show ?case using step by (simp add: ordermap [OF wf_VWF, of _ x] 1 Ord_trans [of _ _ \] step.prems \Ord \\ cong: image_cong) qed lemma ordertype_eq_Ord [simp]: assumes "Ord \" shows "ordertype (elts \) VWF = \" using assms ordermap_eq_self [OF assms] by (simp add: ordertype_def) proposition ordertype_eq_iff: assumes \: "Ord \" and r: "wf r" and "small A" "total_on A r" "trans r" shows "ordertype A r = \ \ (\f. bij_betw f A (elts \) \ (\x \ A. \y \ A. f x < f y \ (x,y) \ r))" (is "?lhs = ?rhs") proof safe assume eq: "\ = ordertype A r" show "\f. bij_betw f A (elts (ordertype A r)) \ (\x\A. \y\A. f x < f y \ ((x, y) \ r))" proof (intro exI conjI ballI) show "bij_betw (ordermap A r) A (elts (ordertype A r))" by (simp add: assms ordermap_bij) then show "ordermap A r x < ordermap A r y \ (x, y) \ r" if "x \ A" "y \ A" for x y using that assms by (metis order.asym ordermap_mono_less total_on_def) qed next fix f assume f: "bij_betw f A (elts \)" "\x\A. \y\A. f x < f y \ (x, y) \ r" have "ordertype A r = ordertype (elts \) VWF" proof (rule ordertype_eqI) show "\x\A. \y\A. ((f x, f y) \ VWF) = ((x, y) \ r)" by (meson Ord_in_Ord VWF_iff_Ord_less \ bij_betwE f) qed (use assms f in auto) then show ?lhs by (simp add: \) qed corollary ordertype_VWF_eq_iff: assumes "Ord \" "small A" shows "ordertype A VWF = \ \ (\f. bij_betw f A (elts \) \ (\x \ A. \y \ A. f x < f y \ (x,y) \ VWF))" by (metis UNIV_I assms ordertype_eq_iff total_VWF total_on_def trans_VWF wf_VWF) lemma ordertype_le_Ord: assumes "Ord \" "X \ elts \" shows "ordertype X VWF \ \" by (metis assms ordertype_VWF_mono ordertype_eq_Ord small_elts) lemma ordertype_inc_le_Ord: assumes "small A" "Ord \" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ \ x < \ y" and "wf r" "total_on A r" and sub: "\ ` A \ elts \" shows "ordertype A r \ \" proof - have "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ VWF" by (meson Ord_in_Ord VWF_iff_Ord_less \ \Ord \\ sub image_subset_iff) with assms show ?thesis by (metis ordertype_inc_eq ordertype_le_Ord wf_VWF) qed lemma le_ordertype_obtains_subset: assumes \: "\ \ \" "ordertype H VWF = \" and "small H" "Ord \" obtains G where "G \ H" "ordertype G VWF = \" proof (intro exI conjI that) let ?f = "ordermap H VWF" show \: "inv_into H ?f ` elts \ \ H" unfolding image_subset_iff by (metis \ inv_into_into ordermap_surj subsetD vsubsetD) have "\f. bij_betw f (inv_into H ?f ` elts \) (elts \) \ (\x\inv_into H ?f ` elts \. \y\inv_into H ?f ` elts \. (f x < f y) = ((x, y) \ VWF))" proof (intro exI conjI ballI iffI) show "bij_betw ?f (inv_into H ?f ` elts \) (elts \)" using ordermap_bij [OF wf_VWF total_on_VWF \small H\] \ by (metis bij_betw_inv_into_RIGHT bij_betw_subset less_eq_V_def \) next fix x y assume x: "x \ inv_into H ?f ` elts \" and y: "y \ inv_into H ?f ` elts \" show "?f x < ?f y" if "(x,y) \ VWF" using that \ \small H\ in_mono ordermap_mono_less x y by fastforce show "(x,y) \ VWF" if "?f x < ?f y" using that \ \small H\ in_mono ordermap_mono_less [OF _ wf_VWF trans_VWF] x y by (metis UNIV_I less_imp_not_less total_VWF total_on_def) qed then show "ordertype (inv_into H ?f ` elts \) VWF = \" by (subst ordertype_eq_iff) (use assms in auto) qed lemma ordertype_infinite_\: assumes "A \ elts \" "infinite A" shows "ordertype A VWF = \" proof (rule antisym) show "ordertype A VWF \ \" by (simp add: assms ordertype_le_Ord) show "\ \ ordertype A VWF" using assms down ordertype_infinite_ge_\ by auto qed text \For infinite sets of natural numbers\ lemma ordertype_nat_\: assumes "infinite N" shows "ordertype N less_than = \" proof - have "small N" by (meson inj_on_def ord_of_nat_inject small_def small_iff_range small_image_nat_V) have "ordertype (ord_of_nat ` N) VWF = \" by (force simp: assms finite_image_iff inj_on_def intro: ordertype_infinite_\) moreover have "ordertype (ord_of_nat ` N) VWF = ordertype N less_than" by (auto intro: ordertype_inc_eq \small N\) ultimately show ?thesis by simp qed proposition ordertype_eq_ordertype: assumes r: "wf r" "total_on A r" "trans r" and "small A" assumes s: "wf s" "total_on B s" "trans s" and "small B" shows "ordertype A r = ordertype B s \ (\f. bij_betw f A B \ (\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r))" (is "?lhs = ?rhs") proof assume L: ?lhs define \ where "\ = ordertype A r" have A: "bij_betw (ordermap A r) A (ordermap A r ` A)" by (meson ordermap_bij assms(4) bij_betw_def r) have B: "bij_betw (ordermap B s) B (ordermap B s ` B)" by (meson ordermap_bij assms(8) bij_betw_def s) define f where "f \ inv_into B (ordermap B s) o ordermap A r" show ?rhs proof (intro exI conjI) have bijA: "bij_betw (ordermap A r) A (elts \)" unfolding \_def using ordermap_bij \small A\ r by blast moreover have bijB: "bij_betw (ordermap B s) B (elts \)" by (simp add: L \_def ordermap_bij \small B\ s) ultimately show bij: "bij_betw f A B" unfolding f_def using bij_betw_comp_iff bij_betw_inv_into by blast have invB: "\\. \ \ elts \ \ ordermap B s (inv_into B (ordermap B s) \) = \" by (meson bijB bij_betw_inv_into_right) have ordermap_A_\: "\a. a \ A \ ordermap A r a \ elts \" using bijA bij_betwE by auto have f_in_B: "\a. a \ A \ f a \ B" using bij bij_betwE by fastforce show "\x\A. \y\A. (f x, f y) \ s \ (x, y) \ r" proof (intro iffI ballI) fix x y assume "x \ A" "y \ A" and ins: "(f x, f y) \ s" then have "ordermap A r x < ordermap A r y" unfolding o_def by (metis (mono_tags, lifting) f_def \small B\ comp_apply f_in_B invB ordermap_A_\ ordermap_mono_less s(1) s(3)) then show "(x, y) \ r" by (metis \x \ A\ \y \ A\ \small A\ order.asym ordermap_mono_less r total_on_def) next fix x y assume "x \ A" "y \ A" and "(x, y) \ r" then have "ordermap A r x < ordermap A r y" by (simp add: \small A\ ordermap_mono_less r) then have "(f y, f x) \ s" by (metis (mono_tags, lifting) \x \ A\ \y \ A\ \small B\ comp_apply f_def f_in_B invB order.asym ordermap_A_\ ordermap_mono_less s(1) s(3)) moreover have "f y \ f x" by (metis \(x, y) \ r\ \x \ A\ \y \ A\ bij bij_betw_inv_into_left r(1) wf_not_sym) ultimately show "(f x, f y) \ s" by (meson \x \ A\ \y \ A\ f_in_B s(2) total_on_def) qed qed next assume ?rhs then show ?lhs using assms ordertype_eqI by blast qed corollary ordertype_eq_ordertype_iso: assumes r: "wf r" "total_on A r" "trans r" and "small A" and FA: "Field r = A" assumes s: "wf s" "total_on B s" "trans s" and "small B" and FB: "Field s = B" shows "ordertype A r = ordertype B s \ (\f. iso r s f)" (is "?lhs = ?rhs") proof assume L: ?lhs then obtain f where "bij_betw f A B" "\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r" using assms ordertype_eq_ordertype by blast then show ?rhs using FA FB iso_iff2 by blast next assume ?rhs then show ?lhs using FA FB \small A\ iso_imp_ordertype_eq_ordertype r by blast qed lemma Limit_ordertype_imp_Field_Restr: assumes Lim: "Limit (ordertype A r)" and r: "wf r" "total_on A r" and "small A" shows "Field (Restr r A) = A" proof - have "\y\A. (x,y) \ r" if "x \ A" for x proof - let ?oy = "succ (ordermap A r x)" have \
: "?oy \ elts (ordertype A r)" by (simp add: Lim \small A\ ordermap_in_ordertype succ_in_Limit_iff that) then have A: "inv_into A (ordermap A r) ?oy \ A" by (simp add: inv_into_ordermap) moreover have "(x, inv_into A (ordermap A r) ?oy) \ r" proof - have "ordermap A r x \ elts (ordermap A r (inv_into A (ordermap A r) ?oy))" by (metis "\
" elts_succ f_inv_into_f insert_iff ordermap_surj subsetD) then show ?thesis by (metis \small A\ A converse_ordermap_mono r that) qed ultimately show ?thesis .. qed then have "A \ Field (Restr r A)" by (auto simp: Field_def) then show ?thesis by (simp add: Field_Restr_subset subset_antisym) qed lemma ordertype_Field_Restr: assumes "wf r" "total_on A r" "trans r" "small A" "Field (Restr r A) = A" shows "ordertype (Field (Restr r A)) (Restr r A) = ordertype A r" using assms by (force simp: ordertype_eq_ordertype wf_Restr total_on_def trans_Restr) proposition ordertype_eq_ordertype_iso_Restr: assumes r: "wf r" "total_on A r" "trans r" and "small A" and FA: "Field (Restr r A) = A" assumes s: "wf s" "total_on B s" "trans s" and "small B" and FB: "Field (Restr s B) = B" shows "ordertype A r = ordertype B s \ (\f. iso (Restr r A) (Restr s B) f)" (is "?lhs = ?rhs") proof assume L: ?lhs then obtain f where "bij_betw f A B" "\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r" using assms ordertype_eq_ordertype by blast then show ?rhs using FA FB bij_betwE unfolding iso_iff2 by fastforce next assume ?rhs moreover have "ordertype (Field (Restr r A)) (Restr r A) = ordertype A r" using FA \small A\ ordertype_Field_Restr r by blast moreover have "ordertype (Field (Restr s B)) (Restr s B) = ordertype B s" using FB \small B\ ordertype_Field_Restr s by blast ultimately show ?lhs using iso_imp_ordertype_eq_ordertype FA FB \small A\ r by (fastforce intro: total_on_imp_Total_Restr trans_Restr wf_Int1) qed lemma ordermap_insert: assumes "Ord \" and y: "Ord y" "y \ \" and U: "U \ elts \" shows "ordermap (insert \ U) VWF y = ordermap U VWF y" using y proof (induction rule: Ord_induct) case (step y) then have 1: "{u \ U. (u, y) \ VWF} = elts y \ U" apply (simp add: set_eq_iff) by (meson Ord_in_Ord Ord_mem_iff_lt VWF_iff_Ord_less assms subsetD) have 2: "{u \ insert \ U. (u, y) \ VWF} = elts y \ U" apply (simp add: set_eq_iff) by (meson Ord_in_Ord Ord_mem_iff_lt VWF_iff_Ord_less assms leD step.hyps step.prems subsetD) show ?case using step apply (simp only: ordermap [OF wf_VWF, of _ y] 1 2) by (meson Int_lower1 Ord_is_Transset Sup.SUP_cong Transset_def assms(1) in_mono vsubsetD) qed lemma ordertype_insert: assumes "Ord \" and U: "U \ elts \" shows "ordertype (insert \ U) VWF = succ (ordertype U VWF)" proof - have \: "{y \ insert \ U. (y, \) \ VWF} = U" "{y \ U. (y, \) \ VWF} = U" using Ord_in_Ord OrdmemD assms by auto have eq: "\x. x \ U \ ordermap (insert \ U) VWF x = ordermap U VWF x" by (meson Ord_in_Ord Ord_is_Transset Transset_def U assms(1) in_mono ordermap_insert) have "ordertype (insert \ U) VWF = ZFC_in_HOL.set (insert (ordermap U VWF \) (ordermap U VWF ` U))" by (simp add: ordertype_def ordermap_insert assms eq) also have "\ = succ (ZFC_in_HOL.set (ordermap U VWF ` U))" using "\" U by (simp add: ordermap [OF wf_VWF, of _ \] down succ_def vinsert_def) also have "\ = succ (ordertype U VWF)" by (simp add: ordertype_def) finally show ?thesis . qed lemma finite_ordertype_le_card: assumes "finite A" "wf r" "trans r" shows "ordertype A r \ ord_of_nat (card A)" proof - have "Ord (ordertype A r)" by (simp add: wf_Ord_ordertype assms) moreover have "ordermap A r ` A = elts (ordertype A r)" by (simp add: ordertype_def finite_imp_small \finite A\) moreover have "card (ordermap A r ` A) \ card A" using \finite A\ card_image_le by blast ultimately show ?thesis by (metis Ord_linear_le Ord_ord_of_nat \finite A\ card_ord_of_nat card_seteq finite_imageI less_eq_V_def) qed lemma ordertype_VWF_\: assumes "finite A" shows "ordertype A VWF \ elts \" proof - have "finite (ordermap A VWF ` A)" using assms by blast then have "ordertype A VWF < \" by (meson Ord_\ OrdmemD trans_VWF wf_VWF assms finite_ordertype_le_card le_less_trans ord_of_nat_\) then show ?thesis by (simp add: Ord_mem_iff_lt) qed lemma ordertype_VWF_finite_nat: assumes "finite A" shows "ordertype A VWF = ord_of_nat (card A)" by (metis finite_imp_small ordermap_bij total_on_VWF wf_VWF \_def assms bij_betw_same_card card_ord_of_nat elts_of_set f_inv_into_f inf ordertype_VWF_\) lemma finite_ordertype_eq_card: assumes "small A" "wf r" "trans r" "total_on A r" shows "ordertype A r = ord_of_nat m \ finite A \ card A = m" using ordermap_bij [OF \wf r\] proof - have *: "bij_betw (ordermap A r) A (elts (ordertype A r))" by (simp add: assms ordermap_bij) moreover have "card (ordermap A r ` A) = card A" by (meson bij_betw_def * card_image) ultimately show ?thesis using assms bij_betw_finite bij_betw_imp_surj_on finite_Ord_omega ordertype_VWF_finite_nat wf_Ord_ordertype by fastforce qed lemma ex_bij_betw_strict_mono_card: assumes "finite M" "M \ ON" obtains h where "bij_betw h {..finite M\ ordermap_bij ordertype_VWF_finite_nat by fastforce let ?h = "(inv_into M (ordermap M VWF)) \ ord_of_nat" show thesis proof show bijh: "bij_betw ?h {.. elts (ordertype M VWF)" "n \ elts (ordertype M VWF)" using \m < n\ \n < card M\ \finite M\ ordertype_VWF_finite_nat by auto have ord: "Ord (?h m)" "Ord (?h n)" using bijh assms(2) bij_betwE that by fastforce+ moreover assume "\ ?h m < ?h n" ultimately consider "?h m = ?h n" | "?h m > ?h n" using Ord_linear_lt by blast then show False proof cases case 1 then have "m = n" by (metis inv_ordermap_mono_eq mn comp_apply ord_of_nat_inject) with \m < n\ show False by blast next case 2 then have "ord_of_nat n \ ord_of_nat m" by (metis Finite_V mn assms comp_def inv_ordermap_VWF_mono_le less_imp_le) then show ?thesis using leD \m < n\ by blast qed qed with assms show ?thesis by (auto simp: strict_mono_on_def) qed qed qed lemma ordertype_finite_less_than [simp]: assumes "finite A" shows "ordertype A less_than = card A" proof - let ?M = "ord_of_nat ` A" obtain M: "finite ?M" "?M \ ON" using Ord_ord_of_nat assms by blast have "ordertype A less_than = ordertype ?M VWF" by (rule ordertype_inc_eq [symmetric]) (use assms finite_imp_small total_on_def in \force+\) also have "\ = card A" proof (subst ordertype_eq_iff) let ?M = "ord_of_nat ` A" obtain h where bijh: "bij_betw h {.. ord_of_nat \ inv_into {..f. bij_betw f ?M (elts (card A)) \ (\x\?M. \y\?M. f x < f y \ ((x, y) \ VWF))" proof (intro exI conjI ballI) have "bij_betw (ord_of_nat \ inv_into {.. ?M" "y \ ?M" then obtain m n where "x = ord_of_nat m" "y = ord_of_nat n" by auto have "(f x < f y) \ ((h \ inv_into {.. inv_into {.. = (x < y)" using bijh by (simp add: bij_betw_inv_into_right xy) also have "\ \ ((x, y) \ VWF)" using M(2) ON_imp_Ord xy by auto finally show "(f x < f y) \ ((x, y) \ VWF)" . qed qed auto finally show ?thesis . qed subsection\Cardinality of a set\ -definition - vcard :: "V\V" +definition vcard :: "V\V" where "vcard a \ (LEAST i. Ord i \ elts i \ elts a)" -definition - Card:: "V\bool" where "Card i \ i = vcard i" +definition Card:: "V\bool" + where "Card i \ i = vcard i" abbreviation CARD where "CARD \ Collect Card" lemma cardinal_cong: "elts x \ elts y \ vcard x = vcard y" unfolding vcard_def by (meson eqpoll_sym eqpoll_trans) lemma Card_cardinal_eq: "Card \ \ vcard \ = \" by (simp add: Card_def) lemma Card_is_Ord: assumes "Card \" shows "Ord \" proof - obtain \ where "Ord \" "elts \ \ elts \" using Ord_ordertype ordertype_eqpoll by blast then have "Ord (LEAST i. Ord i \ elts i \ elts \)" by (metis Ord_Least) then show ?thesis using Card_def vcard_def assms by auto qed lemma cardinal_eqpoll: "elts (vcard a) \ elts a" unfolding vcard_def using ordertype_eqpoll [of "elts a"] Ord_LeastI by (meson Ord_ordertype small_elts) lemma inj_into_vcard: obtains f where "f \ elts A \ elts (vcard A)" "inj_on f (elts A)" using cardinal_eqpoll [of A] inj_on_the_inv_into the_inv_into_onto by (fastforce simp: Pi_iff bij_betw_def eqpoll_def) lemma cardinal_idem [simp]: "vcard (vcard a) = vcard a" using cardinal_cong cardinal_eqpoll by blast text\every natural number is a (finite) cardinal\ lemma nat_into_Card: assumes "\ \ elts \" shows "Card(\)" proof (unfold Card_def vcard_def, rule sym) obtain n where n: "\ = ord_of_nat n" by (metis \_def assms elts_of_set imageE inf) have "Ord(\)" using assms by auto moreover { fix \ assume "\ < \" "Ord \" "elts \ \ elts \" with n have "elts \ \ {..Ord \\ \\ < \\ \Ord(\)\ by (metis \elts \ \ elts \\ card_seteq eqpoll_finite_iff eqpoll_iff_card finite_lessThan less_eq_V_def less_le_not_le order_refl) } ultimately show "(LEAST i. Ord i \ elts i \ elts \) = \" by (metis (no_types, lifting) Least_equality Ord_linear_le eqpoll_refl less_le_not_le) qed lemma Card_ord_of_nat [simp]: "Card (ord_of_nat n)" by (simp add: \_def nat_into_Card) lemma Card_0 [iff]: "Card 0" by (simp add: nat_into_Card) lemma CardI: "\Ord i; \j. \j < i; Ord j\ \ \ elts j \ elts i\ \ Card i" unfolding Card_def vcard_def by (metis Ord_Least Ord_linear_lt cardinal_eqpoll eqpoll_refl not_less_Ord_Least vcard_def) lemma vcard_0 [simp]: "vcard 0 = 0" using Card_0 Card_def by auto lemma Ord_cardinal [simp,intro!]: "Ord(vcard a)" unfolding vcard_def by (metis Card_def Card_is_Ord cardinal_cong cardinal_eqpoll vcard_def) text\The cardinals are the initial ordinals.\ lemma Card_iff_initial: "Card \ \ Ord \ \ (\\. Ord \ \ \ < \ \ ~ elts \ \ elts \)" proof - { fix j assume \: "Card \" "elts j \ elts \" "Ord j" assume "j < \" also have "\ = (LEAST i. Ord i \ elts i \ elts \)" using \ by (simp add: Card_def vcard_def) finally have "j < (LEAST i. Ord i \ elts i \ elts \)" . hence "False" using \ using not_less_Ord_Least by fastforce } then show ?thesis by (blast intro: CardI Card_is_Ord) qed lemma Card_\ [iff]: "Card \" proof - have "\\ f. \\ \ elts \; bij_betw f (elts \) (elts \)\ \ False" using bij_betw_finite finite_Ord_omega infinite_\ by blast then show ?thesis by (meson CardI Ord_\ Ord_mem_iff_lt eqpoll_def) qed lemma lt_Card_imp_lesspoll: "\i < a; Card a; Ord i\ \ elts i \ elts a" by (meson Card_iff_initial less_eq_V_def less_imp_le lesspoll_def subset_imp_lepoll) lemma lepoll_imp_Card_le: assumes "elts a \ elts b" shows "vcard a \ vcard b" using Ord_cardinal [of a] Ord_cardinal [of b] proof (cases rule: Ord_linear_le) case le thus ?thesis . next case ge have "elts b \ elts (vcard b)" by (simp add: cardinal_eqpoll eqpoll_sym) also have "\ \ elts (vcard a)" by (meson ge less_eq_V_def subset_imp_lepoll) also have "\ \ elts a" by (simp add: cardinal_eqpoll) finally have "elts b \ elts a" . hence "elts a \ elts b" using assms lepoll_antisym by blast hence "vcard a = vcard b" by (rule cardinal_cong) thus ?thesis by simp qed lemma lepoll_cardinal_le: "\elts A \ elts i; Ord i\ \ vcard A \ i" by (metis Ord_Least Ord_linear2 dual_order.trans eqpoll_refl lepoll_imp_Card_le not_less_Ord_Least vcard_def) lemma cardinal_le_lepoll: "vcard A \ \ \ elts A \ elts \" by (meson cardinal_eqpoll eqpoll_sym lepoll_trans1 less_eq_V_def subset_imp_lepoll) lemma lesspoll_imp_Card_less: assumes "elts a \ elts b" shows "vcard a < vcard b" by (metis assms cardinal_eqpoll eqpoll_sym eqpoll_trans le_neq_trans lepoll_imp_Card_le lesspoll_def) lemma Card_Union [simp,intro]: assumes A: "\x. x \ A \ Card(x)" shows "Card(\A)" proof (rule CardI) show "Ord(\A)" using A by (simp add: Card_is_Ord Ord_Sup) next fix j assume j: "j < \A" "Ord j" hence "\c\A. j < c \ Card(c)" using A by (meson Card_is_Ord Ord_linear2 ZFC_in_HOL.Sup_least leD) then obtain c where c: "c\A" "j < c" "Card(c)" by blast hence jls: "elts j \ elts c" using j(2) lt_Card_imp_lesspoll by blast { assume eqp: "elts j \ elts (\A)" have "elts c \ elts (\A)" using c using Sup_V_def ZFC_in_HOL.Sup_upper j(1) less_eq_V_def subset_imp_lepoll by fastforce also have "... \ elts j" by (rule eqpoll_sym [OF eqp]) also have "... \ elts c" by (rule jls) finally have "elts c \ elts c" . hence False by auto } thus "\ elts j \ elts (\A)" by blast qed lemma Card_UN: "(\x. x \ A \ Card(K x)) ==> Card(Sup (K ` A))" by blast subsection\Transfinite recursion for definitions based on the three cases of ordinals\ definition transrec3 :: "[V, [V,V]\V, [V,V\V]\V, V] \ V" where "transrec3 a b c \ transrec (\r x. if x=0 then a else if Limit x then c x (\y \ elts x. r y) else b(pred x) (r (pred x)))" lemma transrec3_0 [simp]: "transrec3 a b c 0 = a" by (simp add: transrec transrec3_def) lemma transrec3_succ [simp]: "transrec3 a b c (succ i) = b i (transrec3 a b c i)" by (simp add: transrec transrec3_def) lemma transrec3_Limit [simp]: "Limit i \ transrec3 a b c i = c i (\j \ elts i. transrec3 a b c j)" unfolding transrec3_def by (subst transrec) auto subsection \Cardinal Addition\ definition cadd :: "[V,V]\V" (infixl \\\ 65) where "\ \ \ \ vcard (\ \ \)" subsubsection\Cardinal addition is commutative\ lemma vsum_commute_eqpoll: "elts (a\b) \ elts (b\a)" proof - have "bij_betw (\z \ elts (a\b). sum_case Inr Inl z) (elts (a\b)) (elts (b\a))" unfolding bij_betw_def proof (intro conjI inj_onI) show "restrict (sum_case Inr Inl) (elts (a \ b)) ` elts (a \ b) = elts (b \ a)" apply auto apply (metis (no_types) imageI sum_case_Inr sum_iff) by (metis Inl_in_sum_iff imageI sum_case_Inl) qed auto then show ?thesis using eqpoll_def by blast qed lemma cadd_commute: "i \ j = j \ i" by (simp add: cadd_def cardinal_cong vsum_commute_eqpoll) subsubsection\Cardinal addition is associative\ lemma sum_assoc_bij: "bij_betw (\z \ elts ((a\b)\c). sum_case(sum_case Inl (\y. Inr(Inl y))) (\y. Inr(Inr y)) z) (elts ((a\b)\c)) (elts (a\(b\c)))" by (rule_tac f' = "sum_case (\x. Inl (Inl x)) (sum_case (\x. Inl (Inr x)) Inr)" in bij_betw_byWitness) auto lemma sum_assoc_eqpoll: "elts ((a\b)\c) \ elts (a\(b\c))" unfolding eqpoll_def by (metis sum_assoc_bij) lemma elts_vcard_vsum_eqpoll: "elts (vcard (i \ j)) \ Inl ` elts i \ Inr ` elts j" proof - have "elts (i \ j) \ Inl ` elts i \ Inr ` elts j" by (simp add: elts_vsum) then show ?thesis using cardinal_eqpoll eqpoll_trans by blast qed lemma cadd_assoc: "(i \ j) \ k = i \ (j \ k)" proof (unfold cadd_def, rule cardinal_cong) have "elts (vcard(i \ j) \ k) \ elts ((i \ j) \ k)" by (auto simp: disjnt_def elts_vsum elts_vcard_vsum_eqpoll intro: Un_eqpoll_cong) also have "\ \ elts (i \ (j \ k))" by (rule sum_assoc_eqpoll) also have "\ \ elts (i \ vcard(j \ k))" by (auto simp: disjnt_def elts_vsum elts_vcard_vsum_eqpoll [THEN eqpoll_sym] intro: Un_eqpoll_cong) finally show "elts (vcard (i \ j) \ k) \ elts (i \ vcard (j \ k))" . qed text\0 is the identity for addition\ lemma vsum_0_eqpoll: "elts (0\a) \ elts a" by (simp add: elts_vsum) lemma cadd_0 [simp]: "Card \ \ 0 \ \ = \" by (metis Card_def cadd_def cardinal_cong vsum_0_eqpoll) lemma cadd_0_right [simp]: "Card \ \ \ \ 0 = \" by (simp add: cadd_commute) lemma vsum_lepoll_self: "elts a \ elts (a\b)" unfolding elts_vsum by (meson Inl_iff Un_upper1 inj_onI lepoll_def) lemma cadd_le_self: assumes \: "Card \" shows "\ \ \ \ a" proof (unfold cadd_def) have "\ \ vcard \" using Card_def \ by auto also have "\ \ vcard (\ \ a)" by (simp add: lepoll_imp_Card_le vsum_lepoll_self) finally show "\ \ vcard (\ \ a)" . qed text\Monotonicity of addition\ lemma cadd_le_mono: "\\' \ \; \' \ \\ \ \' \ \' \ \ \ \" unfolding cadd_def by (metis (no_types) lepoll_imp_Card_le less_eq_V_def subset_imp_lepoll sum_subset_iff) subsection\Cardinal multiplication\ definition cmult :: "[V,V]\V" (infixl \\\ 70) where "\ \ \ \ vcard (VSigma \ (\z. \))" subsubsection\Cardinal multiplication is commutative\ lemma prod_bij: "\bij_betw f A C; bij_betw g B D\ \ bij_betw (\(x, y). (f x, g y)) (A \ B) (C \ D)" apply (rule bij_betw_byWitness [where f' = "\(x,y). (inv_into A f x, inv_into B g y)"]) apply (auto simp: bij_betw_inv_into_left bij_betw_inv_into_right bij_betwE) using bij_betwE bij_betw_inv_into apply blast+ done lemma cmult_commute: "i \ j = j \ i" proof - have "(\(x, y). \x, y\) ` (elts i \ elts j) \ (\(x, y). \x, y\) ` (elts j \ elts i)" by (simp add: inj_on_vpair times_commute_eqpoll) then show ?thesis unfolding cmult_def using cardinal_cong elts_VSigma by auto qed subsubsection\Cardinal multiplication is associative\ lemma elts_vcard_VSigma_eqpoll: "elts (vcard (vtimes i j)) \ elts i \ elts j" proof - have "elts (vtimes i j) \ elts i \ elts j" by (simp add: elts_VSigma) then show ?thesis using cardinal_eqpoll eqpoll_trans by blast qed lemma cmult_assoc: "(i \ j) \ k = i \ (j \ k)" unfolding cmult_def proof (rule cardinal_cong) have "elts (vcard (vtimes i j)) \ elts k \ (elts i \ elts j) \ elts k" by (blast intro: times_eqpoll_cong elts_vcard_VSigma_eqpoll cardinal_eqpoll) also have "\ \ elts i \ (elts j \ elts k)" by (rule times_assoc_eqpoll) also have "\ \ elts i \ elts (vcard (vtimes j k))" by (blast intro: times_eqpoll_cong elts_vcard_VSigma_eqpoll cardinal_eqpoll eqpoll_sym) finally show "elts (VSigma (vcard (vtimes i j)) (\z. k)) \ elts (VSigma i (\z. vcard (vtimes j k)))" by (simp add: elts_VSigma) qed subsubsection\Cardinal multiplication distributes over addition\ lemma cadd_cmult_distrib: "(i \ j) \ k = (i \ k) \ (j \ k)" unfolding cadd_def cmult_def proof (rule cardinal_cong) have "elts (vtimes (vcard (i \ j)) k) \ elts (vcard (vsum i j)) \ elts k" using cardinal_eqpoll elts_vcard_VSigma_eqpoll eqpoll_sym eqpoll_trans by blast also have "\ \ (Inl ` elts i \ Inr ` elts j) \ elts k" using elts_vcard_vsum_eqpoll times_eqpoll_cong by blast also have "\ \ (Inl ` elts i) \ elts k \ (Inr ` elts j) \ elts k" by (simp add: Sigma_Un_distrib1) also have "\ \ elts (vtimes i k \ vtimes j k)" unfolding Plus_def by (auto simp: elts_vsum elts_VSigma disjnt_iff intro!: Un_eqpoll_cong times_eqpoll_cong) also have "\ \ elts (vcard (vtimes i k \ vtimes j k))" by (simp add: cardinal_eqpoll eqpoll_sym) also have "\ \ elts (vcard (vtimes i k) \ vcard (vtimes j k))" by (metis cadd_assoc cadd_def cardinal_cong cardinal_eqpoll vsum_0_eqpoll vsum_commute_eqpoll) finally show "elts (VSigma (vcard (i \ j)) (\z. k)) \ elts (vcard (vtimes i k) \ vcard (vtimes j k))" . qed text\Multiplication by 0 yields 0\ lemma cmult_0 [simp]: "0 \ i = 0" using Card_0 Card_def cmult_def by auto text\1 is the identity for multiplication\ lemma cmult_1 [simp]: assumes "Card \" shows "1 \ \ = \" proof - have "elts (vtimes (set {0}) \) \ elts \" by (auto simp: elts_VSigma intro!: times_singleton_eqpoll) then show ?thesis by (metis Card_def assms cardinal_cong cmult_def elts_1 set_of_elts) qed subsection\Some inequalities for multiplication\ lemma cmult_square_le: assumes "Card \" shows "\ \ \ \ \" proof - have "elts \ \ elts (\ \ \)" using times_square_lepoll [of "elts \"] cmult_def elts_vcard_VSigma_eqpoll eqpoll_sym lepoll_trans2 by fastforce then show ?thesis using Card_def assms cmult_def lepoll_cardinal_le by fastforce qed text\Multiplication by a non-empty set\ lemma cmult_le_self: assumes "Card \" "\ \ 0" shows "\ \ \ \ \" proof - have "\ = vcard \" using Card_def \Card \\ by blast also have "\ \ vcard (vtimes \ \)" apply (rule lepoll_imp_Card_le) apply (simp add: elts_VSigma) by (metis ZFC_in_HOL.ext \\ \ 0\ elts_0 lepoll_times1) also have "\ = \ \ \" by (simp add: cmult_def) finally show ?thesis . qed text\Monotonicity of multiplication\ lemma cmult_le_mono: "\\' \ \; \' \ \\ \ \' \ \' \ \ \ \" unfolding cmult_def by (auto simp: elts_VSigma intro!: lepoll_imp_Card_le times_lepoll_mono subset_imp_lepoll) subsection\The finite cardinals\ lemma succ_lepoll_succD: "elts (succ(m)) \ elts (succ(n)) \ elts m \ elts n" by (simp add: insert_lepoll_insertD) text\Congruence law for @{text succ} under equipollence\ lemma succ_eqpoll_cong: "elts a \ elts b \ elts (succ(a)) \ elts (succ(b))" by (simp add: succ_def insert_eqpoll_cong) lemma sum_succ_eqpoll: "elts (succ a \ b) \ elts (succ(a\b))" unfolding eqpoll_def proof (rule exI) let ?f = "\z. if z=Inl a then a\b else z" let ?g = "\z. if z=a\b then Inl a else z" show "bij_betw ?f (elts (succ a \ b)) (elts (succ (a \ b)))" apply (rule bij_betw_byWitness [where f' = ?g], auto) apply (metis Inl_in_sum_iff mem_not_refl) by (metis Inr_in_sum_iff mem_not_refl) qed lemma cadd_succ: "succ m \ n = vcard (succ(m \ n))" proof (unfold cadd_def) have [intro]: "elts (m \ n) \ elts (vcard (m \ n))" using cardinal_eqpoll eqpoll_sym by blast have "vcard (succ m \ n) = vcard (succ(m \ n))" by (rule sum_succ_eqpoll [THEN cardinal_cong]) also have "\ = vcard (succ(vcard (m \ n)))" by (blast intro: succ_eqpoll_cong cardinal_cong) finally show "vcard (succ m \ n) = vcard (succ(vcard (m \ n)))" . qed lemma nat_cadd_eq_add: "ord_of_nat m \ ord_of_nat n = ord_of_nat (m + n)" proof (induct m) case (Suc m) thus ?case by (metis Card_def Card_ord_of_nat add_Suc cadd_succ ord_of_nat.simps(2)) qed auto lemma vcard_disjoint_sup: assumes "x \ y = 0" shows "vcard (x \ y) = vcard x \ vcard y" proof - have "elts (x \ y) \ elts (x \ y)" unfolding eqpoll_def proof (rule exI) let ?f = "\z. if z \ elts x then Inl z else Inr z" let ?g = "sum_case id id" show "bij_betw ?f (elts (x \ y)) (elts (x \ y))" by (rule bij_betw_byWitness [where f' = ?g]) (use assms V_disjoint_iff in auto) qed then show ?thesis by (metis cadd_commute cadd_def cardinal_cong cardinal_idem vsum_0_eqpoll cadd_assoc) qed subsection\Infinite cardinals\ definition InfCard :: "V\bool" where "InfCard \ \ Card \ \ \ \ \" lemma InfCard_iff: "InfCard \ \ Card \ \ infinite (elts \)" proof (cases "\ \ \") case True then show ?thesis using inj_ord_of_nat lepoll_def less_eq_V_def by (auto simp: InfCard_def \_def infinite_le_lepoll) next case False then show ?thesis using Card_iff_initial InfCard_def infinite_Ord_omega by blast qed lemma InfCard_ge_ord_of_nat: assumes "InfCard \" shows "ord_of_nat n \ \" using InfCard_def assms ord_of_nat_le_omega by blast lemma InfCard_not_0[iff]: "\ InfCard 0" by (simp add: InfCard_iff) -definition - csucc :: "V\V" +definition csucc :: "V\V" where "csucc \ \ LEAST \'. Ord \' \ (Card \' \ \ < \')" lemma less_vcard_VPow: "vcard A < vcard (VPow A)" proof (rule lesspoll_imp_Card_less) show "elts A \ elts (VPow A)" by (simp add: elts_VPow down inj_on_def lesspoll_Pow_self) qed lemma greater_Card: assumes "Card \" shows "\ < vcard (VPow \)" proof - have "\ = vcard \" using Card_def assms by blast also have "\ < vcard (VPow \)" proof (rule lesspoll_imp_Card_less) show "elts \ \ elts (VPow \)" by (simp add: elts_VPow down inj_on_def lesspoll_Pow_self) qed finally show ?thesis . qed lemma assumes "Card \" shows Card_csucc [simp]: "Card (csucc \)" and less_csucc [simp]: "\ < csucc \" proof - have "Card (csucc \) \ \ < csucc \" unfolding csucc_def proof (rule Ord_LeastI2) show "Card (vcard (VPow \)) \ \ < (vcard (VPow \))" using Card_def assms greater_Card by auto qed auto then show "Card (csucc \)" "\ < csucc \" by auto qed lemma le_csucc: assumes "Card \" shows "\ \ csucc \" by (simp add: assms less_csucc less_imp_le) lemma csucc_le: "\Card \; \ \ elts \\ \ csucc \ \ \" unfolding csucc_def by (simp add: Card_is_Ord Ord_Least_le OrdmemD) lemma finite_csucc: "a \ elts \ \ csucc a = succ a" unfolding csucc_def proof (rule Least_equality) show "Ord (ZFC_in_HOL.succ a) \ Card (ZFC_in_HOL.succ a) \ a < ZFC_in_HOL.succ a" if "a \ elts \" using that by (auto simp: less_V_def less_eq_V_def nat_into_Card) show "ZFC_in_HOL.succ a \ y" if "a \ elts \" and "Ord y \ Card y \ a < y" for y :: V using that using Ord_mem_iff_lt dual_order.strict_implies_order by fastforce qed lemma Finite_imp_cardinal_cons [simp]: assumes FA: "finite A" and a: "a \ A" shows "vcard (set (insert a A)) = csucc(vcard (set A))" proof - show ?thesis unfolding csucc_def proof (rule Least_equality [THEN sym]) have "small A" by (simp add: FA Finite_V) then have "\ elts (set A) \ elts (set (insert a A))" using FA a eqpoll_imp_lepoll eqpoll_sym finite_insert_lepoll by fastforce then show "Ord (vcard (set (insert a A))) \ Card (vcard (set (insert a A))) \ vcard (set A) < vcard (set (insert a A))" by (simp add: Card_def lesspoll_imp_Card_less lesspoll_def subset_imp_lepoll subset_insertI) show "vcard (set (insert a A)) \ i" if "Ord i \ Card i \ vcard (set A) < i" for i proof - have "elts (vcard (set A)) \ A" by (metis FA finite_imp_small cardinal_eqpoll elts_of_set) then have less: "A \ elts i" using eq_lesspoll_trans eqpoll_sym lt_Card_imp_lesspoll that by blast show ?thesis using that less by (auto simp: less_imp_insert_lepoll lepoll_cardinal_le) qed qed qed lemma vcard_finite_set: "finite A \ vcard (set A) = ord_of_nat (card A)" by (induction A rule: finite_induct) (auto simp: set_empty \_def finite_csucc) lemma lt_csucc_iff: assumes "Ord \" "Card \" shows "\ < csucc \ \ vcard \ \ \" proof show "vcard \ \ \" if "\ < csucc \" proof - have "vcard \ \ csucc \" by (meson \Ord \\ dual_order.trans lepoll_cardinal_le lepoll_refl less_le_not_le that) then show ?thesis by (metis (no_types) Card_def Card_iff_initial Ord_linear2 Ord_mem_iff_lt assms cardinal_eqpoll cardinal_idem csucc_le eq_iff eqpoll_sym that) qed show "\ < csucc \" if "vcard \ \ \" proof - have "\ csucc \ \ \" using that by (metis Card_csucc Card_def assms(2) le_less_trans lepoll_imp_Card_le less_csucc less_eq_V_def less_le_not_le subset_imp_lepoll) then show ?thesis by (meson Card_csucc Card_is_Ord Ord_linear2 assms) qed qed lemma Card_lt_csucc_iff: "\Card \'; Card \\ \ (\' < csucc \) = (\' \ \)" by (simp add: lt_csucc_iff Card_cardinal_eq Card_is_Ord) lemma InfCard_csucc: "InfCard \ \ InfCard (csucc \)" using InfCard_def le_csucc by auto text\Kunen's Lemma 10.11\ lemma InfCard_is_Limit: assumes "InfCard \" shows "Limit \" proof (rule non_succ_LimitI) show "\ \ 0" using InfCard_def assms mem_not_refl by blast show "Ord \" using Card_is_Ord InfCard_def assms by blast show "ZFC_in_HOL.succ y \ \" for y proof assume "succ y = \" then have "Card (succ y)" using InfCard_def assms by auto moreover have "\ \ y" by (metis InfCard_iff Ord_in_Ord \Ord \\ \ZFC_in_HOL.succ y = \\ assms elts_succ finite_insert infinite_Ord_omega insertI1) moreover have "elts y \ elts (succ y)" using InfCard_iff \ZFC_in_HOL.succ y = \\ assms eqpoll_sym infinite_insert_eqpoll by fastforce ultimately show False by (metis Card_iff_initial Ord_in_Ord OrdmemD elts_succ insertI1) qed qed subsection\Toward's Kunen's Corollary 10.13 (1)\ text\Kunen's Theorem 10.12\ lemma InfCard_csquare_eq: assumes "InfCard(\)" shows "\ \ \ = \" using infinite_times_eqpoll_self [of "elts \"] assms unfolding InfCard_iff Card_def by (metis cardinal_cong cardinal_eqpoll cmult_def elts_vcard_VSigma_eqpoll eqpoll_trans) lemma InfCard_le_cmult_eq: assumes "InfCard \" "\ \ \" "\ \ 0" shows "\ \ \ = \" proof (rule order_antisym) have "\ \ \ \ \ \ \" by (simp add: assms(2) cmult_le_mono) also have "\ \ \" by (simp add: InfCard_csquare_eq assms(1)) finally show "\ \ \ \ \" . show "\ \ \ \ \" using InfCard_def assms(1) assms(3) cmult_le_self by auto qed text\Kunen's Corollary 10.13 (1), for cardinal multiplication\ lemma InfCard_cmult_eq: "\InfCard \; InfCard \\ \ \ \ \ = \ \ \" by (metis Card_is_Ord InfCard_def InfCard_le_cmult_eq Ord_linear_le cmult_commute inf_sup_aci(5) mem_not_refl sup.orderE sup_V_0_right zero_in_omega) lemma cmult_succ: "succ(m) \ n = n \ (m \ n)" unfolding cmult_def cadd_def proof (rule cardinal_cong) have "elts (vtimes (ZFC_in_HOL.succ m) n) \ elts n <+> elts m \ elts n" by (simp add: elts_VSigma prod_insert_eqpoll) also have "\ \ elts (n \ vcard (vtimes m n))" unfolding elts_VSigma elts_vsum Plus_def proof (rule Un_eqpoll_cong) show "(Sum_Type.Inr ` (elts m \ elts n)::(V + V \ V) set) \ Inr ` elts (vcard (vtimes m n))" by (simp add: elts_vcard_VSigma_eqpoll eqpoll_sym) qed (auto simp: disjnt_def) finally show "elts (vtimes (ZFC_in_HOL.succ m) n) \ elts (n \ vcard (vtimes m n))" . qed lemma cmult_2: assumes "Card n" shows "ord_of_nat 2 \ n = n \ n" proof - have "ord_of_nat 2 = succ (succ 0)" by force then show ?thesis by (simp add: cmult_succ assms) qed lemma InfCard_cdouble_eq: assumes "InfCard \" shows "\ \ \ = \" proof - have "\ \ \ = \ \ ord_of_nat 2" using InfCard_def assms cmult_2 cmult_commute by auto also have "\ = \" by (simp add: InfCard_le_cmult_eq InfCard_ge_ord_of_nat assms) finally show ?thesis . qed text\Corollary 10.13 (1), for cardinal addition\ lemma InfCard_le_cadd_eq: "\InfCard \; \ \ \\ \ \ \ \ = \" by (metis InfCard_cdouble_eq InfCard_def antisym cadd_le_mono cadd_le_self) lemma InfCard_cadd_eq: "\InfCard \; InfCard \\ \ \ \ \ = \ \ \" by (metis Card_iff_initial InfCard_def InfCard_le_cadd_eq Ord_linear_le cadd_commute sup.absorb2 sup.orderE) subsection \The Aleph-seqence\ text \This is the well-known transfinite enumeration of the cardinal numbers.\ -definition - Aleph :: "V \ V" (\\_\ [90] 90) +definition Aleph :: "V \ V" (\\_\ [90] 90) where "Aleph \ transrec3 \ (\x r. csucc(r)) (\i r . \ (r ` elts i))" lemma Card_Aleph [simp, intro]: "Ord \ \ Card(Aleph \)" by (induction \ rule: Ord_induct3) (auto simp: Aleph_def) lemma Aleph_0 [simp]: "\0 = \" by (simp add: Aleph_def) lemma Aleph_succ [simp]: "\(succ x) = csucc (\ x)" by (simp add: Aleph_def) lemma Aleph_Limit: "Limit \ \ \ \ = \ (Aleph ` elts \)" by (simp add: Aleph_def) lemma mem_Aleph_succ: "Ord \ \ \(\) \ elts (\(succ \))" by (simp add: Card_is_Ord Ord_mem_iff_lt) lemma Aleph_increasing: assumes ab: "\ < \" "Ord \" "Ord \" shows "Aleph(\) < Aleph(\)" proof - { fix x have "\Ord x; x \ elts \\ \ Aleph(x) \ elts (Aleph \)" using \Ord \\ proof (induct \ arbitrary: x rule: Ord_induct3) case 0 thus ?case by simp next case (succ \) then consider "x = \" |"x \ elts \" using OrdmemD by auto then show ?case proof cases case 1 then show ?thesis by (simp add: Card_is_Ord Ord_mem_iff_lt succ.hyps(1)) next case 2 with succ show ?thesis by (metis Aleph_succ Card_Aleph le_csucc vsubsetD) qed next case (Limit \) hence sc: "succ x \ elts \" by (simp add: Limit_def Ord_mem_iff_lt) hence "\ x \ elts (\ (Aleph ` elts \))" using Limit by blast thus ?case using Limit by (simp add: Aleph_Limit) qed } thus ?thesis using ab by (simp add: Card_is_Ord Ord_mem_iff_lt) qed lemma countable_iff_le_Aleph0: "countable (elts A) \ vcard A \ \0" proof show "vcard A \ \0" if "countable (elts A)" proof (cases "finite (elts A)") case True then show ?thesis using vcard_finite_set by fastforce next case False then have "elts \ \ elts A" using countableE_infinite [OF that] by (simp add: eqpoll_def \_def) (meson bij_betw_def bij_betw_inv bij_betw_trans inj_ord_of_nat) then show ?thesis using Card_\ Card_def cardinal_cong vcard_def by auto qed show "countable (elts A)" if "vcard A \ \0" proof - have "elts A \ elts \" using cardinal_le_lepoll [OF that] by simp then show ?thesis by (simp add: countable_iff_lepoll \_def inj_ord_of_nat) qed qed subsection \The ordinal @{term "\1"}\ abbreviation "\1 \ Aleph 1" lemma Ord_\1 [simp]: "Ord \1" by (simp add: Card_is_Ord) lemma omega_\1 [iff]: "\ \ elts \1" using mem_Aleph_succ one_V_def by fastforce lemma ord_of_nat_\1 [iff]: "ord_of_nat n \ elts \1" using Ord_\1 Ord_trans by blast lemma countable_iff_less_\1: assumes "Ord \" shows "countable (elts \) \ \ < \1" by (simp add: assms countable_iff_le_Aleph0 lt_csucc_iff one_V_def) lemma less_\1_imp_countable: assumes "\ \ elts \1" shows "countable (elts \)" using Ord_\1 Ord_in_Ord OrdmemD assms countable_iff_less_\1 by blast lemma \1_gt0 [simp]: "\1 > 0" using Ord_\1 Ord_trans OrdmemD by blast lemma \1_gt1 [simp]: "\1 > 1" using Ord_\1 OrdmemD \_gt1 less_trans by blast lemma Limit_\1 [simp]: "Limit \1" by (simp add: InfCard_def InfCard_is_Limit le_csucc one_V_def) end diff --git a/thys/ZFC_in_HOL/ZFC_in_HOL.thy b/thys/ZFC_in_HOL/ZFC_in_HOL.thy --- a/thys/ZFC_in_HOL/ZFC_in_HOL.thy +++ b/thys/ZFC_in_HOL/ZFC_in_HOL.thy @@ -1,1293 +1,1290 @@ section \The ZF Axioms, Ordinals and Transfinite Recursion\ theory ZFC_in_HOL imports ZFC_Library begin subsection\Syntax and axioms\ hide_const (open) list.set Sum subset -notation - inf (infixl "\" 70) and - sup (infixl "\" 65) and - Inf ("\") and - Sup ("\") +unbundle lattice_syntax typedecl V text\Presentation refined by Dmitriy Traytel\ axiomatization elts :: "V \ V set" where ext [intro?]: "elts x = elts y \ x=y" and down_raw: "Y \ elts x \ Y \ range elts" and Union_raw: "X \ range elts \ Union (elts ` X) \ range elts" and Pow_raw: "X \ range elts \ inv elts ` Pow X \ range elts" and replacement_raw: "X \ range elts \ f ` X \ range elts" and inf_raw: "range (g :: nat \ V) \ range elts" and foundation: "wf {(x,y). x \ elts y}" lemma mem_not_refl [simp]: "i \ elts i" using wf_not_refl [OF foundation] by force lemma mem_not_sym: "\ (x \ elts y \ y \ elts x)" using wf_not_sym [OF foundation] by force text \A set is small if it can be injected into the extension of a V-set.\ definition small :: "'a set \ bool" where "small X \ \V_of :: 'a \ V. inj_on V_of X \ V_of ` X \ range elts" lemma small_empty [iff]: "small {}" by (simp add: small_def down_raw) lemma small_iff_range: "small X \ X \ range elts" apply (simp add: small_def) by (metis inj_on_id2 replacement_raw the_inv_into_onto) text\Small classes can be mapped to sets.\ -definition "set X \ (if small X then inv elts X else inv elts {})" +definition set :: "V set \ V" + where "set X \ (if small X then inv elts X else inv elts {})" lemma set_of_elts [simp]: "set (elts x) = x" by (force simp add: ext set_def f_inv_into_f small_def) lemma elts_of_set [simp]: "elts (set X) = (if small X then X else {})" by (simp add: ZFC_in_HOL.set_def down_raw f_inv_into_f small_iff_range) lemma down: "Y \ elts x \ small Y" by (simp add: down_raw small_iff_range) lemma Union [intro]: "small X \ small (Union (elts ` X))" by (simp add: Union_raw small_iff_range) lemma Pow: "small X \ small (set ` Pow X)" unfolding small_iff_range using Pow_raw set_def down by force declare replacement_raw [intro,simp] lemma replacement [intro,simp]: assumes "small X" shows "small (f ` X)" proof - let ?A = "inv_into X f ` (f ` X)" have AX: "?A \ X" by (simp add: image_subsetI inv_into_into) have inj: "inj_on f ?A" by (simp add: f_inv_into_f inj_on_def) have injo: "inj_on (inv_into X f) (f ` X)" using inj_on_inv_into by blast have "\V_of. inj_on V_of (f ` X) \ V_of ` f ` X \ range elts" if "inj_on V_of X" and "V_of ` X = elts x" for V_of :: "'a \ V" and x proof (intro exI conjI) show "inj_on (V_of \ inv_into X f) (f ` X)" by (meson \inv_into X f ` f ` X \ X\ comp_inj_on inj_on_subset injo that) have "(\x. V_of (inv_into X f (f x))) ` X = elts (set (V_of ` ?A))" by (metis AX down elts_of_set image_image image_mono that(2)) then show "(V_of \ inv_into X f) ` f ` X \ range elts" by (metis image_comp image_image rangeI) qed then show ?thesis using assms by (auto simp: small_def) qed lemma small_image_iff [simp]: "inj_on f A \ small (f ` A) \ small A" by (metis replacement the_inv_into_onto) text \A little bootstrapping is needed to characterise @{term small} for sets of arbitrary type.\ lemma inf: "small (range (g :: nat \ V))" by (simp add: inf_raw small_iff_range) lemma small_image_nat_V [simp]: "small (g ` N)" for g :: "nat \ V" by (metis (mono_tags, opaque_lifting) down elts_of_set image_iff inf rangeI subsetI) lemma Finite_V: fixes X :: "V set" assumes "finite X" shows "small X" using ex_bij_betw_nat_finite [OF assms] unfolding bij_betw_def by (metis small_image_nat_V) lemma small_insert_V: fixes X :: "V set" assumes "small X" shows "small (insert a X)" proof (cases "finite X") case True then show ?thesis by (simp add: Finite_V) next case False show ?thesis using infinite_imp_bij_betw2 [OF False] by (metis replacement Un_insert_right assms bij_betw_imp_surj_on sup_bot.right_neutral) qed lemma small_UN_V [simp,intro]: fixes B :: "'a \ V set" assumes X: "small X" and B: "\x. x \ X \ small (B x)" shows "small (\x\X. B x)" proof - have "(\ (elts ` (\x. ZFC_in_HOL.set (B x)) ` X)) = (\ (B ` X))" using B by force then show ?thesis using Union [OF replacement [OF X, of "\x. ZFC_in_HOL.set (B x)"]] by simp qed definition vinsert where "vinsert x y \ set (insert x (elts y))" lemma elts_vinsert [simp]: "elts (vinsert x y) = insert x (elts y)" using down small_insert_V vinsert_def by auto definition succ where "succ x \ vinsert x x" lemma elts_succ [simp]: "elts (succ x) = insert x (elts x)" by (simp add: succ_def) lemma finite_imp_small: assumes "finite X" shows "small X" using assms proof induction case empty then show ?case by simp next case (insert a X) then obtain V_of u where u: "inj_on V_of X" "V_of ` X = elts u" by (meson small_def image_iff) show ?case unfolding small_def proof (intro exI conjI) show "inj_on (V_of(a:=u)) (insert a X)" using u apply (clarsimp simp add: inj_on_def) by (metis image_eqI mem_not_refl) have "(V_of(a:=u)) ` insert a X = elts (vinsert u u)" using insert.hyps(2) u(2) by auto then show "(V_of(a:=u)) ` insert a X \ range elts" by (blast intro: elim: ) qed qed lemma small_insert: assumes "small X" shows "small (insert a X)" proof (cases "finite X") case True then show ?thesis by (simp add: finite_imp_small) next case False show ?thesis using infinite_imp_bij_betw2 [OF False] by (metis replacement Un_insert_right assms bij_betw_imp_surj_on sup_bot.right_neutral) qed lemma smaller_than_small: assumes "small A" "B \ A" shows "small B" using assms by (metis down elts_of_set image_mono small_def small_iff_range subset_inj_on) lemma small_insert_iff [iff]: "small (insert a X) \ small X" by (meson small_insert smaller_than_small subset_insertI) lemma small_iff: "small X \ (\x. X = elts x)" by (metis down elts_of_set subset_refl) lemma small_elts [iff]: "small (elts x)" by (auto simp: small_iff) lemma small_diff [iff]: "small (elts a - X)" by (meson Diff_subset down) lemma small_set [simp]: "small (list.set xs)" by (simp add: ZFC_in_HOL.finite_imp_small) lemma small_upair: "small {x,y}" by simp lemma small_Un_elts: "small (elts x \ elts y)" using Union [OF small_upair] by auto lemma small_eqcong: "\small X; X \ Y\ \ small Y" by (metis bij_betw_imp_surj_on eqpoll_def replacement) lemma big_UNIV [simp]: "\ small (UNIV::V set)" (is "\ small ?U") proof assume "small ?U" then have "small A" for A :: "V set" by (metis (full_types) UNIV_I down small_iff subsetI) then have "range elts = UNIV" by (meson small_iff surj_def) then show False by (metis Cantors_paradox Pow_UNIV) qed lemma inj_on_set: "inj_on set (Collect small)" by (metis elts_of_set inj_onI mem_Collect_eq) lemma set_injective [simp]: "\small X; small Y\ \ set X = set Y \ X=Y" by (metis elts_of_set) subsection\Type classes and other basic setup\ instantiation V :: zero begin definition zero_V where "0 \ set {}" instance .. end lemma elts_0 [simp]: "elts 0 = {}" by (simp add: zero_V_def) lemma set_empty [simp]: "set {} = 0" by (simp add: zero_V_def) instantiation V :: one begin definition one_V where "1 \ succ 0" instance .. end lemma elts_1 [simp]: "elts 1 = {0}" by (simp add: one_V_def) lemma insert_neq_0 [simp]: "set (insert a X) = 0 \ \ small X" unfolding zero_V_def by (metis elts_of_set empty_not_insert set_of_elts small_insert_iff) lemma elts_eq_empty_iff [simp]: "elts x = {} \ x=0" by (auto simp: ZFC_in_HOL.ext) instantiation V :: distrib_lattice begin definition inf_V where "inf_V x y \ set (elts x \ elts y)" definition sup_V where "sup_V x y \ set (elts x \ elts y)" definition less_eq_V where "less_eq_V x y \ elts x \ elts y" definition less_V where "less_V x y \ less_eq x y \ x \ (y::V)" instance proof show "(x < y) = (x \ y \ \ y \ x)" for x :: V and y :: V using ext less_V_def less_eq_V_def by auto show "x \ x" for x :: V by (simp add: less_eq_V_def) show "x \ z" if "x \ y" "y \ z" for x y z :: V using that by (auto simp: less_eq_V_def) show "x = y" if "x \ y" "y \ x" for x y :: V using that by (simp add: ext less_eq_V_def) show "inf x y \ x" for x y :: V by (metis down elts_of_set inf_V_def inf_sup_ord(1) less_eq_V_def) show "inf x y \ y" for x y :: V by (metis Int_lower2 down elts_of_set inf_V_def less_eq_V_def) show "x \ inf y z" if "x \ y" "x \ z" for x y z :: V proof - have "small (elts y \ elts z)" by (meson down inf.cobounded1) then show ?thesis using elts_of_set inf_V_def less_eq_V_def that by auto qed show "x \ x \ y" "y \ x \ y" for x y :: V by (simp_all add: less_eq_V_def small_Un_elts sup_V_def) show "sup y z \ x" if "y \ x" "z \ x" for x y z :: V using less_eq_V_def sup_V_def that by auto show "sup x (inf y z) = inf (x \ y) (sup x z)" for x y z :: V proof - have "small (elts y \ elts z)" by (meson down inf.cobounded2) then show ?thesis by (simp add: Un_Int_distrib inf_V_def small_Un_elts sup_V_def) qed qed end lemma V_equalityI [intro]: "(\x. x \ elts a \ x \ elts b) \ a = b" by (meson dual_order.antisym less_eq_V_def subsetI) lemma vsubsetI [intro!]: "(\x. x \ elts a \ x \ elts b) \ a \ b" by (simp add: less_eq_V_def subsetI) lemma vsubsetD [elim, intro?]: "a \ b \ c \ elts a \ c \ elts b" using less_eq_V_def by auto lemma rev_vsubsetD: "c \ elts a \ a \ b \ c \ elts b" \ \The same, with reversed premises for use with @{method erule} -- cf. @{thm rev_mp}.\ by (rule vsubsetD) lemma vsubsetCE [elim,no_atp]: "a \ b \ (c \ elts a \ P) \ (c \ elts b \ P) \ P" \ \Classical elimination rule.\ using vsubsetD by blast lemma set_image_le_iff: "small A \ set (f ` A) \ B \ (\x\A. f x \ elts B)" by auto lemma eq0_iff: "x = 0 \ (\y. y \ elts x)" by auto lemma less_eq_V_0_iff [simp]: "x \ 0 \ x = 0" for x::V by auto lemma subset_iff_less_eq_V: assumes "small B" shows "A \ B \ set A \ set B \ small A" using assms down small_iff by auto lemma small_Collect [simp]: "small A \ small {x \ A. P x}" by (simp add: smaller_than_small) lemma small_Union_iff: "small (\(elts ` X)) \ small X" proof show "small X" if "small (\ (elts ` X))" proof - have "X \ set ` Pow (\ (elts ` X))" by fastforce then show ?thesis using Pow subset_iff_less_eq_V that by auto qed qed auto lemma not_less_0 [iff]: fixes x::V shows "\ x < 0" by (simp add: less_eq_V_def less_le_not_le) lemma le_0 [iff]: fixes x::V shows "0 \ x" by auto lemma min_0L [simp]: "min 0 n = 0" for n :: V by (simp add: min_absorb1) lemma min_0R [simp]: "min n 0 = 0" for n :: V by (simp add: min_absorb2) lemma neq0_conv: "\n::V. n \ 0 \ 0 < n" by (simp add: less_V_def) definition VPow :: "V \ V" where "VPow x \ set (set ` Pow (elts x))" lemma VPow_iff [iff]: "y \ elts (VPow x) \ y \ x" using down Pow apply (auto simp: VPow_def less_eq_V_def) using less_eq_V_def apply fastforce done lemma VPow_le_VPow_iff [simp]: "VPow a \ VPow b \ a \ b" by auto lemma elts_VPow: "elts (VPow x) = set ` Pow (elts x)" by (auto simp: VPow_def Pow) lemma small_sup_iff [simp]: "small (X \ Y) \ small X \ small Y" for X::"V set" by (metis down elts_of_set small_Un_elts sup_ge1 sup_ge2) lemma elts_sup_iff [simp]: "elts (x \ y) = elts x \ elts y" by (simp add: sup_V_def) lemma trad_foundation: assumes z: "z \ 0" shows "\w. w \ elts z \ w \ z = 0" using foundation assms by (simp add: wf_eq_minimal) (metis Int_emptyI equals0I inf_V_def set_of_elts zero_V_def) instantiation "V" :: Sup begin definition Sup_V where "Sup_V X \ if small X then set (Union (elts ` X)) else 0" instance .. end instantiation "V" :: Inf begin definition Inf_V where "Inf_V X \ if X = {} then 0 else set (Inter (elts ` X))" instance .. end lemma V_disjoint_iff: "x \ y = 0 \ elts x \ elts y = {}" by (metis down elts_of_set inf_V_def inf_le1 zero_V_def) text\I've no idea why @{term bdd_above} is treated differently from @{term bdd_below}, but anyway\ lemma bdd_above_iff_small [simp]: "bdd_above X = small X" for X::"V set" proof show "small X" if "bdd_above X" proof - obtain a where "\x\X. x \ a" using that \bdd_above X\ bdd_above_def by blast then show "small X" by (meson VPow_iff \\x\X. x \ a\ down subsetI) qed show "bdd_above X" if "small X" proof - have "\x\X. x \ \ X" by (simp add: SUP_upper Sup_V_def Union less_eq_V_def that) then show ?thesis by (meson bdd_above_def) qed qed instantiation "V" :: conditionally_complete_lattice begin definition bdd_below_V where "bdd_below_V X \ X \ {}" instance proof show "\ X \ x" if "x \ X" "bdd_below X" for x :: V and X :: "V set" using that by (auto simp: bdd_below_V_def Inf_V_def split: if_split_asm) show "z \ \ X" if "X \ {}" "\x. x \ X \ z \ x" for X :: "V set" and z :: V using that apply (clarsimp simp add: bdd_below_V_def Inf_V_def less_eq_V_def split: if_split_asm) by (meson INT_subset_iff down eq_refl equals0I) show "x \ \ X" if "x \ X" and "bdd_above X" for x :: V and X :: "V set" using that Sup_V_def by auto show "\ X \ (z::V)" if "X \ {}" "\x. x \ X \ x \ z" for X :: "V set" and z :: V using that by (simp add: SUP_least Sup_V_def less_eq_V_def) qed end lemma Sup_upper: "\x \ A; small A\ \ x \ \A" for A::"V set" by (auto simp: Sup_V_def SUP_upper Union less_eq_V_def) lemma Sup_least: fixes z::V shows "(\x. x \ A \ x \ z) \ \A \ z" by (auto simp: Sup_V_def SUP_least less_eq_V_def) lemma Sup_empty [simp]: "\{} = (0::V)" using Sup_V_def by auto lemma elts_Sup [simp]: "small X \ elts (\ X) = \(elts ` X)" by (auto simp: Sup_V_def) lemma sup_V_0_left [simp]: "0 \ a = a" and sup_V_0_right [simp]: "a \ 0 = a" for a::V by auto lemma Sup_V_insert: fixes x::V assumes "small A" shows "\(insert x A) = x \ \A" by (simp add: assms cSup_insert_If) lemma Sup_Un_distrib: "\small A; small B\ \ \(A \ B) = \A \ \B" for A::"V set" by auto lemma SUP_sup_distrib: fixes f :: "V \ V" - shows "small A \ (SUP x\A. f x \ g x) = \ (f ` A) \ \ (g ` A)" + shows "small A \ (\x\A. f x \ g x) = \ (f ` A) \ \ (g ` A)" by (force simp:) -lemma SUP_const [simp]: "(SUP y \ A. a) = (if A = {} then (0::V) else a)" +lemma SUP_const [simp]: "(\y \ A. a) = (if A = {} then (0::V) else a)" by simp lemma cSUP_subset_mono: fixes f :: "'a \ V set" and g :: "'a \ V set" shows "\A \ B; \x. x \ A \ f x \ g x\ \ \ (f ` A) \ \ (g ` B)" by (simp add: SUP_subset_mono) lemma mem_Sup_iff [iff]: "x \ elts (\X) \ x \ \ (elts ` X) \ small X" using Sup_V_def by auto lemma cSUP_UNION: fixes B :: "V \ V set" and f :: "V \ V" assumes ne: "small A" and bdd_UN: "small (\x\A. f ` B x)" shows "\(f ` (\x\A. B x)) = \((\x. \(f ` B x)) ` A)" proof - have bdd: "\x. x \ A \ small (f ` B x)" using bdd_UN subset_iff_less_eq_V by (meson SUP_upper smaller_than_small) then have bdd2: "small ((\x. \(f ` B x)) ` A)" using ne(1) by blast have "\(f ` (\x\A. B x)) \ \((\x. \(f ` B x)) ` A)" using assms by (fastforce simp add: intro!: cSUP_least intro: cSUP_upper2 simp: bdd2 bdd) moreover have "\((\x. \(f ` B x)) ` A) \ \(f ` (\x\A. B x))" using assms by (fastforce simp add: intro!: cSUP_least intro: cSUP_upper simp: image_UN bdd_UN) ultimately show ?thesis by (rule order_antisym) qed lemma Sup_subset_mono: "small B \ A \ B \ Sup A \ Sup B" for A::"V set" by auto lemma Sup_le_iff: "small A \ Sup A \ a \ (\x\A. x \ a)" for A::"V set" by auto lemma SUP_le_iff: "small (f ` A) \ \(f ` A) \ u \ (\x\A. f x \ u)" for f :: "V \ V" by blast lemma Sup_eq_0_iff [simp]: "\A = 0 \ A \ {0} \ \ small A" for A :: "V set" using Sup_upper by fastforce lemma Sup_Union_commute: fixes f :: "V \ V set" assumes "small A" "\x. x\A \ small (f x)" - shows "\ (\x\A. f x) = (SUP x\A. \ (f x))" + shows "\ (\x\A. f x) = (\x\A. \ (f x))" using assms by (force simp: subset_iff_less_eq_V intro!: antisym) lemma Sup_eq_Sup: fixes B :: "V set" assumes "B \ A" "small A" and *: "\x. x \ A \ \y \ B. x \ y" shows "Sup A = Sup B" proof - have "small B" using assms subset_iff_less_eq_V by auto moreover have "\y\B. u \ elts y" if "x \ A" "u \ elts x" for u x using that "*" by blast moreover have "\x\A. v \ elts x" if "y \ B" "v \ elts y" for v y using that \B \ A\ by blast ultimately show ?thesis using assms by auto qed subsection\Successor function\ lemma vinsert_not_empty [simp]: "vinsert a A \ 0" and empty_not_vinsert [simp]: "0 \ vinsert a A" by (auto simp: vinsert_def) lemma succ_not_0 [simp]: "succ n \ 0" and zero_not_succ [simp]: "0 \ succ n" by (auto simp: succ_def) instantiation V :: zero_neq_one begin instance by intro_classes (metis elts_0 elts_succ empty_iff insert_iff one_V_def set_of_elts) end instantiation V :: zero_less_one begin instance by intro_classes (simp add: less_V_def) end lemma succ_ne_self [simp]: "i \ succ i" by (metis elts_succ insertI1 mem_not_refl) lemma succ_notin_self: "succ i \ elts i" using elts_succ mem_not_refl by blast lemma le_succE: "succ i \ succ j \ i \ j" using less_eq_V_def mem_not_sym by auto lemma succ_inject_iff [iff]: "succ i = succ j \ i = j" by (simp add: dual_order.antisym le_succE) lemma inj_succ: "inj succ" by (simp add: inj_def) lemma succ_neq_zero: "succ x \ 0" by (metis elts_0 elts_succ insert_not_empty) definition pred where "pred i \ THE j. i = succ j" lemma pred_succ [simp]: "pred (succ i) = i" by (simp add: pred_def) subsection \Ordinals\ definition Transset where "Transset x \ \y \ elts x. y \ x" definition Ord where "Ord x \ Transset x \ (\y \ elts x. Transset y)" abbreviation ON where "ON \ Collect Ord" subsubsection \Transitive sets\ lemma Transset_0 [iff]: "Transset 0" by (auto simp: Transset_def) lemma Transset_succ [intro]: assumes "Transset x" shows "Transset (succ x)" using assms by (auto simp: Transset_def succ_def less_eq_V_def) lemma Transset_Sup: assumes "\x. x \ X \ Transset x" shows "Transset (\X)" proof (cases "small X") case True with assms show ?thesis by (simp add: Transset_def) (meson Sup_upper assms dual_order.trans) qed (simp add: Sup_V_def) lemma Transset_sup: assumes "Transset x" "Transset y" shows "Transset (x \ y)" using Transset_def assms by fastforce lemma Transset_inf: "\Transset i; Transset j\ \ Transset (i \ j)" by (simp add: Transset_def rev_vsubsetD) lemma Transset_VPow: "Transset(i) \ Transset(VPow(i))" by (auto simp: Transset_def) lemma Transset_Inf: "(\i. i \ A \ Transset i) \ Transset (\ A)" by (force simp: Transset_def Inf_V_def) lemma Transset_SUP: "(\x. x \ A \ Transset (B x)) \ Transset (\ (B ` A))" by (metis Transset_Sup imageE) lemma Transset_INT: "(\x. x \ A \ Transset (B x)) \ Transset (\ (B ` A))" by (metis Transset_Inf imageE) subsubsection \Zero, successor, sups\ lemma Ord_0 [iff]: "Ord 0" by (auto simp: Ord_def) lemma Ord_succ [intro]: assumes "Ord x" shows "Ord (succ x)" using assms by (auto simp: Ord_def) lemma Ord_Sup: assumes "\x. x \ X \ Ord x" shows "Ord (\X)" proof (cases "small X") case True with assms show ?thesis by (auto simp: Ord_def Transset_Sup) qed (simp add: Sup_V_def) lemma Ord_Union: assumes "\x. x \ X \ Ord x" "small X" shows "Ord (set (\ (elts ` X)))" by (metis Ord_Sup Sup_V_def assms) lemma Ord_sup: assumes "Ord x" "Ord y" shows "Ord (x \ y)" using assms proof (clarsimp simp: Ord_def) show "Transset (x \ y) \ (\y\elts x \ elts y. Transset y)" if "Transset x" "Transset y" "\y\elts x. Transset y" "\y\elts y. Transset y" using Ord_def Transset_sup assms by auto qed lemma big_ON [simp]: "\ small ON" proof assume "small ON" then have "set ON \ ON" by (metis Ord_Union Ord_succ Sup_upper elts_Sup elts_succ insertI1 mem_Collect_eq mem_not_refl set_of_elts vsubsetD) then show False by (metis \small ON\ elts_of_set mem_not_refl) qed lemma Ord_1 [iff]: "Ord 1" using Ord_succ one_V_def succ_def vinsert_def by fastforce lemma OrdmemD: "Ord k \ j \ elts k \ j < k" using Ord_def Transset_def less_V_def by auto lemma Ord_trans: "\ i \ elts j; j \ elts k; Ord k \ \ i \ elts k" using Ord_def Transset_def by blast lemma mem_0_Ord: assumes k: "Ord k" and knz: "k \ 0" shows "0 \ elts k" by (metis Ord_def Transset_def inf.orderE k knz trad_foundation) lemma Ord_in_Ord: "\ Ord k; m \ elts k \ \ Ord m" using Ord_def Ord_trans by blast lemma OrdI: "\Transset i; \x. x \ elts i \ Transset x\ \ Ord i" by (simp add: Ord_def) lemma Ord_is_Transset: "Ord i \ Transset i" by (simp add: Ord_def) lemma Ord_contains_Transset: "\Ord i; j \ elts i\ \ Transset j" using Ord_def by blast lemma ON_imp_Ord: assumes "H \ ON" "x \ H" shows "Ord x" using assms by blast lemma elts_subset_ON: "Ord \ \ elts \ \ ON" using Ord_in_Ord by blast lemma Transset_pred [simp]: "Transset x \ \(elts (succ x)) = x" by (fastforce simp: Transset_def) lemma Ord_pred [simp]: "Ord \ \ \ (insert \ (elts \)) = \" using Ord_def Transset_pred by auto subsubsection \Induction, Linearity, etc.\ lemma Ord_induct [consumes 1, case_names step]: assumes k: "Ord k" and step: "\x.\ Ord x; \y. y \ elts x \ P y \ \ P x" shows "P k" using foundation k proof (induction k rule: wf_induct_rule) case (less x) then show ?case using Ord_in_Ord local.step by auto qed text \Comparability of ordinals\ lemma Ord_linear: "Ord k \ Ord l \ k \ elts l \ k=l \ l \ elts k" proof (induct k arbitrary: l rule: Ord_induct) case (step k) note step_k = step show ?case using \Ord l\ proof (induct l rule: Ord_induct) case (step l) thus ?case using step_k by (metis Ord_trans V_equalityI) qed qed text \The trichotomy law for ordinals\ lemma Ord_linear_lt: assumes "Ord k" "Ord l" obtains (lt) "k < l" | (eq) "k=l" | (gt) "l < k" using Ord_linear OrdmemD assms by blast lemma Ord_linear2: assumes "Ord k" "Ord l" obtains (lt) "k < l" | (ge) "l \ k" by (metis Ord_linear_lt eq_refl assms order.strict_implies_order) lemma Ord_linear_le: assumes "Ord k" "Ord l" obtains (le) "k \ l" | (ge) "l \ k" by (meson Ord_linear2 le_less assms) lemma union_less_iff [simp]: "\Ord i; Ord j\ \ i \ j < k \ i j Ord l \ k \ elts l \ k < l" by (metis Ord_linear OrdmemD less_le_not_le) lemma Ord_Collect_lt: "Ord \ \ {\. Ord \ \ \ < \} = elts \" by (auto simp flip: Ord_mem_iff_lt elim: Ord_in_Ord OrdmemD) lemma Ord_not_less: "\Ord x; Ord y\ \ \ x < y \ y \ x" by (metis (no_types) Ord_linear2 leD) lemma Ord_not_le: "\Ord x; Ord y\ \ \ x \ y \ y < x" by (metis (no_types) Ord_linear2 leD) lemma le_succ_iff: "Ord i \ Ord j \ succ i \ succ j \ i \ j" by (metis Ord_linear_le Ord_succ le_succE order_antisym) lemma succ_le_iff: "Ord i \ Ord j \ succ i \ j \ i < j" using Ord_mem_iff_lt dual_order.strict_implies_order less_eq_V_def by fastforce lemma succ_in_Sup_Ord: assumes eq: "succ \ = \A" and "small A" "A \ ON" "Ord \" shows "succ \ \ A" proof - have "\ \A \ \" using eq \Ord \\ succ_le_iff by fastforce then show ?thesis using assms by (metis Ord_linear2 Sup_least Sup_upper eq_iff mem_Collect_eq subsetD succ_le_iff) qed lemma in_succ_iff: "Ord i \ j \ elts (ZFC_in_HOL.succ i) \ Ord j \ j \ i" by (metis Ord_in_Ord Ord_mem_iff_lt Ord_not_le Ord_succ succ_le_iff) lemma zero_in_succ [simp,intro]: "Ord i \ 0 \ elts (succ i)" using mem_0_Ord by auto lemma Ord_finite_Sup: "\finite A; A \ ON; A \ {}\ \ \A \ A" proof (induction A rule: finite_induct) case (insert x A) then have *: "small A" "A \ ON" "Ord x" by (auto simp add: ZFC_in_HOL.finite_imp_small insert.hyps) show ?case proof (cases "A = {}") case False then have "\A \ A" using insert by blast then have "\A \ x" if "x \ \A \ A" using * by (metis ON_imp_Ord Ord_linear_le sup.absorb2 that) then show ?thesis by (fastforce simp: \small A\ Sup_V_insert) qed auto qed auto subsubsection \The natural numbers\ primrec ord_of_nat :: "nat \ V" where "ord_of_nat 0 = 0" | "ord_of_nat (Suc n) = succ (ord_of_nat n)" lemma ord_of_nat_eq_initial: "ord_of_nat n = set (ord_of_nat ` {.. elts (ord_of_nat n) \ (\m i = \ (succ ` elts i)" by (force intro: Ord_trans) lemma Ord_ord_of_nat [simp]: "Ord (ord_of_nat k)" by (induct k, auto) lemma ord_of_nat_equality: "ord_of_nat n = \ ((succ \ ord_of_nat) ` {.. :: V where "\ \ set (range ord_of_nat)" lemma elts_\: "elts \ = {\. \n. \ = ord_of_nat n}" by (auto simp: \_def image_iff) lemma nat_into_Ord [simp]: "n \ elts \ \ Ord n" by (metis Ord_ord_of_nat \_def elts_of_set image_iff inf) lemma Sup_\: "\(elts \) = \" unfolding \_def by force lemma Ord_\ [iff]: "Ord \" by (metis Ord_Sup Sup_\ nat_into_Ord) lemma zero_in_omega [iff]: "0 \ elts \" by (metis \_def elts_of_set inf ord_of_nat.simps(1) rangeI) lemma succ_in_omega [simp]: "n \ elts \ \ succ n \ elts \" by (metis \_def elts_of_set image_iff small_image_nat_V ord_of_nat.simps(2) rangeI) lemma ord_of_eq_0: "ord_of_nat j = 0 \ j = 0" by (induct j) (auto simp: succ_neq_zero) lemma ord_of_nat_le_omega: "ord_of_nat n \ \" by (metis Sup_\ ZFC_in_HOL.Sup_upper \_def elts_of_set inf rangeI) lemma ord_of_eq_0_iff [simp]: "ord_of_nat n = 0 \ n=0" by (auto simp: ord_of_eq_0) lemma ord_of_nat_inject [iff]: "ord_of_nat i = ord_of_nat j \ i=j" proof (induct i arbitrary: j) case 0 show ?case using ord_of_eq_0 by auto next case (Suc i) then show ?case by auto (metis elts_0 elts_succ insert_not_empty not0_implies_Suc ord_of_nat.simps succ_inject_iff) qed corollary inj_ord_of_nat: "inj ord_of_nat" by (simp add: linorder_injI) corollary countable: assumes "countable X" shows "small X" proof - have "X \ range (from_nat_into X)" by (simp add: assms subset_range_from_nat_into) then show ?thesis by (meson inf_raw inj_ord_of_nat replacement small_def smaller_than_small) qed corollary infinite_\: "infinite (elts \)" using range_inj_infinite [of ord_of_nat] by (simp add: \_def inj_ord_of_nat) corollary ord_of_nat_mono_iff [iff]: "ord_of_nat i \ ord_of_nat j \ i \ j" by (metis Ord_def Ord_ord_of_nat Transset_def eq_iff mem_ord_of_nat_iff not_less ord_of_nat_inject) corollary ord_of_nat_strict_mono_iff [iff]: "ord_of_nat i < ord_of_nat j \ i < j" by (simp add: less_le_not_le) lemma small_image_nat [simp]: fixes N :: "nat set" shows "small (g ` N)" by (simp add: countable) lemma finite_Ord_omega: "\ \ elts \ \ finite (elts \)" proof (clarsimp simp add: \_def) show "finite (elts (ord_of_nat n))" if "\ = ord_of_nat n" for n using that by (simp add: ord_of_nat_eq_initial [of n]) qed lemma infinite_Ord_omega: "Ord \ \ infinite (elts \) \ \ \ \" by (meson Ord_\ Ord_linear2 Ord_mem_iff_lt finite_Ord_omega) lemma ord_of_minus_1: "n > 0 \ ord_of_nat n = succ (ord_of_nat (n - 1))" by (metis Suc_diff_1 ord_of_nat.simps(2)) lemma card_ord_of_nat [simp]: "card (elts (ord_of_nat m)) = m" by (induction m) (auto simp: \_def finite_Ord_omega) lemma ord_of_nat_\ [iff]:"ord_of_nat n \ elts \" by (simp add: \_def) lemma succ_\_iff [iff]: "succ n \ elts \ \ n \ elts \" by (metis Ord_\ OrdmemD elts_vinsert insert_iff less_V_def succ_def succ_in_omega vsubsetD) lemma \_gt0 [simp]: "\ > 0" by (simp add: OrdmemD) lemma \_gt1 [simp]: "\ > 1" by (simp add: OrdmemD one_V_def) subsubsection\Limit ordinals\ definition Limit :: "V\bool" where "Limit i \ Ord i \ 0 \ elts i \ (\y. y \ elts i \ succ y \ elts i)" lemma zero_not_Limit [iff]: "\ Limit 0" by (simp add: Limit_def) lemma not_succ_Limit [simp]: "\ Limit(succ i)" by (metis Limit_def Ord_mem_iff_lt elts_succ insertI1 less_irrefl) lemma Limit_is_Ord: "Limit \ \ Ord \" by (simp add: Limit_def) lemma succ_in_Limit_iff: "Limit \ \ succ \ \ elts \ \ \ \ elts \" by (metis Limit_def OrdmemD elts_succ insertI1 less_V_def vsubsetD) lemma Limit_eq_Sup_self [simp]: "Limit i \ Sup (elts i) = i" apply (rule order_antisym) apply (simp add: Limit_def Ord_def Transset_def Sup_least) by (metis Limit_def Ord_equality Sup_V_def SUP_le_iff Sup_upper small_elts) lemma zero_less_Limit: "Limit \ \ 0 < \" by (simp add: Limit_def OrdmemD) lemma non_Limit_ord_of_nat [iff]: "\ Limit (ord_of_nat m)" by (metis Limit_def mem_ord_of_nat_iff not_succ_Limit ord_of_eq_0_iff ord_of_minus_1) lemma Limit_omega [iff]: "Limit \" by (simp add: Limit_def) lemma omega_nonzero [simp]: "\ \ 0" using Limit_omega by fastforce lemma Ord_cases_lemma: assumes "Ord k" shows "k = 0 \ (\j. k = succ j) \ Limit k" proof (cases "Limit k") case False have "succ j \ elts k" if "\j. k \ succ j" "j \ elts k" for j by (metis Ord_in_Ord Ord_linear Ord_succ assms elts_succ insertE mem_not_sym that) with assms show ?thesis by (auto simp: Limit_def mem_0_Ord) qed auto lemma Ord_cases [cases type: V, case_names 0 succ limit]: assumes "Ord k" obtains "k = 0" | l where "Ord l" "succ l = k" | "Limit k" by (metis assms Ord_cases_lemma Ord_in_Ord elts_succ insertI1) lemma non_succ_LimitI: assumes "i\0" "Ord(i)" "\y. succ(y) \ i" shows "Limit(i)" using Ord_cases_lemma assms by blast lemma Ord_induct3 [consumes 1, case_names 0 succ Limit, induct type: V]: assumes \: "Ord \" and P: "P 0" "\\. \Ord \; P \\ \ P (succ \)" - "\\. \Limit \; \\. \ \ elts \ \ P \\ \ P (SUP \ \ elts \. \)" + "\\. \Limit \; \\. \ \ elts \ \ P \\ \ P (\\ \ elts \. \)" shows "P \" using \ proof (induction \ rule: Ord_induct) case (step \) then show ?case by (metis Limit_eq_Sup_self Ord_cases P elts_succ image_ident insertI1) qed subsubsection\Properties of LEAST for ordinals\ lemma assumes "Ord k" "P k" shows Ord_LeastI: "P (LEAST i. Ord i \ P i)" and Ord_Least_le: "(LEAST i. Ord i \ P i) \ k" proof - have "P (LEAST i. Ord i \ P i) \ (LEAST i. Ord i \ P i) \ k" using assms proof (induct k rule: Ord_induct) case (step x) then have "P x" by simp show ?case proof (rule classical) assume assm: "\ (P (LEAST a. Ord a \ P a) \ (LEAST a. Ord a \ P a) \ x)" have "\y. Ord y \ P y \ x \ y" proof (rule classical) fix y assume y: "Ord y \ P y" "\ x \ y" with step obtain "P (LEAST a. Ord a \ P a)" and le: "(LEAST a. Ord a \ P a) \ y" by (meson Ord_linear2 Ord_mem_iff_lt) with assm have "x < (LEAST a. Ord a \ P a)" by (meson Ord_linear_le y order.trans \Ord x\) then show "x \ y" using le by auto qed then have Least: "(LEAST a. Ord a \ P a) = x" by (simp add: Least_equality \Ord x\ step.prems) with \P x\ show ?thesis by simp qed qed then show "P (LEAST i. Ord i \ P i)" and "(LEAST i. Ord i \ P i) \ k" by auto qed lemma Ord_Least: assumes "Ord k" "P k" shows "Ord (LEAST i. Ord i \ P i)" proof - have "Ord (LEAST i. Ord i \ (Ord i \ P i))" using Ord_LeastI [where P = "\i. Ord i \ P i"] assms by blast then show ?thesis by simp qed \ \The following 3 lemmas are due to Brian Huffman\ lemma Ord_LeastI_ex: "\i. Ord i \ P i \ P (LEAST i. Ord i \ P i)" using Ord_LeastI by blast lemma Ord_LeastI2: "\Ord a; P a; \x. \Ord x; P x\ \ Q x\ \ Q (LEAST i. Ord i \ P i)" by (blast intro: Ord_LeastI Ord_Least) lemma Ord_LeastI2_ex: "\a. Ord a \ P a \ (\x. \Ord x; P x\ \ Q x) \ Q (LEAST i. Ord i \ P i)" by (blast intro: Ord_LeastI_ex Ord_Least) lemma Ord_LeastI2_wellorder: assumes "Ord a" "P a" and "\a. \ P a; \b. Ord b \ P b \ a \ b \ \ Q a" shows "Q (LEAST i. Ord i \ P i)" proof (rule LeastI2_order) show "Ord (LEAST i. Ord i \ P i) \ P (LEAST i. Ord i \ P i)" using Ord_Least Ord_LeastI assms by auto next fix y assume "Ord y \ P y" thus "(LEAST i. Ord i \ P i) \ y" by (simp add: Ord_Least_le) next fix x assume "Ord x \ P x" "\y. Ord y \ P y \ x \ y" thus "Q x" by (simp add: assms(3)) qed lemma Ord_LeastI2_wellorder_ex: assumes "\x. Ord x \ P x" and "\a. \ P a; \b. Ord b \ P b \ a \ b \ \ Q a" shows "Q (LEAST i. Ord i \ P i)" using assms by clarify (blast intro!: Ord_LeastI2_wellorder) lemma not_less_Ord_Least: "\k < (LEAST x. Ord x \ P x); Ord k\ \ \ P k" using Ord_Least_le less_le_not_le by auto lemma exists_Ord_Least_iff: "(\\. Ord \ \ P \) \ (\\. Ord \ \ P \ \ (\\ < \. Ord \ \ \ P \))" (is "?lhs \ ?rhs") proof assume ?rhs thus ?lhs by blast next assume H: ?lhs then obtain \ where \: "Ord \" "P \" by blast let ?x = "LEAST \. Ord \ \ P \" have "Ord ?x" by (metis Ord_Least \) moreover { fix \ assume m: "\ < ?x" "Ord \" from not_less_Ord_Least[OF m] have "\ P \" . } ultimately show ?rhs using Ord_LeastI_ex[OF H] by blast qed lemma Ord_mono_imp_increasing: assumes fun_hD: "h \ D \ D" and mono_h: "strict_mono_on h D" and "D \ ON" and \: "\ \ D" shows "\ \ h \" proof (rule ccontr) assume non: "\ \ \ h \" define \ where "\ \ LEAST \. Ord \ \ \ \ \ h \ \ \ \ D" have "Ord \" using \ \D \ ON\ by blast then have \: "\ \ \ h \ \ \ \ D" unfolding \_def by (rule Ord_LeastI) (simp add: \ non) have "Ord (h \)" using assms by auto then have "Ord (h (h \))" by (meson ON_imp_Ord \ assms funcset_mem) have "Ord \" using \ \D \ ON\ by blast then have "h \ < \" by (metis ON_imp_Ord Ord_linear2 PiE \ \D \ ON\ fun_hD) then have "\ h \ \ h (h \)" using \ fun_hD mono_h by (force simp: strict_mono_on_def) moreover have *: "h \ \ D" using \ fun_hD by auto moreover have "Ord (h \)" using \D \ ON\ * by blast ultimately have "\ \ h \" by (simp add: \_def Ord_Least_le) then show False using \ by blast qed lemma le_Sup_iff: assumes "A \ ON" "Ord x" "small A" shows "x \ \A \ (\y \ ON. y (\a\A. y < a))" proof (intro iffI ballI impI) show "\a\A. y < a" if "x \ \ A" "y \ ON" "y < x" for y proof - have "\ \ A \ y" "Ord y" using that by auto then show ?thesis by (metis Ord_linear2 Sup_least \A \ ON\ mem_Collect_eq subset_eq) qed show "x \ \ A" if "\y\ON. y < x \ (\a\A. y < a)" using that assms by (metis Ord_Sup Ord_linear_le Sup_upper less_le_not_le mem_Collect_eq subsetD) qed lemma le_SUP_iff: "\f ` A \ ON; Ord x; small A\ \ x \ \(f ` A) \ (\y \ ON. y (\i\A. y < f i))" by (simp add: le_Sup_iff) subsection\Transfinite Recursion and the V-levels\ definition transrec :: "[[V\V,V]\V, V] \ V" where "transrec H a \ wfrec {(x,y). x \ elts y} H a" lemma transrec: "transrec H a = H (\x \ elts a. transrec H x) a" proof - have "(cut (wfrec {(x, y). x \ elts y} H) {(x, y). x \ elts y} a) = (\x\elts a. wfrec {(x, y). x \ elts y} H x)" by (force simp: cut_def) then show ?thesis unfolding transrec_def by (simp add: foundation wfrec) qed text\Avoids explosions in proofs; resolve it with a meta-level definition\ lemma def_transrec: "\\x. f x \ transrec H x\ \ f a = H(\x \ elts a. f x) a" by (metis restrict_ext transrec) lemma eps_induct [case_names step]: assumes "\x. (\y. y \ elts x \ P y) \ P x" shows "P a" using wf_induct [OF foundation] assms by auto definition Vfrom :: "[V,V] \ V" where "Vfrom a \ transrec (\f x. a \ \((\y. VPow(f y)) ` elts x))" abbreviation Vset :: "V \ V" where "Vset \ Vfrom 0" lemma Vfrom: "Vfrom a i = a \ \((\j. VPow(Vfrom a j)) ` elts i)" apply (subst Vfrom_def) apply (subst transrec) using Vfrom_def by auto lemma Vfrom_0 [simp]: "Vfrom a 0 = a" by (subst Vfrom) auto lemma Vset: "Vset i = \((\j. VPow(Vset j)) ` elts i)" by (subst Vfrom) auto lemma Vfrom_mono1: assumes "a \ b" shows "Vfrom a i \ Vfrom b i" proof (induction i rule: eps_induct) case (step i) - then have "a \ (SUP j\elts i. VPow (Vfrom a j)) \ b \ (SUP j\elts i. VPow (Vfrom b j))" + then have "a \ (\j\elts i. VPow (Vfrom a j)) \ b \ (\j\elts i. VPow (Vfrom b j))" by (intro sup_mono cSUP_subset_mono \a \ b\) auto then show ?case by (metis Vfrom) qed lemma Vfrom_mono2: "Vfrom a i \ Vfrom a (i \ j)" proof (induction arbitrary: j rule: eps_induct) case (step i) - then have "a \ (SUP j\elts i. VPow (Vfrom a j)) - \ a \ (SUP j\elts (i \ j). VPow (Vfrom a j))" + then have "a \ (\j\elts i. VPow (Vfrom a j)) + \ a \ (\j\elts (i \ j). VPow (Vfrom a j))" by (intro sup_mono cSUP_subset_mono order_refl) auto then show ?case by (metis Vfrom) qed lemma Vfrom_mono: "\Ord i; a\b; i\j\ \ Vfrom a i \ Vfrom b j" by (metis (no_types) Vfrom_mono1 Vfrom_mono2 dual_order.trans sup.absorb_iff2) lemma Transset_Vfrom: "Transset(A) \ Transset(Vfrom A i)" proof (induction i rule: eps_induct) case (step i) then show ?case by (metis Transset_SUP Transset_VPow Transset_sup Vfrom) qed lemma Transset_Vset [simp]: "Transset(Vset i)" by (simp add: Transset_Vfrom) lemma Vfrom_sup: "Vfrom a (i \ j) = Vfrom a i \ Vfrom a j" proof (rule order_antisym) show "Vfrom a (i \ j) \ Vfrom a i \ Vfrom a j" by (simp add: Vfrom [of a "i \ j"] Vfrom [of a i] Vfrom [of a j] Sup_Un_distrib image_Un sup.assoc sup.left_commute) show "Vfrom a i \ Vfrom a j \ Vfrom a (i \ j)" by (metis Vfrom_mono2 le_supI sup_commute) qed lemma Vfrom_succ_Ord: assumes "Ord i" shows "Vfrom a (succ i) = a \ VPow(Vfrom a i)" proof (cases "i = 0") case True then show ?thesis by (simp add: Vfrom [of _ "succ 0"]) next case False - have *: "(SUP x\elts i. VPow (Vfrom a x)) \ VPow (Vfrom a i)" + have *: "(\x\elts i. VPow (Vfrom a x)) \ VPow (Vfrom a i)" proof (rule cSup_least) show "(\x. VPow (Vfrom a x)) ` elts i \ {}" using False by auto show "x \ VPow (Vfrom a i)" if "x \ (\x. VPow (Vfrom a x)) ` elts i" for x using that by clarsimp (meson Ord_in_Ord Ord_linear_le Vfrom_mono assms mem_not_refl order_refl vsubsetD) qed show ?thesis proof (rule Vfrom [THEN trans]) - show "a \ (SUP j\elts (succ i). VPow (Vfrom a j)) = a \ VPow (Vfrom a i)" + show "a \ (\j\elts (succ i). VPow (Vfrom a j)) = a \ VPow (Vfrom a i)" using assms by (intro sup_mono order_antisym) (auto simp: Sup_V_insert *) qed qed lemma Vset_succ: "Ord i \ Vset(succ(i)) = VPow(Vset(i))" by (simp add: Vfrom_succ_Ord) lemma Vfrom_Sup: assumes "X \ {}" "small X" - shows "Vfrom a (Sup X) = (SUP y\X. Vfrom a y)" + shows "Vfrom a (Sup X) = (\y\X. Vfrom a y)" proof (rule order_antisym) - have "Vfrom a (\ X) = a \ (SUP j\elts (\ X). VPow (Vfrom a j))" + have "Vfrom a (\ X) = a \ (\j\elts (\ X). VPow (Vfrom a j))" by (metis Vfrom) also have "\ \ \ (Vfrom a ` X)" proof - have "a \ \ (Vfrom a ` X)" by (metis Vfrom all_not_in_conv assms bdd_above_iff_small cSUP_upper2 replacement sup_ge1) - moreover have "(SUP j\elts (\ X). VPow (Vfrom a j)) \ \ (Vfrom a ` X)" + moreover have "(\j\elts (\ X). VPow (Vfrom a j)) \ \ (Vfrom a ` X)" proof - have "VPow (Vfrom a x) \ \ (Vfrom a ` X)" if "y \ X" "x \ elts y" for x y proof - have "VPow (Vfrom a x) \ Vfrom a y" by (metis Vfrom bdd_above_iff_small cSUP_upper2 le_supI2 order_refl replacement small_elts that(2)) also have "\ \ \ (Vfrom a ` X)" using assms that by (force intro: cSUP_upper) finally show ?thesis . qed then show ?thesis by (simp add: SUP_le_iff \small X\) qed ultimately show ?thesis by auto qed finally show "Vfrom a (\ X) \ \ (Vfrom a ` X)" . have "\x. x \ X \ - a \ (SUP j\elts x. VPow (Vfrom a j)) - \ a \ (SUP j\elts (\ X). VPow (Vfrom a j))" + a \ (\j\elts x. VPow (Vfrom a j)) + \ a \ (\j\elts (\ X). VPow (Vfrom a j))" using cSUP_subset_mono \small X\ by auto then show "\ (Vfrom a ` X) \ Vfrom a (\ X)" by (metis Vfrom assms(1) cSUP_least) qed lemma Limit_Vfrom_eq: - "Limit(i) \ Vfrom a i = (SUP y \ elts i. Vfrom a y)" + "Limit(i) \ Vfrom a i = (\y \ elts i. Vfrom a y)" by (metis Limit_def Limit_eq_Sup_self Vfrom_Sup ex_in_conv small_elts) end