src/HOL/Quotient_Examples/Lift_FSet.thy
author wenzelm
Sun, 02 Nov 2014 18:21:45 +0100
changeset 58889 5b7a9633cfa8
parent 57816 d8bbb97689d3
child 58961 7c507e664047
permissions -rw-r--r--
modernized header uniformly as section;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
     1
(*  Title:      HOL/Quotient_Examples/Lift_FSet.thy
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman, TU Munich
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
     3
*)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
     4
58889
5b7a9633cfa8 modernized header uniformly as section;
wenzelm
parents: 57816
diff changeset
     5
section {* Lifting and transfer with a finite set type *}
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
     6
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
     7
theory Lift_FSet
53013
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
     8
imports Main
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
     9
begin
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    10
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    11
subsection {* Equivalence relation and quotient type definition *}
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    12
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    13
definition list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    14
  where [simp]: "list_eq xs ys \<longleftrightarrow> set xs = set ys"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    15
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    16
lemma reflp_list_eq: "reflp list_eq"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    17
  unfolding reflp_def by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    18
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    19
lemma symp_list_eq: "symp list_eq"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    20
  unfolding symp_def by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    21
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    22
lemma transp_list_eq: "transp list_eq"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    23
  unfolding transp_def by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    24
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    25
lemma equivp_list_eq: "equivp list_eq"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    26
  by (intro equivpI reflp_list_eq symp_list_eq transp_list_eq)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    27
53013
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    28
context
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    29
begin
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    30
interpretation lifting_syntax .
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    31
51376
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    32
lemma list_eq_transfer [transfer_rule]:
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    33
  assumes [transfer_rule]: "bi_unique A"
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    34
  shows "(list_all2 A ===> list_all2 A ===> op =) list_eq list_eq"
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    35
  unfolding list_eq_def [abs_def] by transfer_prover
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    36
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    37
quotient_type 'a fset = "'a list" / "list_eq" parametric list_eq_transfer
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    38
  by (rule equivp_list_eq)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    39
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    40
subsection {* Lifted constant definitions *}
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    41
51994
82cc2aeb7d13 stronger reflexivity prover
kuncar
parents: 51411
diff changeset
    42
lift_definition fnil :: "'a fset" ("{||}") is "[]" parametric Nil_transfer .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    43
51376
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    44
lift_definition fcons :: "'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is Cons parametric Cons_transfer
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    45
  by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    46
51376
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    47
lift_definition fappend :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is append parametric append_transfer
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    48
  by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    49
51376
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    50
lift_definition fmap :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset" is map parametric map_transfer
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    51
  by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    52
51376
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    53
lift_definition ffilter :: "('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is filter parametric filter_transfer
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    54
  by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    55
51376
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    56
lift_definition fset :: "'a fset \<Rightarrow> 'a set" is set parametric set_transfer
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    57
  by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    58
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    59
text {* Constants with nested types (like concat) yield a more
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    60
  complicated proof obligation. *}
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    61
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    62
lemma list_all2_cr_fset:
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    63
  "list_all2 cr_fset xs ys \<longleftrightarrow> map abs_fset xs = ys"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    64
  unfolding cr_fset_def
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    65
  apply safe
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    66
  apply (erule list_all2_induct, simp, simp)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    67
  apply (simp add: list_all2_map2 List.list_all2_refl)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    68
  done
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    69
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    70
lemma abs_fset_eq_iff: "abs_fset xs = abs_fset ys \<longleftrightarrow> list_eq xs ys"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    71
  using Quotient_rel [OF Quotient_fset] by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    72
51376
8e38ff09864a simplify Lift_FSet because we have parametricity in Lifting now
kuncar
parents: 50227
diff changeset
    73
lift_definition fconcat :: "'a fset fset \<Rightarrow> 'a fset" is concat parametric concat_transfer
55732
07906fc6af7a simplify and repair proofs due to df0fda378813
kuncar
parents: 55584
diff changeset
    74
