src/HOL/BNF/BNF_FP_Base.thy
author blanchet
Tue Oct 01 14:05:25 2013 +0200 (2013-10-01)
changeset 54006 9fe1bd54d437
parent 53904 446076262e92
child 54246 8fdb4dc08ed1
permissions -rw-r--r--
renamed theory file
blanchet@53311
     1
(*  Title:      HOL/BNF/BNF_FP_Base.thy
blanchet@53311
     2
    Author:     Lorenz Panny, TU Muenchen
blanchet@49308
     3
    Author:     Dmitriy Traytel, TU Muenchen
blanchet@49308
     4
    Author:     Jasmin Blanchette, TU Muenchen
blanchet@53311
     5
    Copyright   2012, 2013
blanchet@49308
     6
blanchet@53311
     7
Shared fixed point operations on bounded natural functors, including
blanchet@49308
     8
*)
blanchet@49308
     9
blanchet@53311
    10
header {* Shared Fixed Point Operations on Bounded Natural Functors *}
blanchet@49308
    11
blanchet@53311
    12
theory BNF_FP_Base
blanchet@54006
    13
imports BNF_Comp Ctr_Sugar
blanchet@49308
    14
begin
blanchet@49308
    15
blanchet@53900
    16
lemma not_TrueE: "\<not> True \<Longrightarrow> P"
blanchet@53900
    17
by (erule notE, rule TrueI)
blanchet@53900
    18
blanchet@53903
    19
lemma neq_eq_eq_contradict: "\<lbrakk>t \<noteq> u; s = t; s = u\<rbrakk> \<Longrightarrow> P"
blanchet@53903
    20
by fast
blanchet@53903
    21
blanchet@49590
    22
lemma mp_conj: "(P \<longrightarrow> Q) \<and> R \<Longrightarrow> P \<Longrightarrow> R \<and> Q"
blanchet@49590
    23
by auto
blanchet@49590
    24
blanchet@49591
    25
lemma eq_sym_Unity_conv: "(x = (() = ())) = x"
blanchet@49585
    26
by blast
blanchet@49585
    27
blanchet@53903
    28
lemma unit_case_Unity: "(case u of () \<Rightarrow> f) = f"
blanchet@49312
    29
by (cases u) (hypsubst, rule unit.cases)
blanchet@49312
    30
blanchet@49539
    31
lemma prod_case_Pair_iden: "(case p of (x, y) \<Rightarrow> (x, y)) = p"
blanchet@49539
    32
by simp
blanchet@49539
    33
blanchet@49335
    34
lemma unit_all_impI: "(P () \<Longrightarrow> Q ()) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
blanchet@49335
    35
by simp
blanchet@49335
    36
blanchet@49335
    37
lemma prod_all_impI: "(\<And>x y. P (x, y) \<Longrightarrow> Q (x, y)) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
blanchet@49335
    38
by clarify
blanchet@49335
    39
blanchet@49335
    40
lemma prod_all_impI_step: "(\<And>x. \<forall>y. P (x, y) \<longrightarrow> Q (x, y)) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
blanchet@49335
    41
by auto
blanchet@49335
    42
blanchet@49683
    43
lemma pointfree_idE: "f \<circ> g = id \<Longrightarrow> f (g x) = x"
blanchet@49312
    44
unfolding o_def fun_eq_iff by simp
blanchet@49312
    45
blanchet@49312
    46
lemma o_bij:
blanchet@49683
    47
  assumes gf: "g \<circ> f = id" and fg: "f \<circ> g = id"
blanchet@49312
    48
  shows "bij f"
blanchet@49312
    49
unfolding bij_def inj_on_def surj_def proof safe
blanchet@49312
    50
  fix a1 a2 assume "f a1 = f a2"
blanchet@49312
    51
  hence "g ( f a1) = g (f a2)" by simp
blanchet@49312
    52
  thus "a1 = a2" using gf unfolding fun_eq_iff by simp
blanchet@49312
    53
next
blanchet@49312
    54
  fix b
blanchet@49312
    55
  have "b = f (g b)"
blanchet@49312
    56
  using fg unfolding fun_eq_iff by simp
blanchet@49312
    57
  thus "EX a. b = f a" by blast
blanchet@49312
    58
qed
blanchet@49312
    59
blanchet@49312
    60
lemma ssubst_mem: "\<lbrakk>t = s; s \<in> X\<rbrakk> \<Longrightarrow> t \<in> X" by simp
blanchet@49312
    61
blanchet@49312
    62
lemma sum_case_step:
blanchet@49683
    63
