# HG changeset patch # User eberlm # Date 1500151224 -3600 # Node ID 6ad54b84ca5ddd529fc3430cf54bc7913ed56e3a # Parent 0c5eb47e2696f5c81c691931f70f2f3b14b5d0c0 facts about cardinality of vector type diff -r 0c5eb47e2696 -r 6ad54b84ca5d src/HOL/Analysis/Finite_Cartesian_Product.thy --- a/src/HOL/Analysis/Finite_Cartesian_Product.thy Sat Jul 15 16:27:10 2017 +0100 +++ b/src/HOL/Analysis/Finite_Cartesian_Product.thy Sat Jul 15 21:40:24 2017 +0100 @@ -9,6 +9,8 @@ Euclidean_Space L2_Norm "~~/src/HOL/Library/Numeral_Type" + "~~/src/HOL/Library/Countable_Set" + "~~/src/HOL/Library/FuncSet" begin subsection \Finite Cartesian products, with indexing and lambdas.\ @@ -55,6 +57,80 @@ lemma vec_lambda_eta: "(\ i. (g$i)) = g" by (simp add: vec_eq_iff) +subsection \Cardinality of vectors\ + +instance vec :: (finite, finite) finite +proof + show "finite (UNIV :: ('a, 'b) vec set)" + proof (subst bij_betw_finite) + show "bij_betw vec_nth UNIV (Pi (UNIV :: 'b set) (\_. UNIV :: 'a set))" + by (intro bij_betwI[of _ _ _ vec_lambda]) (auto simp: vec_eq_iff) + have "finite (PiE (UNIV :: 'b set) (\_. UNIV :: 'a set))" + by (intro finite_PiE) auto + also have "(PiE (UNIV :: 'b set) (\_. UNIV :: 'a set)) = Pi UNIV (\_. UNIV)" + by auto + finally show "finite \" . + qed +qed + +lemma countable_PiE: + "finite I \ (\i. i \ I \ countable (F i)) \ countable (Pi\<^sub>E I F)" + by (induct I arbitrary: F rule: finite_induct) (auto simp: PiE_insert_eq) + +instance vec :: (countable, finite) countable +proof + have "countable (UNIV :: ('a, 'b) vec set)" + proof (rule countableI_bij2) + show "bij_betw vec_nth UNIV (Pi (UNIV :: 'b set) (\_. UNIV :: 'a set))" + by (intro bij_betwI[of _ _ _ vec_lambda]) (auto simp: vec_eq_iff) + have "countable (PiE (UNIV :: 'b set) (\_. UNIV :: 'a set))" + by (intro countable_PiE) auto + also have "(PiE (UNIV :: 'b set) (\_. UNIV :: 'a set)) = Pi UNIV (\_. UNIV)" + by auto + finally show "countable \" . + qed + thus "\t::('a, 'b) vec \ nat. inj t" + by (auto elim!: countableE) +qed + +lemma infinite_UNIV_vec: + assumes "infinite (UNIV :: 'a set)" + shows "infinite (UNIV :: ('a, 'b :: finite) vec set)" +proof (subst bij_betw_finite) + show "bij_betw vec_nth UNIV (Pi (UNIV :: 'b set) (\_. UNIV :: 'a set))" + by (intro bij_betwI[of _ _ _ vec_lambda]) (auto simp: vec_eq_iff) + have "infinite (PiE (UNIV :: 'b set) (\_. UNIV :: 'a set))" (is "infinite ?A") + proof + assume "finite ?A" + hence "finite ((\f. f undefined) ` ?A)" + by (rule finite_imageI) + also have "(\f. f undefined) ` ?A = UNIV" + by auto + finally show False + using \infinite (UNIV :: 'a set)\ by contradiction + qed + also have "?A = Pi UNIV (\_. UNIV)" + by auto + finally show "infinite (Pi (UNIV :: 'b set) (\_. UNIV :: 'a set))" . +qed + +lemma CARD_vec [simp]: + "CARD(('a,'b::finite) vec) = CARD('a) ^ CARD('b)" +proof (cases "finite (UNIV :: 'a set)") + case True + show ?thesis + proof (subst bij_betw_same_card) + show "bij_betw vec_nth UNIV (Pi (UNIV :: 'b set) (\_. UNIV :: 'a set))" + by (intro bij_betwI[of _ _ _ vec_lambda]) (auto simp: vec_eq_iff) + have "CARD('a) ^ CARD('b) = card (PiE (UNIV :: 'b set) (\_. UNIV :: 'a set))" + (is "_ = card ?A") + by (subst card_PiE) (auto simp: prod_constant) + + also have "?A = Pi UNIV (\_. UNIV)" + by auto + finally show "card \ = CARD('a) ^ CARD('b)" .. + qed +qed (simp_all add: infinite_UNIV_vec) subsection \Group operations and class instances\