src/HOL/BNF/BNF_FP.thy
author blanchet
Tue Oct 02 01:00:18 2012 +0200 (2012-10-02)
changeset 49683 78a3d5006cf1
parent 49642 9f884142334c
child 51740 97c116445b65
permissions -rw-r--r--
continued changing type of corec type
blanchet@49509
     1
(*  Title:      HOL/BNF/BNF_FP.thy
blanchet@49308
     2
    Author:     Dmitriy Traytel, TU Muenchen
blanchet@49308
     3
    Author:     Jasmin Blanchette, TU Muenchen
blanchet@49308
     4
    Copyright   2012
blanchet@49308
     5
blanchet@49308
     6
Composition of bounded natural functors.
blanchet@49308
     7
*)
blanchet@49308
     8
blanchet@49308
     9
header {* Composition of Bounded Natural Functors *}
blanchet@49308
    10
blanchet@49308
    11
theory BNF_FP
blanchet@49308
    12
imports BNF_Comp BNF_Wrap
blanchet@49308
    13
keywords
blanchet@49308
    14
  "defaults"
blanchet@49308
    15
begin
blanchet@49308
    16
blanchet@49590
    17
lemma mp_conj: "(P \<longrightarrow> Q) \<and> R \<Longrightarrow> P \<Longrightarrow> R \<and> Q"
blanchet@49590
    18
by auto
blanchet@49590
    19
blanchet@49591
    20
lemma eq_sym_Unity_conv: "(x = (() = ())) = x"
blanchet@49585
    21
by blast
blanchet@49585
    22
blanchet@49539
    23
lemma unit_case_Unity: "(case u of () => f) = f"
blanchet@49312
    24
by (cases u) (hypsubst, rule unit.cases)
blanchet@49312
    25
blanchet@49539
    26
lemma prod_case_Pair_iden: "(case p of (x, y) \<Rightarrow> (x, y)) = p"
blanchet@49539
    27
by simp
blanchet@49539
    28
blanchet@49335
    29
lemma unit_all_impI: "(P () \<Longrightarrow> Q ()) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
blanchet@49335
    30
by simp
blanchet@49335
    31
blanchet@49335
    32
lemma prod_all_impI: "(\<And>x y. P (x, y) \<Longrightarrow> Q (x, y)) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
blanchet@49335
    33
by clarify
blanchet@49335
    34
blanchet@49335
    35
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
    36
by auto
blanchet@49335
    37
blanchet@49368
    38
lemma all_unit_eq: "(\<And>x. PROP P x) \<equiv> PROP P ()"
blanchet@49368
    39
by simp
blanchet@49312
    40
blanchet@49368
    41
lemma all_prod_eq: "(\<And>x. PROP P x) \<equiv> (\<And>a b. PROP P (a, b))"
blanchet@49368
    42
by clarsimp
blanchet@49312
    43
blanchet@49312
    44
lemma rev_bspec: "a \<in> A \<Longrightarrow> \<forall>z \<in> A. P z \<Longrightarrow> P a"
blanchet@49312
    45
by simp
blanchet@49312
    46
blanchet@49312
    47
lemma Un_cong: "\<lbrakk>A = B; C = D\<rbrakk> \<Longrightarrow> A \<union> C = B \<union> D"
blanchet@49312
    48
by simp
blanchet@49312
    49
blanchet@49683
    50
lemma pointfree_idE: "f \<circ> g = id \<Longrightarrow> f (g x) = x"
blanchet@49312
    51
unfolding o_def fun_eq_iff by simp
blanchet@49312
    52
blanchet@49312
    53
lemma o_bij:
blanchet@49683
    54
  assumes gf: "g \<circ> f = id" and fg: "f \<circ> g = id"
blanchet@49312
    55
  shows "bij f"
blanchet@49312
    56
unfolding bij_def inj_on_def surj_def proof safe
blanchet@49312
    57
  fix a1 a2 assume "f a1 = f a2"
blanchet@49312
    58
  hence "g ( f a1) = g (f a2)" by simp
blanchet@49312
    59
  thus "a1 = a2" using gf unfolding fun_eq_iff by simp
blanchet@49312
    60
next
blanchet@49312
    61
  fix b
blanchet@49312
    62
  have "b = f (g b)"
blanchet@49312
    63
  using fg unfolding fun_eq_iff by simp
blanchet@49312
    64
  thus "EX a. b = f a" by blast
blanchet@49312
    65
qed
blanchet@49312
    66
blanchet@49312
    67
lemma ssubst_mem: "\<lbrakk>t = s; s \<in> X\<rbrakk> \<Longrightarrow> t \<in> X" by simp
blanchet@49312
    68
blanchet@49312
    69
lemma sum_case_step:
blanchet@49683
    70
"sum_case (sum_case f' g') g (Inl p) = sum_case f' g' p"
blanchet@49683
    71
"sum_case f (sum_case f' g') (Inr p) = sum_case f' g' p"
blanchet@49312
    72
by auto
blanchet@49312
    73
blanchet@49312
    74
lemma one_pointE: "\<lbrakk>\<And>x. s = x \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
blanchet@49312
    75
by simp
blanchet@49312
    76
blanchet@49312
    77
lemma obj_one_pointE: "\<forall>x. s = x \<longrightarrow> P \<Longrightarrow> P"
blanchet@49312
    78
