src/HOL/BNF_FP_Base.thy
changeset 56650 1f9ab71d43a5
parent 56640 0a35354137a5
child 56651 fc105315822a
     1.1 --- a/src/HOL/BNF_FP_Base.thy	Wed Apr 23 10:23:27 2014 +0200
     1.2 +++ b/src/HOL/BNF_FP_Base.thy	Wed Apr 23 10:23:27 2014 +0200
     1.3 @@ -163,11 +163,58 @@
     1.4  lemma vimage2p_comp: "vimage2p (f1 \<circ> f2) (g1 \<circ> g2) = vimage2p f2 g2 \<circ> vimage2p f1 g1"
     1.5    unfolding fun_eq_iff vimage2p_def o_apply by simp
     1.6  
     1.7 +lemma fun_cong_unused_0: "f = (\<lambda>x. g) \<Longrightarrow> f (\<lambda>x. 0) = g"
     1.8 +  by (erule arg_cong)
     1.9 +
    1.10 +lemma snd_o_convol: "(snd \<circ> (\<lambda>x. (f x, g x))) = g"
    1.11 +  by (rule ext) simp
    1.12 +
    1.13 +lemma inj_on_convol_id: "inj_on (\<lambda>x. (x, f x)) X"
    1.14 +  unfolding inj_on_def by simp
    1.15 +
    1.16 +lemma case_prod_app: "case_prod f x y = case_prod (\<lambda>l r. f l r y) x"
    1.17 +  by (case_tac x) simp
    1.18 +
    1.19 +lemma case_sum_map_sum: "case_sum l r (map_sum f g x) = case_sum (l \<circ> f) (r \<circ> g) x"
    1.20 +  by (case_tac x) simp+
    1.21 +
    1.22 +lemma case_prod_map_prod: "case_prod h (map_prod f g x) = case_prod (\<lambda>l r. h (f l) (g r)) x"
    1.23 +  by (case_tac x) simp+
    1.24 +
    1.25 +lemma prod_inj_map: "inj f \<Longrightarrow> inj g \<Longrightarrow> inj (map_prod f g)"
    1.26 +  by (simp add: inj_on_def)
    1.27 +
    1.28 +
    1.29  ML_file "Tools/BNF/bnf_fp_util.ML"
    1.30  ML_file "Tools/BNF/bnf_fp_def_sugar_tactics.ML"
    1.31 +ML_file "Tools/BNF/bnf_lfp_size.ML"
    1.32  ML_file "Tools/BNF/bnf_fp_def_sugar.ML"
    1.33  ML_file "Tools/BNF/bnf_fp_n2m_tactics.ML"
    1.34  ML_file "Tools/BNF/bnf_fp_n2m.ML"
    1.35  ML_file "Tools/BNF/bnf_fp_n2m_sugar.ML"
    1.36  
    1.37 +ML_file "Tools/Function/size.ML"
    1.38 +setup Size.setup
    1.39 +
    1.40 +lemma size_bool[code]: "size (b\<Colon>bool) = 0"
    1.41 +  by (cases b) auto
    1.42 +
    1.43 +lemma nat_size[simp, code]: "size (n\<Colon>nat) = n"
    1.44 +  by (induct n) simp_all
    1.45 +
    1.46 +declare prod.size[no_atp]
    1.47 +
    1.48 +lemma sum_size_o_map: "sum_size g1 g2 \<circ> map_sum f1 f2 = sum_size (g1 \<circ> f1) (g2 \<circ> f2)"
    1.49 +  by (rule ext) (case_tac x, auto)
    1.50 +
    1.51 +lemma prod_size_o_map: "prod_size g1 g2 \<circ> map_prod f1 f2 = prod_size (g1 \<circ> f1) (g2 \<circ> f2)"
    1.52 +  by (rule ext) auto
    1.53 +
    1.54 +setup {*
    1.55 +BNF_LFP_Size.register_size @{type_name sum} @{const_name sum_size} @{thms sum.size}
    1.56 +  @{thms sum_size_o_map}
    1.57 +#> BNF_LFP_Size.register_size @{type_name prod} @{const_name prod_size} @{thms prod.size}
    1.58 +  @{thms prod_size_o_map}
    1.59 +*}
    1.60 +
    1.61  end