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