src/HOL/BNF/Countable_Set_Type.thy
author blanchet
Thu, 16 Jan 2014 16:20:17 +0100
changeset 55017 2df6ad1dbd66
parent 54841 af71b753c459
child 55070 235c7661a96b
permissions -rw-r--r--
adapted to move of Wfrec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
     1
(*  Title:      HOL/BNF/Countable_Set_Type.thy
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     2
    Author:     Andrei Popescu, TU Muenchen
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     3
    Copyright   2012
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     4
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
     5
Type of (at most) countable sets.
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     6
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     7
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
     8
header {* Type of (at Most) Countable Sets *}
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     9
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    10
theory Countable_Set_Type
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    11
imports
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    12
  More_BNFs
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    13
  "~~/src/HOL/Cardinals/Cardinals"
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    14
  "~~/src/HOL/Library/Countable_Set"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    15
begin
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    16
50144
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    17
subsection{* Cardinal stuff *}
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    18
50144
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    19
lemma countable_card_of_nat: "countable A \<longleftrightarrow> |A| \<le>o |UNIV::nat set|"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    20
  unfolding countable_def card_of_ordLeq[symmetric] by auto
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    21
50144
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    22
lemma countable_card_le_natLeq: "countable A \<longleftrightarrow> |A| \<le>o natLeq"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    23
  unfolding countable_card_of_nat using card_of_nat ordLeq_ordIso_trans ordIso_symmetric by blast
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    24
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    25
lemma countable_or_card_of:
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    26
assumes "countable A"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    27
shows "(finite A \<and> |A| <o |UNIV::nat set| ) \<or>
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    28
       (infinite A  \<and> |A| =o |UNIV::nat set| )"
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    29
proof (cases "finite A")
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    30
  case True thus ?thesis by (metis finite_iff_cardOf_nat)
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    31
next
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    32
  case False with assms show ?thesis
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    33
    by (metis countable_card_of_nat infinite_iff_card_of_nat ordIso_iff_ordLeq)
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    34
qed
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    35
50144
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    36
lemma countable_cases_card_of[elim]:
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    37
  assumes "countable A"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    38
  obtains (Fin) "finite A" "|A| <o |UNIV::nat set|"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    39
        | (Inf) "infinite A" "|A| =o |UNIV::nat set|"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    40
  using assms countable_or_card_of by blast
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    41
50144
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    42
lemma countable_or:
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    43
  "countable A \<Longrightarrow> (\<exists> f::'a\<Rightarrow>nat. finite A \<and> inj_on f A) \<or> (\<exists> f::'a\<Rightarrow>nat. infinite A \<and> bij_betw f A UNIV)"
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    44
  by (elim countable_enum_cases) fastforce+
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    45
50144
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    46
lemma countable_cases[elim]:
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    47
  assumes "countable A"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    48
  obtains (Fin) f :: "'a\<Rightarrow>nat" where "finite A" "inj_on f A"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    49
        | (Inf) f :: "'a\<Rightarrow>nat" where "infinite A" "bij_betw f A UNIV"
885deccc264e renamed BNF/Countable_Set to Countable_Type and moved its generic stuff to Library/Countable_Set
hoelzl
parents: 49834
diff changeset
    50
  using assms countable_or by metis
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    51
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    52
lemma countable_ordLeq:
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    53
assumes "|A| \<le>o |B|" and "countable B"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    54
shows "countable A"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    55
using assms unfolding countable_card_of_nat by(rule ordLeq_transitive)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    56
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    57
lemma countable_ordLess:
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    58
assumes AB: "|A| <o |B|" and B: "countable B"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    59
shows "countable A"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    60
using countable_ordLeq[OF ordLess_imp_ordLeq[OF AB] B] .
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    61
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    62
subsection {* The type of countable sets *}
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    63
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    64
typedef 'a cset = "{A :: 'a set. countable A}" morphisms rcset acset
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    65
  by (rule exI[of _ "{}"]) simp
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    66
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    67
setup_lifting type_definition_cset
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    68
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    69
declare
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    70
  rcset_inverse[simp]
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    71
  acset_inverse[Transfer.transferred, unfolded mem_Collect_eq, simp]
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    72
  acset_inject[Transfer.transferred, unfolded mem_Collect_eq, simp]
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    73
  rcset[Transfer.transferred, unfolded mem_Collect_eq, simp]
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    74
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    75
lift_definition cin :: "'a \<Rightarrow> 'a cset \<Rightarrow> bool" is "op \<in>" parametric member_transfer
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    76
  ..
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    77
lift_definition cempty :: "'a cset" is "{}" parametric empty_transfer
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    78
  by (rule countable_empty)
