src/HOL/Quotient_Examples/Lift_RBT.thy
changeset 47963 0516a6c1ea59
parent 47962 fa3538d6004b
child 47967 987cb55cac44
     1.1 --- a/src/HOL/Quotient_Examples/Lift_RBT.thy	Fri Mar 23 14:17:29 2012 +0100
     1.2 +++ b/src/HOL/Quotient_Examples/Lift_RBT.thy	Fri Mar 23 14:18:43 2012 +0100
     1.3 @@ -6,30 +6,15 @@
     1.4  imports Main "~~/src/HOL/Library/RBT_Impl"
     1.5  begin
     1.6  
     1.7 +definition inv :: "('a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" 
     1.8 +  where [simp]: "inv R = (\<lambda>x y. R x \<and> x = y)"
     1.9 +
    1.10  subsection {* Type definition *}
    1.11  
    1.12 -typedef (open) ('a, 'b) rbt = "{t :: ('a\<Colon>linorder, 'b) RBT_Impl.rbt. is_rbt t}"
    1.13 -  morphisms impl_of RBT
    1.14 -proof -
    1.15 -  have "RBT_Impl.Empty \<in> ?rbt" by simp
    1.16 -  then show ?thesis ..
    1.17 -qed
    1.18 +quotient_type ('a, 'b) rbt = "('a\<Colon>linorder, 'b) RBT_Impl.rbt" / "inv is_rbt" morphisms impl_of RBT
    1.19 +sorry
    1.20  
    1.21 -local_setup {* fn lthy =>
    1.22 -let
    1.23 -  val quotients = {qtyp = @{typ "('a, 'b) rbt"}, rtyp = @{typ "('a, 'b) RBT_Impl.rbt"},
    1.24 -    equiv_rel = @{term "op ="}, equiv_thm = @{thm refl}}
    1.25 -  val qty_full_name = @{type_name "rbt"}
    1.26 -
    1.27 -  fun qinfo phi = Quotient_Info.transform_quotients phi quotients
    1.28 -  in lthy
    1.29 -    |> Local_Theory.declaration {syntax = false, pervasive = true}
    1.30 -        (fn phi => Quotient_Info.update_quotients qty_full_name (qinfo phi)
    1.31 -       #> Quotient_Info.update_abs_rep qty_full_name (Quotient_Info.transform_abs_rep phi
    1.32 -         {abs = @{term "RBT"}, rep = @{term "impl_of"}}))
    1.33 -  end
    1.34 -*}
    1.35 -
    1.36 +(*
    1.37  lemma rbt_eq_iff:
    1.38    "t1 = t2 \<longleftrightarrow> impl_of t1 = impl_of t2"
    1.39    by (simp add: impl_of_inject)
    1.40 @@ -45,12 +30,12 @@
    1.41  lemma RBT_impl_of [simp, code abstype]:
    1.42    "RBT (impl_of t) = t"
    1.43    by (simp add: impl_of_inverse)
    1.44 -
    1.45 +*)
    1.46  
    1.47  subsection {* Primitive operations *}
    1.48  
    1.49  quotient_definition lookup where "lookup :: ('a\<Colon>linorder, 'b) rbt \<Rightarrow> 'a \<rightharpoonup> 'b" is "RBT_Impl.lookup"
    1.50 -done
    1.51 +by simp
    1.52  
    1.53  declare lookup_def[unfolded map_fun_def comp_def id_def, code]
    1.54