blanchet@55059
|
1 |
(* Title: HOL/BNF_Def.thy
|
blanchet@48975
|
2 |
Author: Dmitriy Traytel, TU Muenchen
|
blanchet@48975
|
3 |
Copyright 2012
|
blanchet@48975
|
4 |
|
blanchet@48975
|
5 |
Definition of bounded natural functors.
|
blanchet@48975
|
6 |
*)
|
blanchet@48975
|
7 |
|
blanchet@48975
|
8 |
header {* Definition of Bounded Natural Functors *}
|
blanchet@48975
|
9 |
|
blanchet@48975
|
10 |
theory BNF_Def
|
blanchet@55085
|
11 |
imports BNF_Util Fun_Def_Base
|
blanchet@48975
|
12 |
keywords
|
blanchet@49286
|
13 |
"print_bnfs" :: diag and
|
blanchet@51836
|
14 |
"bnf" :: thy_goal
|
blanchet@48975
|
15 |
begin
|
blanchet@48975
|
16 |
|
blanchet@55066
|
17 |
lemma collect_comp: "collect F o g = collect ((\<lambda>f. f o g) ` F)"
|
blanchet@55066
|
18 |
by (rule ext) (auto simp only: comp_apply collect_def)
|
traytel@51893
|
19 |
|
traytel@49495
|
20 |
definition convol ("<_ , _>") where
|
traytel@49495
|
21 |
"<f , g> \<equiv> %a. (f a, g a)"
|
traytel@49495
|
22 |
|
traytel@49495
|
23 |
lemma fst_convol:
|
traytel@49495
|
24 |
"fst o <f , g> = f"
|
traytel@49495
|
25 |
apply(rule ext)
|
traytel@49495
|
26 |
unfolding convol_def by simp
|
traytel@49495
|
27 |
|
traytel@49495
|
28 |
lemma snd_convol:
|
traytel@49495
|
29 |
"snd o <f , g> = g"
|
traytel@49495
|
30 |
apply(rule ext)
|
traytel@49495
|
31 |
unfolding convol_def by simp
|
traytel@49495
|
32 |
|
traytel@51893
|
33 |
lemma convol_mem_GrpI:
|
traytel@52986
|
34 |
"x \<in> A \<Longrightarrow> <id , g> x \<in> (Collect (split (Grp A g)))"
|
traytel@51893
|
35 |
unfolding convol_def Grp_def by auto
|
traytel@51893
|
36 |
|
blanchet@49312
|
37 |
definition csquare where
|
blanchet@49312
|
38 |
"csquare A f1 f2 p1 p2 \<longleftrightarrow> (\<forall> a \<in> A. f1 (p1 a) = f2 (p2 a))"
|
blanchet@49312
|
39 |
|
traytel@51893
|
40 |
lemma eq_alt: "op = = Grp UNIV id"
|
traytel@51893
|
41 |
unfolding Grp_def by auto
|
traytel@51893
|
42 |
|
traytel@51893
|
43 |
lemma leq_conversepI: "R = op = \<Longrightarrow> R \<le> R^--1"
|
traytel@51893
|
44 |
by auto
|
traytel@51893
|
45 |
|
traytel@54841
|
46 |
lemma leq_OOI: "R = op = \<Longrightarrow> R \<le> R OO R"
|
traytel@51893
|
47 |
by auto
|
traytel@51893
|
48 |
|
traytel@53561
|
49 |
lemma OO_Grp_alt: "(Grp A f)^--1 OO Grp A g = (\<lambda>x y. \<exists>z. z \<in> A \<and> f z = x \<and> g z = y)"
|
traytel@53561
|
50 |
unfolding Grp_def by auto
|
traytel@53561
|
51 |
|
traytel@51893
|
52 |
lemma Grp_UNIV_id: "f = id \<Longrightarrow> (Grp UNIV f)^--1 OO Grp UNIV f = Grp UNIV f"
|
traytel@51893
|
53 |
unfolding Grp_def by auto
|
traytel@51893
|
54 |
|
traytel@51893
|
55 |
lemma Grp_UNIV_idI: "x = y \<Longrightarrow> Grp UNIV id x y"
|
traytel@51893
|
56 |
unfolding Grp_def by auto
|
traytel@51893
|
57 |
|
traytel@51893
|
58 |
lemma Grp_mono: "A \<le> B \<Longrightarrow> Grp A f \<le> Grp B f"
|
traytel@51893
|
59 |
unfolding Grp_def by auto
|
traytel@51893
|
60 |
|
traytel@51893
|
61 |
lemma GrpI: "\<lbrakk>f x = y; x \<in> A\<rbrakk> \<Longrightarrow> Grp A f x y"
|
traytel@51893
|
62 |
unfolding Grp_def by auto
|
traytel@51893
|
63 |
|
traytel@51893
|
64 |
lemma GrpE: "Grp A f x y \<Longrightarrow> (\<lbrakk>f x = y; x \<in> A\<rbrakk> \<Longrightarrow> R) \<Longrightarrow> R"
|
traytel@51893
|
65 |
unfolding Grp_def by auto
|
traytel@51893
|
66 |
|
traytel@51893
|
67 |
lemma Collect_split_Grp_eqD: "z \<in> Collect (split (Grp A f)) \<Longrightarrow> (f \<circ> fst) z = snd z"
|
blanchet@55066
|
68 |
unfolding Grp_def comp_def by auto
|
traytel@51893
|
69 |
|
traytel@51893
|
70 |
lemma Collect_split_Grp_inD: "z \<in> Collect (split (Grp A f)) \<Longrightarrow> fst z \<in> A"
|
blanchet@55066
|
71 |
unfolding Grp_def comp_def by auto
|
traytel@51893
|
72 |
|
traytel@51893
|
73 |
definition "pick_middlep P Q a c = (SOME b. P a b \<and> Q b c)"
|
traytel@51893
|
74 |
|
traytel@51893
|
75 |
lemma pick_middlep:
|
traytel@51893
|
76 |
"(P OO Q) a c \<Longrightarrow> P a (pick_middlep P Q a c) \<and> Q (pick_middlep P Q a c) c"
|
traytel@51893
|
77 |
unfolding pick_middlep_def apply(rule someI_ex) by auto
|
blanchet@49312
|
78 |
|
traytel@51893
|
79 |
definition fstOp where "fstOp P Q ac = (fst ac, pick_middlep P Q (fst ac) (snd ac))"
|
traytel@51893
|
80 |
definition sndOp where "sndOp P Q ac = (pick_middlep P Q (fst ac) (snd ac), (snd ac))"
|
traytel@51893
|
81 |
|
traytel@51893
|
82 |
lemma fstOp_in: "ac \<in> Collect (split (P OO Q)) \<Longrightarrow> fstOp P Q ac \<in> Collect (split P)"
|
traytel@51893
|
83 |
unfolding fstOp_def mem_Collect_eq
|
blanchet@55642
|
84 |
by (subst (asm) surjective_pairing, unfold prod.case) (erule pick_middlep[THEN conjunct1])
|
blanchet@49312
|
85 |
|
traytel@51893
|
86 |
lemma fst_fstOp: "fst bc = (fst \<circ> fstOp P Q) bc"
|
traytel@51893
|
87 |
unfolding comp_def fstOp_def by simp
|
traytel@51893
|
88 |
|
traytel@51893
|
89 |
lemma snd_sndOp: "snd bc = (snd \<circ> sndOp P Q) bc"
|
traytel@51893
|
90 |
unfolding comp_def sndOp_def by simp
|
traytel@51893
|
91 |
|
traytel@51893
|
92 |
lemma sndOp_in: "ac \<in> Collect (split (P OO Q)) \<Longrightarrow> sndOp P Q ac \<in> Collect (split Q)"
|
traytel@51893
|
93 |
unfolding sndOp_def mem_Collect_eq
|
blanchet@55642
|
94 |
by (subst (asm) surjective_pairing, unfold prod.case) (erule pick_middlep[THEN conjunct2])
|
traytel@51893
|
95 |
|
traytel@51893
|
96 |
lemma csquare_fstOp_sndOp:
|
traytel@51893
|
97 |
"csquare (Collect (split (P OO Q))) snd fst (fstOp P Q) (sndOp P Q)"
|
traytel@51893
|
98 |
unfolding csquare_def fstOp_def sndOp_def using pick_middlep by simp
|
traytel@51893
|
99 |
|
blanchet@49312
|
100 |
lemma snd_fst_flip: "snd xy = (fst o (%(x, y). (y, x))) xy"
|
blanchet@49312
|
101 |
by (simp split: prod.split)
|
blanchet@49312
|
102 |
|
blanchet@49312
|
103 |
lemma fst_snd_flip: "fst xy = (snd o (%(x, y). (y, x))) xy"
|
blanchet@49312
|
104 |
by (simp split: prod.split)
|
blanchet@49312
|
105 |
|
traytel@51893
|
106 |
lemma flip_pred: "A \<subseteq> Collect (split (R ^--1)) \<Longrightarrow> (%(x, y). (y, x)) ` A \<subseteq> Collect (split R)"
|
traytel@51893
|
107 |
by auto
|
traytel@51893
|
108 |
|
traytel@51893
|
109 |
lemma Collect_split_mono: "A \<le> B \<Longrightarrow> Collect (split A) \<subseteq> Collect (split B)"
|
traytel@51893
|
110 |
by auto
|
traytel@51893
|
111 |
|
traytel@51916
|
112 |
lemma Collect_split_mono_strong:
|
traytel@55163
|
113 |
"\<lbrakk>X = fst ` A; Y = snd ` A; \<forall>a\<in>X. \<forall>b \<in> Y. P a b \<longrightarrow> Q a b; A \<subseteq> Collect (split P)\<rbrakk> \<Longrightarrow>
|
traytel@51916
|
114 |
A \<subseteq> Collect (split Q)"
|
traytel@51916
|
115 |
by fastforce
|
traytel@51916
|
116 |
|
traytel@55163
|
117 |
|
traytel@51917
|
118 |
lemma predicate2_eqD: "A = B \<Longrightarrow> A a b \<longleftrightarrow> B a b"
|
traytel@51893
|
119 |
by metis
|
blanchet@49537
|
120 |
|
blanchet@55414
|
121 |
lemma case_sum_o_inj:
|
blanchet@55414
|
122 |
"case_sum f g \<circ> Inl = f"
|
blanchet@55414
|
123 |
"case_sum f g \<circ> Inr = g"
|
traytel@52635
|
124 |
by auto
|
traytel@52635
|
125 |
|
traytel@52635
|
126 |
lemma card_order_csum_cone_cexp_def:
|
traytel@52635
|
127 |
"card_order r \<Longrightarrow> ( |A1| +c cone) ^c r = |Func UNIV (Inl ` A1 \<union> {Inr ()})|"
|
traytel@52635
|
128 |
unfolding cexp_def cone_def Field_csum Field_card_of by (auto dest: Field_card_order)
|
traytel@52635
|
129 |
|
traytel@52635
|
130 |
lemma If_the_inv_into_in_Func:
|
traytel@52635
|
131 |
"\<lbrakk>inj_on g C; C \<subseteq> B \<union> {x}\<rbrakk> \<Longrightarrow>
|
traytel@52635
|
132 |
(\<lambda>i. if i \<in> g ` C then the_inv_into C g i else x) \<in> Func UNIV (B \<union> {x})"
|
traytel@52635
|
133 |
unfolding Func_def by (auto dest: the_inv_into_into)
|
traytel@52635
|
134 |
|
traytel@52635
|
135 |
lemma If_the_inv_into_f_f:
|
traytel@52635
|
136 |
"\<lbrakk>i \<in> C; inj_on g C\<rbrakk> \<Longrightarrow>
|
traytel@52635
|
137 |
((\<lambda>i. if i \<in> g ` C then the_inv_into C g i else x) o g) i = id i"
|
traytel@52635
|
138 |
unfolding Func_def by (auto elim: the_inv_into_f_f)
|
traytel@52635
|
139 |
|
traytel@52731
|
140 |
definition vimage2p where
|
traytel@52731
|
141 |
"vimage2p f g R = (\<lambda>x y. R (f x) (g y))"
|
traytel@52719
|
142 |
|
traytel@52731
|
143 |
lemma vimage2pI: "R (f x) (g y) \<Longrightarrow> vimage2p f g R x y"
|
traytel@52731
|
144 |
unfolding vimage2p_def by -
|
traytel@52719
|
145 |
|
traytel@52731
|
146 |
lemma fun_rel_iff_leq_vimage2p: "(fun_rel R S) f g = (R \<le> vimage2p f g S)"
|
traytel@52731
|
147 |
unfolding fun_rel_def vimage2p_def by auto
|
traytel@52719
|
148 |
|
traytel@52731
|
149 |
lemma convol_image_vimage2p: "<f o fst, g o snd> ` Collect (split (vimage2p f g R)) \<subseteq> Collect (split R)"
|
traytel@52731
|
150 |
unfolding vimage2p_def convol_def by auto
|
traytel@52719
|
151 |
|
traytel@54961
|
152 |
lemma vimage2p_Grp: "vimage2p f g P = Grp UNIV f OO P OO (Grp UNIV g)\<inverse>\<inverse>"
|
traytel@54961
|
153 |
unfolding vimage2p_def Grp_def by auto
|
traytel@54961
|
154 |
|
blanchet@55062
|
155 |
ML_file "Tools/BNF/bnf_def_tactics.ML"
|
blanchet@55062
|
156 |
ML_file "Tools/BNF/bnf_def.ML"
|
blanchet@49309
|
157 |
|
blanchet@48975
|
158 |
end
|