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
immler@50089
     1
(*  Title:      HOL/Probability/Discrete_Topology.thy
immler@50089
     2
    Author:     Fabian Immler, TU München
immler@50089
     3
*)
immler@50089
     4
immler@50089
     5
theory Discrete_Topology
hoelzl@51000
     6
imports "~~/src/HOL/Multivariate_Analysis/Multivariate_Analysis"
immler@50089
     7
begin
immler@50089
     8
immler@50089
     9
text {* Copy of discrete types with discrete topology. This space is polish. *}
immler@50089
    10
immler@50089
    11
typedef 'a discrete = "UNIV::'a set"
immler@50089
    12
morphisms of_discrete discrete
immler@50089
    13
..
immler@50089
    14
immler@50089
    15
instantiation discrete :: (type) topological_space
immler@50089
    16
begin
immler@50089
    17
immler@50089
    18
definition open_discrete::"'a discrete set \<Rightarrow> bool"
immler@50089
    19
  where "open_discrete s = True"
immler@50089
    20
immler@50089
    21
instance proof qed (auto simp: open_discrete_def)
immler@50089
    22
end
immler@50089
    23
immler@50089
    24
instantiation discrete :: (type) metric_space
immler@50089
    25
begin
immler@50089
    26
immler@50089
    27
definition dist_discrete::"'a discrete \<Rightarrow> 'a discrete \<Rightarrow> real"
immler@50089
    28
  where "dist_discrete n m = (if n = m then 0 else 1)"
immler@50089
    29
immler@50089
    30
instance proof qed (auto simp: open_discrete_def dist_discrete_def intro: exI[where x=1])
immler@50089
    31
end
immler@50089
    32
immler@50089
    33
instance discrete :: (type) complete_space
immler@50089
    34
proof
immler@50089
    35
  fix X::"nat\<Rightarrow>'a discrete" assume "Cauchy X"
immler@50089
    36
  hence "\<exists>n. \<forall>m\<ge>n. X n = X m"
immler@50089
    37
    by (force simp: dist_discrete_def Cauchy_def split: split_if_asm dest:spec[where x=1])
immler@50089
    38
  then guess n ..
immler@50089
    39
  thus "convergent X"
immler@50089
    40
    by (intro convergentI[where L="X n"] tendstoI eventually_sequentiallyI[of n])
immler@50089
    41
       (simp add: dist_discrete_def)
immler@50089
    42
qed
immler@50089
    43
immler@50089
    44
instance discrete :: (countable) countable
immler@50089
    45
proof
immler@50089
    46
  have "inj (\<lambda>c::'a discrete. to_nat (of_discrete c))"
immler@50089
    47
    by (simp add: inj_on_def of_discrete_inject)
immler@50089
    48
  thus "\<exists>f::'a discrete \<Rightarrow> nat. inj f" by blast
immler@50089
    49
qed
immler@50089
    50
hoelzl@50881
    51
instance discrete :: (countable) second_countable_topology
immler@50089
    52
proof
hoelzl@51343
    53
  let ?B = "range (\<lambda>n::'a discrete. {n})"
hoelzl@51343
    54
  have "\<And>S. generate_topology ?B (\<Union>x\<in>S. {x})"
hoelzl@51343
    55
    by (intro generate_topology_Union) (auto intro: generate_topology.intros)
hoelzl@51343
    56
  then have "open = generate_topology ?B"
hoelzl@51343
    57
    by (auto intro!: ext simp: open_discrete_def)
immler@50245
    58
  moreover have "countable ?B" by simp
hoelzl@51343
    59
  ultimately show "\<exists>B::'a discrete set set. countable B \<and> open = generate_topology B" by blast
immler@50089
    60
qed
immler@50089
    61
immler@50089
    62
instance discrete :: (countable) polish_space ..
immler@50089
    63
immler@50089
    64
end