"sum_case (sum_case f' g') g (Inl p) = sum_case f' g' p"
blanchet@49683
    64
"sum_case f (sum_case f' g') (Inr p) = sum_case f' g' p"
blanchet@49312
    65
by auto
blanchet@49312
    66
blanchet@49312
    67
lemma one_pointE: "\<lbrakk>\<And>x. s = x \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
blanchet@49312
    68
by simp
blanchet@49312
    69
blanchet@49312
    70
lemma obj_one_pointE: "\<forall>x. s = x \<longrightarrow> P \<Longrightarrow> P"
blanchet@49312
    71
by blast
blanchet@49312
    72
blanchet@49312
    73
lemma obj_sumE_f:
blanchet@49312
    74
"\<lbrakk>\<forall>x. s = f (Inl x) \<longrightarrow> P; \<forall>x. s = f (Inr x) \<longrightarrow> P\<rbrakk> \<Longrightarrow> \<forall>x. s = f x \<longrightarrow> P"
traytel@52660
    75
by (rule allI) (metis sumE)
blanchet@49312
    76
blanchet@49312
    77
lemma obj_sumE: "\<lbrakk>\<forall>x. s = Inl x \<longrightarrow> P; \<forall>x. s = Inr x \<longrightarrow> P\<rbrakk> \<Longrightarrow> P"
blanchet@49312
    78
by (cases s) auto
blanchet@49312
    79
blanchet@49312
    80
lemma sum_case_if:
blanchet@49312
    81
"sum_case f g (if p then Inl x else Inr y) = (if p then f x else g y)"
blanchet@49312
    82
by simp
blanchet@49312
    83
blanchet@49428
    84
lemma mem_UN_compreh_eq: "(z : \<Union>{y. \<exists>x\<in>A. y = F x}) = (\<exists>x\<in>A. z : F x)"
blanchet@49428
    85
by blast
blanchet@49428
    86
blanchet@49585
    87
lemma UN_compreh_eq_eq:
blanchet@49585
    88
"\<Union>{y. \<exists>x\<in>A. y = {}} = {}"
blanchet@49585
    89
"\<Union>{y. \<exists>x\<in>A. y = {x}} = A"
blanchet@49585
    90
by blast+
blanchet@49585
    91
blanchet@51745
    92
lemma Inl_Inr_False: "(Inl x = Inr y) = False"
blanchet@51745
    93
by simp
blanchet@51745
    94
blanchet@49429
    95
lemma prod_set_simps:
blanchet@49429
    96
"fsts (x, y) = {x}"
blanchet@49429
    97
"snds (x, y) = {y}"
blanchet@49429
    98
unfolding fsts_def snds_def by simp+
blanchet@49429
    99
blanchet@49429
   100
lemma sum_set_simps:
blanchet@49451
   101
"setl (Inl x) = {x}"
blanchet@49451
   102
"setl (Inr x) = {}"
blanchet@49451
   103
"setr (Inl x) = {}"
blanchet@49451
   104
"setr (Inr x) = {x}"
blanchet@49451
   105
unfolding sum_set_defs by simp+
blanchet@49429
   106
blanchet@49642
   107
lemma prod_rel_simp:
blanchet@49642
   108
"prod_rel P Q (x, y) (x', y') \<longleftrightarrow> P x x' \<and> Q y y'"
blanchet@49642
   109
unfolding prod_rel_def by simp
blanchet@49642
   110
blanchet@49642
   111
lemma sum_rel_simps:
blanchet@49642
   112
"sum_rel P Q (Inl x) (Inl x') \<longleftrightarrow> P x x'"
blanchet@49642
   113
"sum_rel P Q (Inr y) (Inr y') \<longleftrightarrow> Q y y'"
blanchet@49642
   114
"sum_rel P Q (Inl x) (Inr y') \<longleftrightarrow> False"
blanchet@49642
   115
"sum_rel P Q (Inr y) (Inl x') \<longleftrightarrow> False"
blanchet@49642
   116
unfolding sum_rel_def by simp+
blanchet@49642
   117
traytel@52505
   118
lemma spec2: "\<forall>x y. P x y \<Longrightarrow> P x y"
traytel@52505
   119
by blast
traytel@52505
   120
traytel@52913
   121
lemma rewriteR_comp_comp: "\<lbrakk>g o h = r\<rbrakk> \<Longrightarrow> f o g o h = f o r"
traytel@52913
   122
  unfolding o_def fun_eq_iff by auto
traytel@52913
   123
traytel@52913
   124
