# HG changeset patch # User traytel # Date 1439405193 -7200 # Node ID b0ba7799d05a9ad541ef803ad05bdad749602f8c # Parent 4ceef1592e8c3645baaf719291ab075548eba30a use lift_bnf in an example diff -r 4ceef1592e8c -r b0ba7799d05a src/HOL/Library/DAList.thy --- a/src/HOL/Library/DAList.thy Wed Aug 12 20:46:33 2015 +0200 +++ b/src/HOL/Library/DAList.thy Wed Aug 12 20:46:33 2015 +0200 @@ -198,54 +198,8 @@ section \alist is a BNF\ -lift_definition map :: "('a \ 'b) \ ('k, 'a) alist \ ('k, 'b) alist" - is "\f xs. List.map (map_prod id f) xs" by simp - -lift_definition set :: "('k, 'v) alist => 'v set" - is "\xs. snd ` List.set xs" . - -lift_definition rel :: "('a \ 'b \ bool) \ ('k, 'a) alist \ ('k, 'b) alist \ bool" - is "\R xs ys. list_all2 (rel_prod op = R) xs ys" . - -bnf "('k, 'v) alist" - map: map - sets: set - bd: natLeq - wits: empty - rel: rel -proof (unfold OO_Grp_alt) - show "map id = id" by (rule ext, transfer) (simp add: prod.map_id0) -next - fix f g - show "map (g \ f) = map g \ map f" - by (rule ext, transfer) (simp add: prod.map_comp) -next - fix x f g - assume "(\z. z \ set x \ f z = g z)" - then show "map f x = map g x" by transfer force -next - fix f - show "set \ map f = op ` f \ set" - by (rule ext, transfer) (simp add: image_image) -next - fix x - show "ordLeq3 (card_of (set x)) natLeq" - by transfer (auto simp: finite_iff_ordLess_natLeq[symmetric] intro: ordLess_imp_ordLeq) -next - fix R S - show "rel R OO rel S \ rel (R OO S)" - by (rule predicate2I, transfer) - (auto simp: list.rel_compp prod.rel_compp[of "op =", unfolded eq_OO]) -next - fix R - show "rel R = (\x y. \z. z \ {x. set x \ {(x, y). R x y}} \ map fst z = x \ map snd z = y)" - unfolding fun_eq_iff by transfer (fastforce simp: list.in_rel o_def intro: - exI[of _ "List.map (\p. ((fst p, fst (snd p)), (fst p, snd (snd p)))) z" for z] - exI[of _ "List.map (\p. (fst (fst p), snd (fst p), snd (snd p))) z" for z]) -next - fix z assume "z \ set empty" - then show False by transfer simp -qed (simp_all add: natLeq_cinfinite natLeq_card_order) +lift_bnf (dead 'k, set: 'v) alist [wits: "[] :: ('k \ 'v) list"] for map: map rel: rel + by auto hide_const valterm_empty valterm_update random_aux_alist