by blast
blanchet@49312
    79
blanchet@49325
    80
lemma obj_sumE_f':
blanchet@49325
    81
"\<lbrakk>\<forall>x. s = f (Inl x) \<longrightarrow> P; \<forall>x. s = f (Inr x) \<longrightarrow> P\<rbrakk> \<Longrightarrow> s = f x \<longrightarrow> P"
blanchet@49325
    82
by (cases x) blast+
blanchet@49325
    83
blanchet@49312
    84
lemma obj_sumE_f:
blanchet@49312
    85
"\<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"
blanchet@49325
    86
by (rule allI) (rule obj_sumE_f')
blanchet@49312
    87
blanchet@49312
    88
lemma obj_sumE: "\<lbrakk>\<forall>x. s = Inl x \<longrightarrow> P; \<forall>x. s = Inr x \<longrightarrow> P\<rbrakk> \<Longrightarrow> P"
blanchet@49312
    89
by (cases s) auto
blanchet@49312
    90
blanchet@49325
    91
lemma obj_sum_step':
blanchet@49325
    92
"\<lbrakk>\<forall>x. s = f (Inr (Inl x)) \<longrightarrow> P; \<forall>x. s = f (Inr (Inr x)) \<longrightarrow> P\<rbrakk> \<Longrightarrow> s = f (Inr x) \<longrightarrow> P"
blanchet@49325
    93
by (cases x) blast+
blanchet@49325
    94
blanchet@49312
    95
lemma obj_sum_step:
blanchet@49325
    96
"\<lbrakk>\<forall>x. s = f (Inr (Inl x)) \<longrightarrow> P; \<forall>x. s = f (Inr (Inr x)) \<longrightarrow> P\<rbrakk> \<Longrightarrow> \<forall>x. s = f (Inr x) \<longrightarrow> P"
blanchet@49325
    97
by (rule allI) (rule obj_sum_step')
blanchet@49312
    98
blanchet@49312
    99
lemma sum_case_if:
blanchet@49312
   100
"sum_case f g (if p then Inl x else Inr y) = (if p then f x else g y)"
blanchet@49312
   101
by simp
blanchet@49312
   102
blanchet@49683
   103
lemma sum_case_o_inj:
blanchet@49683
   104
"sum_case f g \<circ> Inl = f"
blanchet@49683
   105
"sum_case f g \<circ> Inr = g"
blanchet@49683
   106
by auto
blanchet@49683
   107
blanchet@49683
   108
lemma ident_o_ident: "(\<lambda>x. x) \<circ> (\<lambda>x. x) = (\<lambda>x. x)"
blanchet@49683
   109
by (rule o_def)
blanchet@49683
   110
blanchet@49428
   111
lemma mem_UN_compreh_eq: "(z : \<Union>{y. \<exists>x\<in>A. y = F x}) = (\<exists>x\<in>A. z : F x)"
blanchet@49428
   112
by blast
blanchet@49428
   113
blanchet@49585
   114
lemma UN_compreh_eq_eq:
blanchet@49585
   115
"\<Union>{y. \<exists>x\<in>A. y = {}} = {}"
blanchet@49585
   116
"\<Union>{y. \<exists>x\<in>A. y = {x}} = A"
blanchet@49585
   117
by blast+
blanchet@49585
   118
blanchet@49429
   119
lemma prod_set_simps:
blanchet@49429
   120
"fsts (x, y) = {x}"
blanchet@49429
   121
"snds (x, y) = {y}"
blanchet@49429
   122
unfolding fsts_def snds_def by simp+
blanchet@49429
   123
blanchet@49429
   124
lemma sum_set_simps:
blanchet@49451
   125
"setl (Inl x) = {x}"
blanchet@49451
   126
"setl (Inr x) = {}"
blanchet@49451
   127
"setr (Inl x) = {}"
blanchet@49451
   128
"setr (Inr x) = {x}"
blanchet@49451
   129
unfolding sum_set_defs by simp+
blanchet@49429
   130
blanchet@49642
   131
lemma prod_rel_simp:
blanchet@49642
   132
"prod_rel P Q (x, y) (x', y') \<longleftrightarrow> P x x' \<and> Q y y'"
blanchet@49642
   133
unfolding prod_rel_def by simp
blanchet@49642
   134
blanchet@49642
   135
lemma sum_rel_simps:
blanchet@49642
   136
"sum_rel P Q (Inl x) (Inl x') \<longleftrightarrow> P x x'"
blanchet@49642
   137
"sum_rel P Q (Inr y) (Inr y') \<longleftrightarrow> Q y y'"
blanchet@49642
   138
"sum_rel P Q (Inl x) (Inr y') \<longleftrightarrow> False"
blanchet@49642
   139
"sum_rel P Q (Inr y) (Inl x') \<longleftrightarrow> False"
blanchet@49642
   140
unfolding sum_rel_def by simp+
blanchet@49642
   141
blanchet@49457
   142
ML_file "Tools/bnf_fp.ML"
blanchet@49636
   143
ML_file "Tools/bnf_fp_def_sugar_tactics.ML"
blanchet@49636
   144
ML_file "Tools/bnf_fp_def_sugar.ML"
blanchet@49309
   145
blanchet@49308
   146
end