lemma rewriteR_comp_comp2: "\<lbrakk>g o h = r1 o r2; f o r1 = l\<rbrakk> \<Longrightarrow> f o g o h = l o r2"
traytel@52913
   125
  unfolding o_def fun_eq_iff by auto
traytel@52913
   126
traytel@52913
   127
lemma rewriteL_comp_comp: "\<lbrakk>f o g = l\<rbrakk> \<Longrightarrow> f o (g o h) = l o h"
traytel@52913
   128
  unfolding o_def fun_eq_iff by auto
traytel@52913
   129
traytel@52913
   130
lemma rewriteL_comp_comp2: "\<lbrakk>f o g = l1 o l2; l2 o h = r\<rbrakk> \<Longrightarrow> f o (g o h) = l1 o r"
traytel@52913
   131
  unfolding o_def fun_eq_iff by auto
traytel@52913
   132
traytel@52913
   133
lemma convol_o: "<f, g> o h = <f o h, g o h>"
traytel@52913
   134
  unfolding convol_def by auto
traytel@52913
   135
traytel@52913
   136
lemma map_pair_o_convol: "map_pair h1 h2 o <f, g> = <h1 o f, h2 o g>"
traytel@52913
   137
  unfolding convol_def by auto
traytel@52913
   138
traytel@52913
   139
lemma map_pair_o_convol_id: "(map_pair f id \<circ> <id , g>) x = <id \<circ> f , g> x"
traytel@52913
   140
  unfolding map_pair_o_convol id_o o_id ..
traytel@52913
   141
traytel@52913
   142
lemma o_sum_case: "h o sum_case f g = sum_case (h o f) (h o g)"
traytel@52913
   143
  unfolding o_def by (auto split: sum.splits)
traytel@52913
   144
traytel@52913
   145
lemma sum_case_o_sum_map: "sum_case f g o sum_map h1 h2 = sum_case (f o h1) (g o h2)"
traytel@52913
   146
  unfolding o_def by (auto split: sum.splits)
traytel@52913
   147
traytel@52913
   148
lemma sum_case_o_sum_map_id: "(sum_case id g o sum_map f id) x = sum_case (f o id) g x"
traytel@52913
   149
  unfolding sum_case_o_sum_map id_o o_id ..
traytel@52913
   150
traytel@52731
   151
lemma fun_rel_def_butlast:
traytel@52731
   152
  "(fun_rel R (fun_rel S T)) f g = (\<forall>x y. R x y \<longrightarrow> (fun_rel S T) (f x) (g y))"
traytel@52731
   153
  unfolding fun_rel_def ..
traytel@52731
   154
traytel@53105
   155
lemma subst_eq_imp: "(\<forall>a b. a = b \<longrightarrow> P a b) \<equiv> (\<forall>a. P a a)"
traytel@53105
   156
  by auto
traytel@53105
   157
traytel@53105
   158
lemma eq_subset: "op = \<le> (\<lambda>a b. P a b \<or> a = b)"
traytel@53105
   159
  by auto
traytel@53105
   160
blanchet@53308
   161
lemma eq_le_Grp_id_iff: "(op = \<le> Grp (Collect R) id) = (All R)"
blanchet@53308
   162
  unfolding Grp_def id_apply by blast
blanchet@53308
   163
blanchet@53308
   164
lemma Grp_id_mono_subst: "(\<And>x y. Grp P id x y \<Longrightarrow> Grp Q id (f x) (f y)) \<equiv>
blanchet@53308
   165
   (\<And>x. x \<in> P \<Longrightarrow> f x \<in> Q)"
blanchet@53308
   166
  unfolding Grp_def by rule auto
blanchet@53308
   167
blanchet@51850
   168
ML_file "Tools/bnf_fp_util.ML"
blanchet@49636
   169
ML_file "Tools/bnf_fp_def_sugar_tactics.ML"
blanchet@49636
   170
ML_file "Tools/bnf_fp_def_sugar.ML"
blanchet@53308
   171
ML_file "Tools/bnf_fp_n2m_tactics.ML"
blanchet@53308
   172
ML_file "Tools/bnf_fp_n2m.ML"
blanchet@53308
   173
ML_file "Tools/bnf_fp_n2m_sugar.ML"
blanchet@53305
   174
ML_file "Tools/bnf_fp_rec_sugar_util.ML"
blanchet@53305
   175
ML_file "Tools/bnf_fp_rec_sugar_tactics.ML"
blanchet@53305
   176
ML_file "Tools/bnf_fp_rec_sugar.ML"
blanchet@49309
   177
blanchet@49308
   178
end