src/HOL/BNF_Composition.thy
author paulson <lp15@cam.ac.uk>
Mon, 22 Apr 2024 22:08:28 +0100
changeset 80142 34e0ddfc6dcc
parent 75624 22d1c5f2b9f4
permissions -rw-r--r--
More tidying of Nominal proofs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
     1
(*  Title:      HOL/BNF_Composition.thy
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     2
    Author:     Dmitriy Traytel, TU Muenchen
57698
afef6616cbae header tuning
blanchet
parents: 56166
diff changeset
     3
    Author:     Jasmin Blanchette, TU Muenchen
75624
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
     4
    Author:     Jan van Brügge, TU Muenchen
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
     5
    Copyright   2012, 2013, 2014, 2022
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     6
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     7
Composition of bounded natural functors.
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     8
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     9
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    10
section \<open>Composition of Bounded Natural Functors\<close>
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    11
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    12
theory BNF_Composition
55936
f6591f8c629d rationalized imports
traytel
parents: 55935
diff changeset
    13
imports BNF_Def
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    14
begin
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    15
60918
4ceef1592e8c new command for lifting BNF structure over typedefs
traytel
parents: 60758
diff changeset
    16
lemma ssubst_mem: "\<lbrakk>t = s; s \<in> X\<rbrakk> \<Longrightarrow> t \<in> X"
4ceef1592e8c new command for lifting BNF structure over typedefs
traytel
parents: 60758
diff changeset
    17
  by simp
4ceef1592e8c new command for lifting BNF structure over typedefs
traytel
parents: 60758
diff changeset
    18
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
    19
lemma empty_natural: "(\<lambda>_. {}) \<circ> f = image g \<circ> (\<lambda>_. {})"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    20
  by (rule ext) simp
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    21
75624
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    22
lemma Cinfinite_gt_empty: "Cinfinite r \<Longrightarrow> |{}| <o r"
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    23
  by (simp add: cinfinite_def finite_ordLess_infinite card_of_ordIso_finite Field_card_of card_of_well_order_on emptyI card_order_on_well_order_on)
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    24
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
    25
lemma Union_natural: "Union \<circ> image (image f) = image f \<circ> Union"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    26
  by (rule ext) (auto simp only: comp_apply)
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    27
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
    28
lemma in_Union_o_assoc: "x \<in> (Union \<circ> gset \<circ> gmap) A \<Longrightarrow> x \<in> (Union \<circ> (gset \<circ> gmap)) A"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    29
  by (unfold comp_assoc)
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    30
75624
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    31
lemma regularCard_UNION_bound:
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    32
  assumes "Cinfinite r" "regularCard r" and "|I| <o r" "\<And>i. i \<in> I \<Longrightarrow> |A i| <o r"
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    33
  shows "|\<Union>i\<in>I. A i| <o r"
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    34
  using assms cinfinite_def regularCard_stable stable_UNION by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    35
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    36
lemma comp_single_set_bd_strict:
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    37
  assumes fbd: "Cinfinite fbd" "regularCard fbd" and
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    38
    gbd: "Cinfinite gbd" "regularCard gbd" and
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    39
    fset_bd: "\<And>x. |fset x| <o fbd" and
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    40
    gset_bd: "\<And>x. |gset x| <o gbd"
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    41
  shows "|\<Union>(fset ` gset x)| <o gbd *c fbd"
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    42
proof (cases "fbd <o gbd")
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    43
  case True
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    44
  then have "|fset x| <o gbd" for x using fset_bd ordLess_transitive by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    45
  then have "|\<Union>(fset ` gset x)| <o gbd" using regularCard_UNION_bound[OF gbd gset_bd] by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    46
  then have "|\<Union> (fset ` gset x)| <o fbd *c gbd"
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    47
    using ordLess_ordLeq_trans ordLeq_cprod2 gbd(1) fbd(1) cinfinite_not_czero by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    48
  then show ?thesis using ordLess_ordIso_trans cprod_com by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    49
next
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    50
  case False
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    51
  have "Well_order fbd" "Well_order gbd" using fbd(1) gbd(1) card_order_on_well_order_on by auto
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    52
  then have "gbd \<le>o fbd" using not_ordLess_iff_ordLeq False by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    53
  then have "|gset x| <o fbd" for x using gset_bd ordLess_ordLeq_trans by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    54
  then have "|\<Union>(fset ` gset x)| <o fbd" using regularCard_UNION_bound[OF fbd] fset_bd by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    55
  then show ?thesis using ordLess_ordLeq_trans ordLeq_cprod2 gbd(1) fbd(1) cinfinite_not_czero by blast
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    56
qed
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
    57
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    58
lemma comp_single_set_bd:
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    59
  assumes fbd_Card_order: "Card_order fbd" and
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    60
    fset_bd: "\<And>x. |fset x| \<le>o fbd" and
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    61
    gset_bd: "\<And>x. |gset x| \<le>o gbd"
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51893
diff changeset
    62
  shows "|\<Union>(fset ` gset x)| \<le>o gbd *c fbd"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    63
  apply simp
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    64
  apply (rule ordLeq_transitive)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    65
  apply (rule card_of_UNION_Sigma)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    66
  apply (subst SIGMA_CSUM)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    67
  apply (rule ordLeq_transitive)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    68
  apply (rule card_of_Csum_Times')
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    69
  apply (rule fbd_Card_order)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    70
  apply (rule ballI)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    71
  apply (rule fset_bd)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    72
  apply (rule ordLeq_transitive)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    73
  apply (rule cprod_mono1)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    74
  apply (rule gset_bd)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    75
  apply (rule ordIso_imp_ordLeq)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    76
  apply (rule ordIso_refl)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    77
  apply (rule Card_order_cprod)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    78
  done
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    79
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
    80
lemma csum_dup: "cinfinite r \<Longrightarrow> Card_order r \<Longrightarrow> p +c p' =o r +c r \<Longrightarrow> p +c p' =o r"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    81
  apply (erule ordIso_transitive)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    82
  apply (frule csum_absorb2')
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    83
  apply (erule ordLeq_refl)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    84
  by simp
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
    85
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
    86
lemma cprod_dup: "cinfinite r \<Longrightarrow> Card_order r \<Longrightarrow> p *c p' =o r *c r \<Longrightarrow> p *c p' =o r"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    87
  apply (erule ordIso_transitive)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    88
  apply (rule cprod_infinite)
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    89
  by simp
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
    90
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51893
diff changeset
    91
lemma Union_image_insert: "\<Union>(f ` insert a B) = f a \<union> \<Union>(f ` B)"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    92
  by simp
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    93
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51893
diff changeset
    94
lemma Union_image_empty: "A \<union> \<Union>(f ` {}) = A"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    95
  by simp
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    96
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
    97
lemma image_o_collect: "collect ((\<lambda>f. image g \<circ> f) ` F) = image g \<circ> collect F"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
    98
  by (rule ext) (auto simp add: collect_def)
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
    99
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   100
lemma conj_subset_def: "A \<subseteq> {x. P x \<and> Q x} = (A \<subseteq> {x. P x} \<and> A \<subseteq> {x. Q x})"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   101
  by blast
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   102
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51893
diff changeset
   103
lemma UN_image_subset: "\<Union>(f ` g x) \<subseteq> X = (g x \<subseteq> {x. f x \<subseteq> X})"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   104
  by blast
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   105
69745
aec42cee2521 more canonical and less specialized syntax
nipkow
parents: 69605
diff changeset
   106
lemma comp_set_bd_Union_o_collect: "|\<Union>(\<Union>((\<lambda>f. f x) ` X))| \<le>o hbd \<Longrightarrow> |(Union \<circ> collect X) x| \<le>o hbd"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   107
  by (unfold comp_apply collect_def) simp
49312
c874ff5658dc moved theorems closer to where they are used
blanchet
parents: 49309
diff changeset
   108
75624
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
   109
lemma comp_set_bd_Union_o_collect_strict: "|\<Union>(\<Union>((\<lambda>f. f x) ` X))| <o hbd \<Longrightarrow> |(Union \<circ> collect X) x| <o hbd"
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
   110
  by (unfold comp_apply collect_def) simp
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
   111
62324
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   112
lemma Collect_inj: "Collect P = Collect Q \<Longrightarrow> P = Q"
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   113
  by blast
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   114
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
   115
lemma Grp_fst_snd: "(Grp (Collect (case_prod R)) fst)\<inverse>\<inverse> OO Grp (Collect (case_prod R)) snd = R"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   116
  unfolding Grp_def fun_eq_iff relcompp.simps by auto
51893
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 49512
diff changeset
   117
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
   118
lemma OO_Grp_cong: "A = B \<Longrightarrow> (Grp A f)\<inverse>\<inverse> OO Grp A g = (Grp B f)\<inverse>\<inverse> OO Grp B g"
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   119
  by (rule arg_cong)
51893
596baae88a88 got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents: 49512
diff changeset
   120
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   121
lemma vimage2p_relcompp_mono: "R OO S \<le> T \<Longrightarrow>
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   122
  vimage2p f g R OO vimage2p g h S \<le> vimage2p f h T"
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   123
  unfolding vimage2p_def by auto
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   124
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   125
lemma type_copy_map_cong0: "M (g x) = N (h x) \<Longrightarrow> (f \<circ> M \<circ> g) x = (f \<circ> N \<circ> h) x"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   126
  by auto
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   127
75624
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
   128
lemma type_copy_set_bd: "(\<And>y. |S y| <o bd) \<Longrightarrow> |(S \<circ> Rep) x| <o bd"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   129
  by auto
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   130
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   131
lemma vimage2p_cong: "R = S \<Longrightarrow> vimage2p f g R = vimage2p f g S"
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   132
  by simp
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   133
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   134
lemma Ball_comp_iff: "(\<lambda>x. Ball (A x) f) \<circ> g = (\<lambda>x. Ball ((A \<circ> g) x) f)"
62324
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   135
  unfolding o_def by auto
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   136
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   137
lemma conj_comp_iff: "(\<lambda>x. P x \<and> Q x) \<circ> g = (\<lambda>x. (P \<circ> g) x \<and> (Q \<circ> g) x)"
62324
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   138
  unfolding o_def by auto
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   139
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   140
context
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   141
  fixes Rep Abs
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   142
  assumes type_copy: "type_definition Rep Abs UNIV"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   143
begin
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   144
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   145
lemma type_copy_map_id0: "M = id \<Longrightarrow> Abs \<circ> M \<circ> Rep = id"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   146
  using type_definition.Rep_inverse[OF type_copy] by auto
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   147
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   148
lemma type_copy_map_comp0: "M = M1 \<circ> M2 \<Longrightarrow> f \<circ> M \<circ> g = (f \<circ> M1 \<circ> Rep) \<circ> (Abs \<circ> M2 \<circ> g)"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   149
  using type_definition.Abs_inverse[OF type_copy UNIV_I] by auto
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   150
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   151
lemma type_copy_set_map0: "S \<circ> M = image f \<circ> S' \<Longrightarrow> (S \<circ> Rep) \<circ> (Abs \<circ> M \<circ> g) = image f \<circ> (S' \<circ> g)"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   152
  using type_definition.Abs_inverse[OF type_copy UNIV_I] by (auto simp: o_def fun_eq_iff)
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   153
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   154
lemma type_copy_wit: "x \<in> (S \<circ> Rep) (Abs y) \<Longrightarrow> x \<in> S y"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   155
  using type_definition.Abs_inverse[OF type_copy UNIV_I] by auto
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   156
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   157
lemma type_copy_vimage2p_Grp_Rep: "vimage2p f Rep (Grp (Collect P) h) =
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   158
    Grp (Collect (\<lambda>x. P (f x))) (Abs \<circ> h \<circ> f)"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   159
  unfolding vimage2p_def Grp_def fun_eq_iff
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   160
  by (auto simp: type_definition.Abs_inverse[OF type_copy UNIV_I]
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   161
   type_definition.Rep_inverse[OF type_copy] dest: sym)
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   162
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   163
lemma type_copy_vimage2p_Grp_Abs:
67091
1393c2340eec more symbols;
wenzelm
parents: 62777
diff changeset
   164
  "\<And>h. vimage2p g Abs (Grp (Collect P) h) = Grp (Collect (\<lambda>x. P (g x))) (Rep \<circ> h \<circ> g)"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   165
  unfolding vimage2p_def Grp_def fun_eq_iff
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   166
  by (auto simp: type_definition.Abs_inverse[OF type_copy UNIV_I]
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   167
   type_definition.Rep_inverse[OF type_copy] dest: sym)
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   168
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   169
lemma type_copy_ex_RepI: "(\<exists>b. F b) = (\<exists>b. F (Rep b))"
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   170
proof safe
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   171
  fix b assume "F b"
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   172
  show "\<exists>b'. F (Rep b')"
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   173
  proof (rule exI)
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   174
    from \<open>F b\<close> show "F (Rep (Abs b))" using type_definition.Abs_inverse[OF type_copy] by auto
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   175
  qed
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   176
qed blast
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   177
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   178
lemma vimage2p_relcompp_converse:
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
   179
  "vimage2p f g (R\<inverse>\<inverse> OO S) = (vimage2p Rep f R)\<inverse>\<inverse> OO vimage2p Rep g S"
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   180
  unfolding vimage2p_def relcompp.simps conversep.simps fun_eq_iff image_def
55811
aa1acc25126b load Metis a little later
traytel
parents: 55803
diff changeset
   181
  by (auto simp: type_copy_ex_RepI)
55803
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   182
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   183
end
74d3fe9031d8 joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents: 55705
diff changeset
   184
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   185
bnf DEADID: 'a
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   186
  map: "id :: 'a \<Rightarrow> 'a"
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   187
  bd: natLeq
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67091
diff changeset
   188
  rel: "(=) :: 'a \<Rightarrow> 'a \<Rightarrow> bool"
75624
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
   189
  by (auto simp add: natLeq_card_order natLeq_cinfinite regularCard_natLeq)
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   190
58353
c9f374b64d99 tuned fact visibility
blanchet
parents: 58282
diff changeset
   191
definition id_bnf :: "'a \<Rightarrow> 'a" where
c9f374b64d99 tuned fact visibility
blanchet
parents: 58282
diff changeset
   192
  "id_bnf \<equiv> (\<lambda>x. x)"
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   193
58181
6d527272f7b2 renamed internal constant
blanchet
parents: 58128
diff changeset
   194
lemma id_bnf_apply: "id_bnf x = x"
6d527272f7b2 renamed internal constant
blanchet
parents: 58128
diff changeset
   195
  unfolding id_bnf_def by simp
56016
8875cdcfc85b unfold intermediate definitions after sealing the bnf
traytel
parents: 55936
diff changeset
   196
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   197
bnf ID: 'a
58181
6d527272f7b2 renamed internal constant
blanchet
parents: 58128
diff changeset
   198
  map: "id_bnf :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
55935
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   199
  sets: "\<lambda>x. {x}"
8f20d09d294e move special BNFs used for composition only to BNF_Comp;
traytel
parents: 55930
diff changeset
   200
  bd: natLeq
58181
6d527272f7b2 renamed internal constant
blanchet
parents: 58128
diff changeset
   201
  rel: "id_bnf :: ('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
62324
ae44f16dcea5 make predicator a first-class bnf citizen
traytel
parents: 61032
diff changeset
   202
  pred: "id_bnf :: ('a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> bool"
58181
6d527272f7b2 renamed internal constant
blanchet
parents: 58128
diff changeset
   203
  unfolding id_bnf_def
75624
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
   204
  apply (auto simp: Grp_def fun_eq_iff relcompp.simps natLeq_card_order natLeq_cinfinite regularCard_natLeq)
22d1c5f2b9f4 strict bounds for BNFs (by Jan van Brügge)
traytel
parents: 71262
diff changeset
   205
  apply (rule finite_ordLess_infinite[OF _ natLeq_Well_order])
58128
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   206
  apply (auto simp add: Field_card_of Field_natLeq card_of_well_order_on)[3]
43a1ba26a8cb renamed BNF theories
blanchet
parents: 57698
diff changeset
   207
  done
55854
ee270328a781 make 'typedef' optional, depending on size of original type
blanchet
parents: 55851
diff changeset
   208
58181
6d527272f7b2 renamed internal constant
blanchet
parents: 58128
diff changeset
   209
lemma type_definition_id_bnf_UNIV: "type_definition id_bnf id_bnf UNIV"
6d527272f7b2 renamed internal constant
blanchet
parents: 58128
diff changeset
   210
  unfolding id_bnf_def by unfold_locales auto
55854
ee270328a781 make 'typedef' optional, depending on size of original type
blanchet
parents: 55851
diff changeset
   211
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 67613
diff changeset
   212
ML_file \<open>Tools/BNF/bnf_comp_tactics.ML\<close>
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 67613
diff changeset
   213
ML_file \<open>Tools/BNF/bnf_comp.ML\<close>
49309
f20b24214ac2 split basic BNFs into really basic ones and others, and added Andreas Lochbihler's "option" BNF
blanchet
parents: 49308
diff changeset
   214
58282
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   215
hide_fact
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   216
  DEADID.inj_map DEADID.inj_map_strong DEADID.map_comp DEADID.map_cong DEADID.map_cong0
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   217
  DEADID.map_cong_simp DEADID.map_id DEADID.map_id0 DEADID.map_ident DEADID.map_transfer
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   218
  DEADID.rel_Grp DEADID.rel_compp DEADID.rel_compp_Grp DEADID.rel_conversep DEADID.rel_eq
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   219
  DEADID.rel_flip DEADID.rel_map DEADID.rel_mono DEADID.rel_transfer
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   220
  ID.inj_map ID.inj_map_strong ID.map_comp ID.map_cong ID.map_cong0 ID.map_cong_simp ID.map_id
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   221
  ID.map_id0 ID.map_ident ID.map_transfer ID.rel_Grp ID.rel_compp ID.rel_compp_Grp ID.rel_conversep
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   222
  ID.rel_eq ID.rel_flip ID.rel_map ID.rel_mono ID.rel_transfer ID.set_map ID.set_transfer
48e16d74845b hide DEADID/ID theorems
blanchet
parents: 58181
diff changeset
   223
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
   224
end