proof (simp only: fset.pcr_cr_eq)
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    75
  fix xss yss :: "'a list list"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    76
  assume "(list_all2 cr_fset OO list_eq OO (list_all2 cr_fset)\<inverse>\<inverse>) xss yss"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    77
  then obtain uss vss where
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    78
    "list_all2 cr_fset xss uss" and "list_eq uss vss" and
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    79
    "list_all2 cr_fset yss vss" by clarsimp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    80
  hence "list_eq (map abs_fset xss) (map abs_fset yss)"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    81
    unfolding list_all2_cr_fset by simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    82
  thus "list_eq (concat xss) (concat yss)"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    83
    apply (simp add: set_eq_iff image_def)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    84
    apply safe
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    85
    apply (rename_tac xs, drule_tac x="abs_fset xs" in spec)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    86
    apply (drule iffD1, fast, clarsimp simp add: abs_fset_eq_iff, fast)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    87
    apply (rename_tac xs, drule_tac x="abs_fset xs" in spec)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    88
    apply (drule iffD2, fast, clarsimp simp add: abs_fset_eq_iff, fast)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    89
    done
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    90
qed
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
    91
53013
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    92
lemma member_transfer:
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    93
  assumes [transfer_rule]: "bi_unique A"
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    94
  shows "(A ===> list_all2 A ===> op=) (\<lambda>x xs. x \<in> set xs) (\<lambda>x xs. x \<in> set xs)"
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    95
by transfer_prover
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    96
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    97
end
3fbcfa911863 remove unnecessary dependencies on Library/Quotient_*
kuncar
parents: 52354
diff changeset
    98
51410
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
    99
syntax
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   100
  "_insert_fset"     :: "args => 'a fset"  ("{|(_)|}")
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   101
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   102
translations
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   103
  "{|x, xs|}" == "CONST fcons x {|xs|}"
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   104
  "{|x|}"     == "CONST fcons x {||}"
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   105
51411
deb59caefdb3 rename fset_member to fmember and prove parametricity
kuncar
parents: 51410
diff changeset
   106
lift_definition fmember :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<in>|" 50) is "\<lambda>x xs. x \<in> set xs"
deb59caefdb3 rename fset_member to fmember and prove parametricity
kuncar
parents: 51410
diff changeset
   107
   parametric member_transfer by simp
51410
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   108
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   109
abbreviation notin_fset :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50) where
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   110
  "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)"
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   111
51411
deb59caefdb3 rename fset_member to fmember and prove parametricity
kuncar
parents: 51410
diff changeset
   112
lemma fmember_fmap[simp]: "a |\<in>| fmap f X = (\<exists>b. b |\<in>| X \<and> a = f b)"
51410
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   113
  by transfer auto
f0865a641e76 BNF uses fset defined via Lifting/Transfer rather than Quotient
traytel
parents: 51376
diff changeset
   114
47937
70375fa2679d generate abs_eq, use it as a code equation for total quotients; no_abs_code renamed to no_code; added no_code for quotient_type command
kuncar
parents: 47676
diff changeset
   115
text {* We can export code: *}
70375fa2679d generate abs_eq, use it as a code equation for total quotients; no_abs_code renamed to no_code; added no_code for quotient_type command
kuncar
parents: 47676
diff changeset
   116
51411
deb59caefdb3 rename fset_member to fmember and prove parametricity
kuncar
parents: 51410
diff changeset
   117
export_code fnil fcons fappend fmap ffilter fset fmember in SML
47937
70375fa2679d generate abs_eq, use it as a code equation for total quotients; no_abs_code renamed to no_code; added no_code for quotient_type command
kuncar
parents: 47676
diff changeset
   118
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   119
subsection {* Using transfer with type @{text "fset"} *}
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   120
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   121
text {* The correspondence relation @{text "cr_fset"} can only relate
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   122
  @{text "list"} and @{text "fset"} types with the same element type.
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   123
  To relate nested types like @{text "'a list list"} and
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   124
  @{text "'a fset fset"}, we define a parameterized version of the
50227
01d545993e8c generate a parameterized correspondence relation
kuncar
parents: 47937
diff changeset
   125
  correspondence relation, @{text "pcr_fset"}. *}
