src/HOL/Codatatype/BNF_FP.thy
author blanchet
Mon Sep 17 21:33:12 2012 +0200 (2012-09-17)
changeset 49430 6df729c6a1a6
parent 49429 64ac3471005a
child 49451 7a28d22c33c6
permissions -rw-r--r--
tuned simpset
     1 (*  Title:      HOL/Codatatype/BNF_FP.thy
     2     Author:     Dmitriy Traytel, TU Muenchen
     3     Author:     Jasmin Blanchette, TU Muenchen
     4     Copyright   2012
     5 
     6 Composition of bounded natural functors.
     7 *)
     8 
     9 header {* Composition of Bounded Natural Functors *}
    10 
    11 theory BNF_FP
    12 imports BNF_Comp BNF_Wrap
    13 keywords
    14   "defaults"
    15 begin
    16 
    17 lemma case_unit: "(case u of () => f) = f"
    18 by (cases u) (hypsubst, rule unit.cases)
    19 
    20 lemma unit_all_impI: "(P () \<Longrightarrow> Q ()) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
    21 by simp
    22 
    23 lemma prod_all_impI: "(\<And>x y. P (x, y) \<Longrightarrow> Q (x, y)) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
    24 by clarify
    25 
    26 lemma prod_all_impI_step: "(\<And>x. \<forall>y. P (x, y) \<longrightarrow> Q (x, y)) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
    27 by auto
    28 
    29 lemma all_unit_eq: "(\<And>x. PROP P x) \<equiv> PROP P ()"
    30 by simp
    31 
    32 lemma all_prod_eq: "(\<And>x. PROP P x) \<equiv> (\<And>a b. PROP P (a, b))"
    33 by clarsimp
    34 
    35 lemma rev_bspec: "a \<in> A \<Longrightarrow> \<forall>z \<in> A. P z \<Longrightarrow> P a"
    36 by simp
    37 
    38 lemma Un_cong: "\<lbrakk>A = B; C = D\<rbrakk> \<Longrightarrow> A \<union> C = B \<union> D"
    39 by simp
    40 
    41 definition convol ("<_ , _>") where
    42 "<f , g> \<equiv> %a. (f a, g a)"
    43 
    44 lemma fst_convol:
    45 "fst o <f , g> = f"
    46 apply(rule ext)
    47 unfolding convol_def by simp
    48 
    49 lemma snd_convol:
    50 "snd o <f , g> = g"
    51 apply(rule ext)
    52 unfolding convol_def by simp
    53 
    54 lemma pointfree_idE: "f o g = id \<Longrightarrow> f (g x) = x"
    55 unfolding o_def fun_eq_iff by simp
    56 
    57 lemma o_bij:
    58   assumes gf: "g o f = id" and fg: "f o g = id"
    59   shows "bij f"
    60 unfolding bij_def inj_on_def surj_def proof safe
    61   fix a1 a2 assume "f a1 = f a2"
    62   hence "g ( f a1) = g (f a2)" by simp
    63   thus "a1 = a2" using gf unfolding fun_eq_iff by simp
    64 next
    65   fix b
    66   have "b = f (g b)"
    67   using fg unfolding fun_eq_iff by simp
    68   thus "EX a. b = f a" by blast
    69 qed
    70 
    71 lemma ssubst_mem: "\<lbrakk>t = s; s \<in> X\<rbrakk> \<Longrightarrow> t \<in> X" by simp
    72 
    73 lemma sum_case_step:
    74   "sum_case (sum_case f' g') g (Inl p) = sum_case f' g' p"
    75   "sum_case f (sum_case f' g') (Inr p) = sum_case f' g' p"
    76 by auto
    77 
    78 lemma one_pointE: "\<lbrakk>\<And>x. s = x \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
    79 by simp
    80 
    81 lemma obj_one_pointE: "\<forall>x. s = x \<longrightarrow> P \<Longrightarrow> P"
    82 by blast
    83 
    84 lemma obj_sumE_f':
    85 "\<lbrakk>\<forall>x. s = f (Inl x) \<longrightarrow> P; \<forall>x. s = f (Inr x) \<longrightarrow> P\<rbrakk> \<Longrightarrow> s = f x \<longrightarrow> P"
    86 by (cases x) blast+
    87 
    88 lemma obj_sumE_f:
    89 "\<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"
    90 by (rule allI) (rule obj_sumE_f')
    91 
    92 lemma obj_sumE: "\<lbrakk>\<forall>x. s = Inl x \<longrightarrow> P; \<forall>x. s = Inr x \<longrightarrow> P\<rbrakk> \<Longrightarrow> P"
    93 by (cases s) auto
    94 
    95 lemma obj_sum_step':
    96 "\<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"
    97 by (cases x) blast+
    98 
    99 lemma obj_sum_step:
   100 "\<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"
   101 by (rule allI) (rule obj_sum_step')
   102 
   103 lemma sum_case_if:
   104 "sum_case f g (if p then Inl x else Inr y) = (if p then f x else g y)"
   105 by simp
   106 
   107 lemma mem_UN_compreh_eq: "(z : \<Union>{y. \<exists>x\<in>A. y = F x}) = (\<exists>x\<in>A. z : F x)"
   108 by blast
   109 
   110 lemma prod_set_simps:
   111 "fsts (x, y) = {x}"
   112 "snds (x, y) = {y}"
   113 unfolding fsts_def snds_def by simp+
   114 
   115 lemma sum_set_simps:
   116 "sum_setl (Inl x) = {x}"
   117 "sum_setl (Inr x) = {}"
   118 "sum_setr (Inl x) = {}"
   119 "sum_setr (Inr x) = {x}"
   120 unfolding sum_setl_def sum_setr_def by simp+
   121 
   122 ML_file "Tools/bnf_fp_util.ML"
   123 ML_file "Tools/bnf_fp_sugar_tactics.ML"
   124 ML_file "Tools/bnf_fp_sugar.ML"
   125 
   126 end