src/HOL/Probability/Discrete_Topology.thy
 author haftmann Sun Jun 23 21:16:07 2013 +0200 (2013-06-23) changeset 52435 6646bb548c6b parent 51343 b61b32f62c78 child 61808 fc1556774cfe permissions -rw-r--r--
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
1 (*  Title:      HOL/Probability/Discrete_Topology.thy
2     Author:     Fabian Immler, TU München
3 *)
5 theory Discrete_Topology
6 imports "~~/src/HOL/Multivariate_Analysis/Multivariate_Analysis"
7 begin
9 text {* Copy of discrete types with discrete topology. This space is polish. *}
11 typedef 'a discrete = "UNIV::'a set"
12 morphisms of_discrete discrete
13 ..
15 instantiation discrete :: (type) topological_space
16 begin
18 definition open_discrete::"'a discrete set \<Rightarrow> bool"
19   where "open_discrete s = True"
21 instance proof qed (auto simp: open_discrete_def)
22 end
24 instantiation discrete :: (type) metric_space
25 begin
27 definition dist_discrete::"'a discrete \<Rightarrow> 'a discrete \<Rightarrow> real"
28   where "dist_discrete n m = (if n = m then 0 else 1)"
30 instance proof qed (auto simp: open_discrete_def dist_discrete_def intro: exI[where x=1])
31 end
33 instance discrete :: (type) complete_space
34 proof
35   fix X::"nat\<Rightarrow>'a discrete" assume "Cauchy X"
36   hence "\<exists>n. \<forall>m\<ge>n. X n = X m"
37     by (force simp: dist_discrete_def Cauchy_def split: split_if_asm dest:spec[where x=1])
38   then guess n ..
39   thus "convergent X"
40     by (intro convergentI[where L="X n"] tendstoI eventually_sequentiallyI[of n])
41        (simp add: dist_discrete_def)
42 qed
44 instance discrete :: (countable) countable
45 proof
46   have "inj (\<lambda>c::'a discrete. to_nat (of_discrete c))"
47     by (simp add: inj_on_def of_discrete_inject)
48   thus "\<exists>f::'a discrete \<Rightarrow> nat. inj f" by blast
49 qed
51 instance discrete :: (countable) second_countable_topology
52 proof
53   let ?B = "range (\<lambda>n::'a discrete. {n})"
54   have "\<And>S. generate_topology ?B (\<Union>x\<in>S. {x})"
55     by (intro generate_topology_Union) (auto intro: generate_topology.intros)
56   then have "open = generate_topology ?B"
57     by (auto intro!: ext simp: open_discrete_def)
58   moreover have "countable ?B" by simp
59   ultimately show "\<exists>B::'a discrete set set. countable B \<and> open = generate_topology B" by blast
60 qed
62 instance discrete :: (countable) polish_space ..
64 end