01d545993e8c generate a parameterized correspondence relation
kuncar
parents: 47937
diff changeset
   126
01d545993e8c generate a parameterized correspondence relation
kuncar
parents: 47937
diff changeset
   127
thm pcr_fset_def
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   128
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   129
subsection {* Transfer examples *}
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   130
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   131
text {* The @{text "transfer"} method replaces equality on @{text
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   132
  "fset"} with the @{text "list_eq"} relation on lists, which is
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   133
  logically equivalent. *}
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   134
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   135
lemma "fmap f (fmap g xs) = fmap (f \<circ> g) xs"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   136
  apply transfer
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   137
  apply simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   138
  done
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   139
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   140
text {* The @{text "transfer'"} variant can replace equality on @{text
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   141
  "fset"} with equality on @{text "list"}, which is logically stronger
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   142
  but sometimes more convenient. *}
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   143
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   144
lemma "fmap f (fmap g xs) = fmap (f \<circ> g) xs"
52354
acb4f932dd24 implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
huffman
parents: 51994
diff changeset
   145
  using map_map [Transfer.transferred] .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   146
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   147
lemma "ffilter p (fmap f xs) = fmap f (ffilter (p \<circ> f) xs)"
52354
acb4f932dd24 implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
huffman
parents: 51994
diff changeset
   148
  using filter_map [Transfer.transferred] .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   149
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   150
lemma "ffilter p (ffilter q xs) = ffilter (\<lambda>x. q x \<and> p x) xs"
52354
acb4f932dd24 implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
huffman
parents: 51994
diff changeset
   151
  using filter_filter [Transfer.transferred] .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   152
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   153
lemma "fset (fcons x xs) = insert x (fset xs)"
57816
d8bbb97689d3 no need for 'set_simps' now that 'datatype_new' generates the desired 'set' property
blanchet
parents: 55732
diff changeset
   154
  using list.set(2) [Transfer.transferred] .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   155
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   156
lemma "fset (fappend xs ys) = fset xs \<union> fset ys"
52354
acb4f932dd24 implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
huffman
parents: 51994
diff changeset
   157
  using set_append [Transfer.transferred] .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   158
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   159
lemma "fset (fconcat xss) = (\<Union>xs\<in>fset xss. fset xs)"
52354
acb4f932dd24 implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
huffman
parents: 51994
diff changeset
   160
  using set_concat [Transfer.transferred] .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   161
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   162
lemma "\<forall>x\<in>fset xs. f x = g x \<Longrightarrow> fmap f xs = fmap g xs"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   163
  apply transfer
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   164
  apply (simp cong: map_cong del: set_map)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   165
  done
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   166
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   167
lemma "fnil = fconcat xss \<longleftrightarrow> (\<forall>xs\<in>fset xss. xs = fnil)"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   168
  apply transfer
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   169
  apply simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   170
  done
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   171
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   172
lemma "fconcat (fmap (\<lambda>x. fcons x fnil) xs) = xs"
52354
acb4f932dd24 implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
huffman
parents: 51994
diff changeset
   173
  apply transfer
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   174
  apply simp
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   175
  done
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   176
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   177
lemma concat_map_concat: "concat (map concat xsss) = concat (concat xsss)"
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   178
  by (induct xsss, simp_all)
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   179
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   180
lemma "fconcat (fmap fconcat xss) = fconcat (fconcat xss)"
52354
acb4f932dd24 implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
huffman
parents: 51994
diff changeset
   181
  using concat_map_concat [Transfer.transferred] .
47660
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   182
7a5c681c0265 new example theory for quotient/transfer
huffman
parents:
diff changeset
   183
end