53013
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52662
diff changeset
    79
lift_definition cinsert :: "'a \<Rightarrow> 'a cset \<Rightarrow> 'a cset" is insert parametric Lifting_Set.insert_transfer
52662
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    80
  by (rule countable_insert)
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    81
lift_definition csingle :: "'a \<Rightarrow> 'a cset" is "\<lambda>x. {x}"
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    82
  by (rule countable_insert[OF countable_empty])
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    83
lift_definition cUn :: "'a cset \<Rightarrow> 'a cset \<Rightarrow> 'a cset" is "op \<union>" parametric union_transfer
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    84
  by (rule countable_Un)
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    85
lift_definition cInt :: "'a cset \<Rightarrow> 'a cset \<Rightarrow> 'a cset" is "op \<inter>" parametric inter_transfer
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    86
  by (rule countable_Int1)
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    87
lift_definition cDiff :: "'a cset \<Rightarrow> 'a cset \<Rightarrow> 'a cset" is "op -" parametric Diff_transfer
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    88
  by (rule countable_Diff)
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    89
lift_definition cimage :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a cset \<Rightarrow> 'b cset" is "op `" parametric image_transfer
c7cae5ce217d use transfer/lifting for proving countable set and multisets being BNFs
traytel
parents: 52660
diff changeset
    90
  by (rule countable_image)
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    91
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    92
subsection {* Registration as BNF *}
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    93
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    94
lemma card_of_countable_sets_range:
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    95
fixes A :: "'a set"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    96
shows "|{X. X \<subseteq> A \<and> countable X \<and> X \<noteq> {}}| \<le>o |{f::nat \<Rightarrow> 'a. range f \<subseteq> A}|"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    97
apply(rule card_of_ordLeqI[of from_nat_into]) using inj_on_from_nat_into
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    98
unfolding inj_on_def by auto
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
    99
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   100
lemma card_of_countable_sets_Func:
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   101
"|{X. X \<subseteq> A \<and> countable X \<and> X \<noteq> {}}| \<le>o |A| ^c natLeq"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   102
using card_of_countable_sets_range card_of_Func_UNIV[THEN ordIso_symmetric]
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   103
unfolding cexp_def Field_natLeq Field_card_of
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   104
by (rule ordLeq_ordIso_trans)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   105
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   106
lemma ordLeq_countable_subsets:
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   107
"|A| \<le>o |{X. X \<subseteq> A \<and> countable X}|"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   108
apply (rule card_of_ordLeqI[of "\<lambda> a. {a}"]) unfolding inj_on_def by auto
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   109
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   110
lemma finite_countable_subset:
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   111
"finite {X. X \<subseteq> A \<and> countable X} \<longleftrightarrow> finite A"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   112
apply default
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   113
 apply (erule contrapos_pp)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   114
 apply (rule card_of_ordLeq_infinite)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   115
 apply (rule ordLeq_countable_subsets)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   116
 apply assumption
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   117
apply (rule finite_Collect_conjI)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   118
apply (rule disjI1)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   119
by (erule finite_Collect_subsets)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   120
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   121
lemma rcset_to_rcset: "countable A \<Longrightarrow> rcset (the_inv rcset A) = A"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   122
  apply (rule f_the_inv_into_f[unfolded inj_on_def image_iff])
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   123
   apply transfer' apply simp
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   124
  apply transfer' apply simp
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   125
  done
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   126
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   127
lemma Collect_Int_Times:
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   128
"{(x, y). R x y} \<inter> A \<times> B = {(x, y). R x y \<and> x \<in> A \<and> y \<in> B}"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   129
by auto
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   130
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   131
definition cset_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a cset \<Rightarrow> 'b cset \<Rightarrow> bool" where
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   132
"cset_rel R a b \<longleftrightarrow>
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   133
 (\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and>
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   134
 (\<forall>t \<in> rcset b. \<exists>u \<in> rcset a. R u t)"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   135
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   136
lemma cset_rel_aux:
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   137
"(\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and> (\<forall>t \<in> rcset b. \<exists>u \<in> rcset a. R u t) \<longleftrightarrow>
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   138
 ((Grp {x. rcset x \<subseteq> {(a, b). R a b}} (cimage fst))\<inverse>\<inverse> OO
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   139
          Grp {x. rcset x \<subseteq> {(a, b). R a b}} (cimage snd)) a b" (is "?L = ?R")
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   140
proof
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   141
  assume ?L
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   142
  def R' \<equiv> "the_inv rcset (Collect (split R) \<inter> (rcset a \<times> rcset b))"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   143
  (is "the_inv rcset ?L'")
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   144
  have L: "countable ?L'" by auto
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   145
  hence *: "rcset R' = ?L'" unfolding R'_def using fset_to_fset by (intro rcset_to_rcset)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   146
  thus ?R unfolding Grp_def relcompp.simps conversep.simps
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   147
  proof (intro CollectI prod_caseI exI[of _ a] exI[of _ b] exI[of _ R'] conjI refl)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   148
    from * `?L` show "a = cimage fst R'" by transfer (auto simp: image_def Collect_Int_Times)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   149
  next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   150
    from * `?L` show "b = cimage snd R'" by transfer (auto simp: image_def Collect_Int_Times)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   151
  qed simp_all
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   152
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   153
  assume ?R thus ?L unfolding Grp_def relcompp.simps conversep.simps
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   154
    by transfer force
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   155
qed
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   156
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   157
bnf "'a cset"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   158
  map: cimage
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   159
  sets: rcset
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   160
  bd: natLeq
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   161
  wits: "cempty"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   162
  rel: cset_rel
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   163
proof -
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   164
  show "cimage id = id" by transfer' simp
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   165
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   166
  fix f g show "cimage (g \<circ> f) = cimage g \<circ> cimage f" by transfer' fastforce
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   167
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   168
  fix C f g assume eq: "\<And>a. a \<in> rcset C \<Longrightarrow> f a = g a"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   169
  thus "cimage f C = cimage g C" by transfer force
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   170
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   171
  fix f show "rcset \<circ> cimage f = op ` f \<circ> rcset" by transfer' fastforce
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   172
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   173
  show "card_order natLeq" by (rule natLeq_card_order)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   174
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   175
  show "cinfinite natLeq" by (rule natLeq_cinfinite)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   176
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   177
  fix C show "|rcset C| \<le>o natLeq" by transfer (unfold countable_card_le_natLeq)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   178
next
54841
af71b753c459 express weak pullback property of bnfs only in terms of the relator
traytel
parents: 54539
diff changeset
   179
  fix R S
af71b753c459 express weak pullback property of bnfs only in terms of the relator
traytel
parents: 54539
diff changeset
   180
  show "cset_rel R OO cset_rel S \<le> cset_rel (R OO S)"
af71b753c459 express weak pullback property of bnfs only in terms of the relator
traytel
parents: 54539
diff changeset
   181
    unfolding cset_rel_def[abs_def] by fast
54539
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   182
next
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   183
  fix R
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   184
  show "cset_rel R =
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   185
        (Grp {x. rcset x \<subseteq> Collect (split R)} (cimage fst))\<inverse>\<inverse> OO
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   186
         Grp {x. rcset x \<subseteq> Collect (split R)} (cimage snd)"
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   187
  unfolding cset_rel_def[abs_def] cset_rel_aux by simp
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   188
qed (transfer, simp)
bbab2ebda234 move registration of countable set type as BNF to its own theory file (+ renamed theory)
blanchet
parents: 53013
diff changeset
   189
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   190
end