src/HOL/BNF/BNF_GFP.thy
author traytel
Wed, 03 Jul 2013 16:53:27 +0200
changeset 52505 e62f3fd2035e
parent 51925 e3b7917186f1
child 52634 7c4b56bac189
permissions -rw-r--r--
share some code between codatatypes, datatypes and eventually prim(co)rec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49509
163914705f8d renamed top-level theory from "Codatatype" to "BNF"
blanchet
parents: 49328
diff changeset
     1
(*  Title:      HOL/BNF/BNF_GFP.thy
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     2
    Author:     Dmitriy Traytel, 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
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     5
Greatest fixed point operation on bounded natural functors.
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
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     8
header {* Greatest Fixed Point Operation on Bounded Natural Functors *}
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     9
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    10
theory BNF_GFP
51850
106afdf5806c renamed a few FP-related files, to make it clear that these are not the sum of LFP + GFP but rather shared basic libraries
blanchet
parents: 51804
diff changeset
    11
imports BNF_FP_Basic Equiv_Relations_More "~~/src/HOL/Library/Sublist"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    12
keywords
51804
be6e703908f4 renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents: 51782
diff changeset
    13
  "codatatype" :: thy_decl
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    14
begin
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    15
51739
3514b90d0a8b (co)rec is (just as the (un)fold) the unique morphism;
traytel
parents: 51447
diff changeset
    16
lemma o_sum_case: "h o sum_case f g = sum_case (h o f) (h o g)"
3514b90d0a8b (co)rec is (just as the (un)fold) the unique morphism;
traytel
parents: 51447
diff changeset
    17
unfolding o_def by (auto split: sum.splits)
3514b90d0a8b (co)rec is (just as the (un)fold) the unique morphism;
traytel
parents: 51447
diff changeset
    18
3514b90d0a8b (co)rec is (just as the (un)fold) the unique morphism;
traytel
parents: 51447
diff changeset
    19
lemma sum_case_comp_Inl: "sum_case f g \<circ> Inl = f"
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    20
unfolding comp_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    21
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    22
lemma sum_case_expand_Inr: "f o Inl = g \<Longrightarrow> f x = sum_case g (f o Inr) x"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    23
by (auto split: sum.splits)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    24
51739
3514b90d0a8b (co)rec is (just as the (un)fold) the unique morphism;
traytel
parents: 51447
diff changeset
    25
lemma sum_case_expand_Inr': "f o Inl = g \<Longrightarrow> h = f o Inr \<longleftrightarrow> sum_case g h = f"
3514b90d0a8b (co)rec is (just as the (un)fold) the unique morphism;
traytel
parents: 51447
diff changeset
    26
by (metis sum_case_comp_Inl sum_case_o_inj(2) surjective_sum)
3514b90d0a8b (co)rec is (just as the (un)fold) the unique morphism;
traytel
parents: 51447
diff changeset
    27
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    28
lemma converse_Times: "(A \<times> B) ^-1 = B \<times> A"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    29
by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    30
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    31
lemma equiv_triv1:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    32
assumes "equiv A R" and "(a, b) \<in> R" and "(a, c) \<in> R"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    33
shows "(b, c) \<in> R"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    34
using assms unfolding equiv_def sym_def trans_def by blast
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    35
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    36
lemma equiv_triv2:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    37
assumes "equiv A R" and "(a, b) \<in> R" and "(b, c) \<in> R"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    38
shows "(a, c) \<in> R"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    39
using assms unfolding equiv_def trans_def by blast
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    40
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    41
lemma equiv_proj:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    42
  assumes e: "equiv A R" and "z \<in> R"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    43
  shows "(proj R o fst) z = (proj R o snd) z"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    44
proof -
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    45
  from assms(2) have z: "(fst z, snd z) \<in> R" by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    46
  have P: "\<And>x. (fst z, x) \<in> R \<Longrightarrow> (snd z, x) \<in> R" by (erule equiv_triv1[OF e z])
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    47
  have "\<And>x. (snd z, x) \<in> R \<Longrightarrow> (fst z, x) \<in> R" by (erule equiv_triv2[OF e z])
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    48
  with P show ?thesis unfolding proj_def[abs_def] by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    49
qed
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    50
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    51
(* Operators: *)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    52
definition image2 where "image2 A f g = {(f a, g a) | a. a \<in> A}"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    53
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    54
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    55
lemma Id_onD: "(a, b) \<in> Id_on A \<Longrightarrow> a = b"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    56
unfolding Id_on_def by simp
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    57
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    58
lemma Id_onD': "x \<in> Id_on A \<Longrightarrow> fst x = snd x"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    59
unfolding Id_on_def by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    60
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    61
lemma Id_on_fst: "x \<in> Id_on A \<Longrightarrow> fst x \<in> A"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    62
unfolding Id_on_def by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    63
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    64
lemma Id_on_UNIV: "Id_on UNIV = Id"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    65
unfolding Id_on_def by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    66
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    67
lemma Id_on_Comp: "Id_on A = Id_on A O Id_on A"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    68
unfolding Id_on_def by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    69
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    70
lemma Id_on_Gr: "Id_on A = Gr A id"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    71
unfolding Id_on_def Gr_def by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    72
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    73
lemma Id_on_UNIV_I: "x = y \<Longrightarrow> (x, y) \<in> Id_on UNIV"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
    74
unfolding Id_on_def by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    75
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    76
lemma image2_eqI: "\<lbrakk>b = f x; c = g x; x \<in> A\<rbrakk> \<Longrightarrow> (b, c) \<in> image2 A f g"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    77
unfolding image2_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    78
51893
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
    79
lemma eq_subset: "op = \<le> (\<lambda>a b. P a b \<or> a = b)"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
    80
by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
    81
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    82
lemma IdD: "(a, b) \<in> Id \<Longrightarrow> a = b"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    83
by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    84
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    85
lemma image2_Gr: "image2 A f g = (Gr A f)^-1 O (Gr A g)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    86
unfolding image2_def Gr_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    87
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    88
lemma GrD1: "(x, fx) \<in> Gr A f \<Longrightarrow> x \<in> A"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    89
unfolding Gr_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    90
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    91
lemma GrD2: "(x, fx) \<in> Gr A f \<Longrightarrow> f x = fx"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    92
unfolding Gr_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    93
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    94
lemma Gr_incl: "Gr A f \<subseteq> A <*> B \<longleftrightarrow> f ` A \<subseteq> B"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    95
unfolding Gr_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    96
51893
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
    97
lemma in_rel_Collect_split_eq: "in_rel (Collect (split X)) = X"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
    98
unfolding fun_eq_iff by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
    99
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   100
lemma Collect_split_in_rel_leI: "X \<subseteq> Y \<Longrightarrow> X \<subseteq> Collect (split (in_rel Y))"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   101
by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   102
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   103
lemma Collect_split_in_rel_leE: "X \<subseteq> Collect (split (in_rel Y)) \<Longrightarrow> (X \<subseteq> Y \<Longrightarrow> R) \<Longrightarrow> R"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   104
by force
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   105
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   106
lemma Collect_split_in_relI: "x \<in> X \<Longrightarrow> x \<in> Collect (split (in_rel X))"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   107
by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   108
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   109
lemma conversep_in_rel: "(in_rel R)\<inverse>\<inverse> = in_rel (R\<inverse>)"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   110
unfolding fun_eq_iff by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   111
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   112
lemmas conversep_in_rel_Id_on =
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   113
  trans[OF conversep_in_rel arg_cong[of _ _ in_rel, OF converse_Id_on]]
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   114
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   115
lemma relcompp_in_rel: "in_rel R OO in_rel S = in_rel (R O S)"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   116
unfolding fun_eq_iff by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   117
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   118
lemmas relcompp_in_rel_Id_on =
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   119
  trans[OF relcompp_in_rel arg_cong[of _ _ in_rel, OF Id_on_Comp[symmetric]]]
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   120
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   121
lemma in_rel_Gr: "in_rel (Gr A f) = Grp A f"
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   122
unfolding Gr_def Grp_def fun_eq_iff by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   123
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   124
lemma in_rel_Id_on_UNIV: "in_rel (Id_on UNIV) = op ="
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   125
unfolding fun_eq_iff by auto
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 51850
diff changeset
   126
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   127
definition relImage where
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   128
"relImage R f \<equiv> {(f a1, f a2) | a1 a2. (a1,a2) \<in> R}"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   129
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   130
definition relInvImage where
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   131
"relInvImage A R f \<equiv> {(a1, a2) | a1 a2. a1 \<in> A \<and> a2 \<in> A \<and> (f a1, f a2) \<in> R}"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   132
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   133
lemma relImage_Gr:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   134
"\<lbrakk>R \<subseteq> A \<times> A\<rbrakk> \<Longrightarrow> relImage R f = (Gr A f)^-1 O R O Gr A f"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   135
unfolding relImage_def Gr_def relcomp_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   136
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   137
lemma relInvImage_Gr: "\<lbrakk>R \<subseteq> B \<times> B\<rbrakk> \<Longrightarrow> relInvImage A R f = Gr A f O R O (Gr A f)^-1"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   138
unfolding Gr_def relcomp_def image_def relInvImage_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   139
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   140
lemma relImage_mono:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   141
"R1 \<subseteq> R2 \<Longrightarrow> relImage R1 f \<subseteq> relImage R2 f"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   142
unfolding relImage_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   143
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   144
lemma relInvImage_mono:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   145
"R1 \<subseteq> R2 \<Longrightarrow> relInvImage A R1 f \<subseteq> relInvImage A R2 f"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   146
unfolding relInvImage_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   147
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
   148
lemma relInvImage_Id_on:
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
   149
"(\<And>a1 a2. f a1 = f a2 \<longleftrightarrow> a1 = a2) \<Longrightarrow> relInvImage A (Id_on B) f \<subseteq> Id"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
   150
unfolding relInvImage_def Id_on_def by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   151
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   152
lemma relInvImage_UNIV_relImage:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   153
"R \<subseteq> relInvImage UNIV (relImage R f) f"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   154
unfolding relInvImage_def relImage_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   155
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   156
lemma equiv_Image: "equiv A R \<Longrightarrow> (\<And>a b. (a, b) \<in> R \<Longrightarrow> a \<in> A \<and> b \<in> A \<and> R `` {a} = R `` {b})"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   157
unfolding equiv_def refl_on_def Image_def by (auto intro: transD symD)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   158
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   159
lemma relImage_proj:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   160
assumes "equiv A R"
51447
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
   161
shows "relImage R (proj R) \<subseteq> Id_on (A//R)"
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
   162
unfolding relImage_def Id_on_def
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
   163
using proj_iff[OF assms] equiv_class_eq_iff[OF assms]
a19e973fa2cf eliminate duplicated constant (diag vs. Id_on)
traytel
parents: 51446
diff changeset
   164
by (auto simp: proj_preserves)
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   165
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   166
lemma relImage_relInvImage:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   167
assumes "R \<subseteq> f ` A <*> f ` A"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   168
shows "relImage (relInvImage A R f) f = R"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   169
using assms unfolding relImage_def relInvImage_def by fastforce
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   170
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   171
lemma subst_Pair: "P x y \<Longrightarrow> a = (x, y) \<Longrightarrow> P (fst a) (snd a)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   172
by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   173
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   174
lemma fst_diag_id: "(fst \<circ> (%x. (x, x))) z = id z"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   175
by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   176
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   177
lemma snd_diag_id: "(snd \<circ> (%x. (x, x))) z = id z"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   178
by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   179
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   180
lemma Collect_restrict': "{(x, y) | x y. phi x y \<and> P x y} \<subseteq> {(x, y) | x y. phi x y}"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   181
by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   182
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   183
lemma image_convolD: "\<lbrakk>(a, b) \<in> <f, g> ` X\<rbrakk> \<Longrightarrow> \<exists>x. x \<in> X \<and> a = f x \<and> b = g x"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   184
unfolding convol_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   185
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   186
(*Extended Sublist*)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   187
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   188
definition prefCl where
50058
bb1fadeba35e import Sublist rather than PrefixOrder to avoid unnecessary class instantiation
traytel
parents: 49635
diff changeset
   189
  "prefCl Kl = (\<forall> kl1 kl2. prefixeq kl1 kl2 \<and> kl2 \<in> Kl \<longrightarrow> kl1 \<in> Kl)"
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   190
definition PrefCl where
50058
bb1fadeba35e import Sublist rather than PrefixOrder to avoid unnecessary class instantiation
traytel
parents: 49635
diff changeset
   191
  "PrefCl A n = (\<forall>kl kl'. kl \<in> A n \<and> prefixeq kl' kl \<longrightarrow> (\<exists>m\<le>n. kl' \<in> A m))"
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   192
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   193
lemma prefCl_UN:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   194
  "\<lbrakk>\<And>n. PrefCl A n\<rbrakk> \<Longrightarrow> prefCl (\<Union>n. A n)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   195
unfolding prefCl_def PrefCl_def by fastforce
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   196
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   197
definition Succ where "Succ Kl kl = {k . kl @ [k] \<in> Kl}"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   198
definition Shift where "Shift Kl k = {kl. k # kl \<in> Kl}"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   199
definition shift where "shift lab k = (\<lambda>kl. lab (k # kl))"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   200
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   201
lemma empty_Shift: "\<lbrakk>[] \<in> Kl; k \<in> Succ Kl []\<rbrakk> \<Longrightarrow> [] \<in> Shift Kl k"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   202
unfolding Shift_def Succ_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   203
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   204
lemma Shift_clists: "Kl \<subseteq> Field (clists r) \<Longrightarrow> Shift Kl k \<subseteq> Field (clists r)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   205
unfolding Shift_def clists_def Field_card_of by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   206
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   207
lemma Shift_prefCl: "prefCl Kl \<Longrightarrow> prefCl (Shift Kl k)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   208
unfolding prefCl_def Shift_def
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   209
proof safe
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   210
  fix kl1 kl2
50058
bb1fadeba35e import Sublist rather than PrefixOrder to avoid unnecessary class instantiation
traytel
parents: 49635
diff changeset
   211
  assume "\<forall>kl1 kl2. prefixeq kl1 kl2 \<and> kl2 \<in> Kl \<longrightarrow> kl1 \<in> Kl"
bb1fadeba35e import Sublist rather than PrefixOrder to avoid unnecessary class instantiation
traytel
parents: 49635
diff changeset
   212
    "prefixeq kl1 kl2" "k # kl2 \<in> Kl"
bb1fadeba35e import Sublist rather than PrefixOrder to avoid unnecessary class instantiation
traytel
parents: 49635
diff changeset
   213
  thus "k # kl1 \<in> Kl" using Cons_prefixeq_Cons[of k kl1 k kl2] by blast
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   214
qed
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   215
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   216
lemma not_in_Shift: "kl \<notin> Shift Kl x \<Longrightarrow> x # kl \<notin> Kl"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   217
unfolding Shift_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   218
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   219
lemma prefCl_Succ: "\<lbrakk>prefCl Kl; k # kl \<in> Kl\<rbrakk> \<Longrightarrow> k \<in> Succ Kl []"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   220
unfolding Succ_def proof
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   221
  assume "prefCl Kl" "k # kl \<in> Kl"
50058
bb1fadeba35e import Sublist rather than PrefixOrder to avoid unnecessary class instantiation
traytel
parents: 49635
diff changeset
   222
  moreover have "prefixeq (k # []) (k # kl)" by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   223
  ultimately have "k # [] \<in> Kl" unfolding prefCl_def by blast
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   224
  thus "[] @ [k] \<in> Kl" by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   225
qed
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   226
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   227
lemma SuccD: "k \<in> Succ Kl kl \<Longrightarrow> kl @ [k] \<in> Kl"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   228
unfolding Succ_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   229
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   230
lemmas SuccE = SuccD[elim_format]
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   231
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   232
lemma SuccI: "kl @ [k] \<in> Kl \<Longrightarrow> k \<in> Succ Kl kl"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   233
unfolding Succ_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   234
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   235
lemma ShiftD: "kl \<in> Shift Kl k \<Longrightarrow> k # kl \<in> Kl"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   236
unfolding Shift_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   237
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   238
lemma Succ_Shift: "Succ (Shift Kl k) kl = Succ Kl (k # kl)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   239
unfolding Succ_def Shift_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   240
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   241
lemma ShiftI: "k # kl \<in> Kl \<Longrightarrow> kl \<in> Shift Kl k"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   242
unfolding Shift_def by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   243
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   244
lemma Func_cexp: "|Func A B| =o |B| ^c |A|"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   245
unfolding cexp_def Field_card_of by (simp only: card_of_refl)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   246
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   247
lemma clists_bound: "A \<in> Field (cpow (clists r)) - {{}} \<Longrightarrow> |A| \<le>o clists r"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   248
unfolding cpow_def clists_def Field_card_of by (auto simp: card_of_mono1)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   249
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   250
lemma cpow_clists_czero: "\<lbrakk>A \<in> Field (cpow (clists r)) - {{}}; |A| =o czero\<rbrakk> \<Longrightarrow> False"
51782
84e7225f5ab6 removed unnecessary assumptions in some theorems about cardinal exponentiation
traytel
parents: 51739
diff changeset
   251
unfolding cpow_def clists_def card_of_ordIso_czero_iff_empty by auto
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   252
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   253
lemma incl_UNION_I:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   254
assumes "i \<in> I" and "A \<subseteq> F i"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   255
shows "A \<subseteq> UNION I F"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   256
using assms by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   257
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   258
lemma Nil_clists: "{[]} \<subseteq> Field (clists r)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   259
unfolding clists_def Field_card_of by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   260
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   261
lemma Cons_clists:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   262
  "\<lbrakk>x \<in> Field r; xs \<in> Field (clists r)\<rbrakk> \<Longrightarrow> x # xs \<in> Field (clists r)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   263
unfolding clists_def Field_card_of by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   264
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   265
lemma length_Cons: "length (x # xs) = Suc (length xs)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   266
by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   267
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   268
lemma length_append_singleton: "length (xs @ [x]) = Suc (length xs)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   269
by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   270
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   271
(*injection into the field of a cardinal*)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   272
definition "toCard_pred A r f \<equiv> inj_on f A \<and> f ` A \<subseteq> Field r \<and> Card_order r"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   273
definition "toCard A r \<equiv> SOME f. toCard_pred A r f"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   274
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   275
lemma ex_toCard_pred:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   276
"\<lbrakk>|A| \<le>o r; Card_order r\<rbrakk> \<Longrightarrow> \<exists> f. toCard_pred A r f"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   277
unfolding toCard_pred_def
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   278
using card_of_ordLeq[of A "Field r"]
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   279
      ordLeq_ordIso_trans[OF _ card_of_unique[of "Field r" r], of "|A|"]
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   280
by blast
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   281
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   282
lemma toCard_pred_toCard:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   283
  "\<lbrakk>|A| \<le>o r; Card_order r\<rbrakk> \<Longrightarrow> toCard_pred A r (toCard A r)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   284
unfolding toCard_def using someI_ex[OF ex_toCard_pred] .
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   285
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   286
lemma toCard_inj: "\<lbrakk>|A| \<le>o r; Card_order r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow>
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   287
  toCard A r x = toCard A r y \<longleftrightarrow> x = y"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   288
using toCard_pred_toCard unfolding inj_on_def toCard_pred_def by blast
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   289
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   290
lemma toCard: "\<lbrakk>|A| \<le>o r; Card_order r; b \<in> A\<rbrakk> \<Longrightarrow> toCard A r b \<in> Field r"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   291
using toCard_pred_toCard unfolding toCard_pred_def by blast
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   292
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   293
definition "fromCard A r k \<equiv> SOME b. b \<in> A \<and> toCard A r b = k"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   294
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   295
lemma fromCard_toCard:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   296
"\<lbrakk>|A| \<le>o r; Card_order r; b \<in> A\<rbrakk> \<Longrightarrow> fromCard A r (toCard A r b) = b"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   297
unfolding fromCard_def by (rule some_equality) (auto simp add: toCard_inj)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   298
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   299
(* pick according to the weak pullback *)
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   300
definition pickWP where
51446
a6ebb12cc003 hide internal constants; tuned proofs
traytel
parents: 50058
diff changeset
   301
"pickWP A p1 p2 b1 b2 \<equiv> SOME a. a \<in> A \<and> p1 a = b1 \<and> p2 a = b2"
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   302
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   303
lemma pickWP_pred:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   304
assumes "wpull A B1 B2 f1 f2 p1 p2" and
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   305
"b1 \<in> B1" and "b2 \<in> B2" and "f1 b1 = f2 b2"
51446
a6ebb12cc003 hide internal constants; tuned proofs
traytel
parents: 50058
diff changeset
   306
shows "\<exists> a. a \<in> A \<and> p1 a = b1 \<and> p2 a = b2"
a6ebb12cc003 hide internal constants; tuned proofs
traytel
parents: 50058
diff changeset
   307
using assms unfolding wpull_def by blast
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   308
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   309
lemma pickWP:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   310
assumes "wpull A B1 B2 f1 f2 p1 p2" and
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   311
"b1 \<in> B1" and "b2 \<in> B2" and "f1 b1 = f2 b2"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   312
shows "pickWP A p1 p2 b1 b2 \<in> A"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   313
      "p1 (pickWP A p1 p2 b1 b2) = b1"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   314
      "p2 (pickWP A p1 p2 b1 b2) = b2"
51446
a6ebb12cc003 hide internal constants; tuned proofs
traytel
parents: 50058
diff changeset
   315
unfolding pickWP_def using assms someI_ex[OF pickWP_pred] by fastforce+
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   316
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   317
lemma Inl_Field_csum: "a \<in> Field r \<Longrightarrow> Inl a \<in> Field (r +c s)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   318
unfolding Field_card_of csum_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   319
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   320
lemma Inr_Field_csum: "a \<in> Field s \<Longrightarrow> Inr a \<in> Field (r +c s)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   321
unfolding Field_card_of csum_def by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   322
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   323
lemma nat_rec_0: "f = nat_rec f1 (%n rec. f2 n rec) \<Longrightarrow> f 0 = f1"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   324
by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   325
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   326
lemma nat_rec_Suc: "f = nat_rec f1 (%n rec. f2 n rec) \<Longrightarrow> f (Suc n) = f2 n (f n)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   327
by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   328
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   329
lemma list_rec_Nil: "f = list_rec f1 (%x xs rec. f2 x xs rec) \<Longrightarrow> f [] = f1"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   330
by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   331
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   332
lemma list_rec_Cons: "f = list_rec f1 (%x xs rec. f2 x xs rec) \<Longrightarrow> f (x # xs) = f2 x xs (f xs)"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   333
by auto
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   334
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   335
lemma not_arg_cong_Inr: "x \<noteq> y \<Longrightarrow> Inr x \<noteq> Inr y"
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   336
by simp
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   337
51925
e3b7917186f1 relator coinduction for codatatypes
traytel
parents: 51909
diff changeset
   338
lemma Collect_splitD: "x \<in> Collect (split A) \<Longrightarrow> A (fst x) (snd x)"
e3b7917186f1 relator coinduction for codatatypes
traytel
parents: 51909
diff changeset
   339
by auto
e3b7917186f1 relator coinduction for codatatypes
traytel
parents: 51909
diff changeset
   340
49309
f20b24214ac2 split basic BNFs into really basic ones and others, and added Andreas Lochbihler's "option" BNF
blanchet
parents: 49308
diff changeset
   341
ML_file "Tools/bnf_gfp_util.ML"
f20b24214ac2 split basic BNFs into really basic ones and others, and added Andreas Lochbihler's "option" BNF
blanchet
parents: 49308
diff changeset
   342
ML_file "Tools/bnf_gfp_tactics.ML"
f20b24214ac2 split basic BNFs into really basic ones and others, and added Andreas Lochbihler's "option" BNF
blanchet
parents: 49308
diff changeset
   343
ML_file "Tools/bnf_gfp.ML"
f20b24214ac2 split basic BNFs into really basic ones and others, and added Andreas Lochbihler's "option" BNF
blanchet
parents: 49308
diff changeset
   344
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   345
end