--- a/src/HOL/Quotient_Examples/Lift_RBT.thy Wed May 02 22:05:59 2012 +0200
+++ b/src/HOL/Quotient_Examples/Lift_RBT.thy Fri May 04 11:08:31 2012 +0200
@@ -8,6 +8,8 @@
imports Main "~~/src/HOL/Library/RBT_Impl"
begin
+(* TODO: Replace the ancient Library/RBT theory by this example of the lifting and transfer mechanism. *)
+
subsection {* Type definition *}
typedef (open) ('a, 'b) rbt = "{t :: ('a\<Colon>linorder, 'b) RBT_Impl.rbt. is_rbt t}"
@@ -77,23 +79,21 @@
subsection {* Abstract lookup properties *}
-(* TODO: obtain the following lemmas by lifting existing theorems. *)
-
lemma lookup_RBT:
"is_rbt t \<Longrightarrow> lookup (RBT t) = rbt_lookup t"
by (simp add: lookup_def RBT_inverse)
lemma lookup_impl_of:
"rbt_lookup (impl_of t) = lookup t"
- by (simp add: lookup_def)
+ by transfer (rule refl)
lemma entries_impl_of:
"RBT_Impl.entries (impl_of t) = entries t"
- by (simp add: entries_def)
+ by transfer (rule refl)
lemma keys_impl_of:
"RBT_Impl.keys (impl_of t) = keys t"
- by (simp add: keys_def)
+ by transfer (rule refl)
lemma lookup_empty [simp]:
"lookup empty = Map.empty"
@@ -101,43 +101,43 @@
lemma lookup_insert [simp]:
"lookup (insert k v t) = (lookup t)(k \<mapsto> v)"
- by (simp add: insert_def lookup_RBT rbt_lookup_rbt_insert lookup_impl_of)
+ by transfer (rule rbt_lookup_rbt_insert)
lemma lookup_delete [simp]:
"lookup (delete k t) = (lookup t)(k := None)"
- by (simp add: delete_def lookup_RBT rbt_lookup_rbt_delete lookup_impl_of restrict_complement_singleton_eq)
+ by transfer (simp add: rbt_lookup_rbt_delete restrict_complement_singleton_eq)
lemma map_of_entries [simp]:
"map_of (entries t) = lookup t"
- by (simp add: entries_def map_of_entries lookup_impl_of)
+ by transfer (simp add: map_of_entries)
lemma entries_lookup:
"entries t1 = entries t2 \<longleftrightarrow> lookup t1 = lookup t2"
- by (simp add: entries_def lookup_def entries_rbt_lookup)
+ by transfer (simp add: entries_rbt_lookup)
lemma lookup_bulkload [simp]:
"lookup (bulkload xs) = map_of xs"
- by (simp add: bulkload_def lookup_RBT rbt_lookup_rbt_bulkload)
+ by transfer (rule rbt_lookup_rbt_bulkload)
lemma lookup_map_entry [simp]:
"lookup (map_entry k f t) = (lookup t)(k := Option.map f (lookup t k))"
- by (simp add: map_entry_def lookup_RBT rbt_lookup_rbt_map_entry lookup_impl_of)
+ by transfer (rule rbt_lookup_rbt_map_entry)
lemma lookup_map [simp]:
"lookup (map f t) k = Option.map (f k) (lookup t k)"
- by (simp add: map_def lookup_RBT rbt_lookup_map lookup_impl_of)
+ by transfer (rule rbt_lookup_map)
lemma fold_fold:
"fold f t = List.fold (prod_case f) (entries t)"
- by (simp add: fold_def fun_eq_iff RBT_Impl.fold_def entries_impl_of)
+ by transfer (rule RBT_Impl.fold_def)
lemma impl_of_empty:
"impl_of empty = RBT_Impl.Empty"
- by (simp add: empty_def RBT_inverse)
+ by transfer (rule refl)
lemma is_empty_empty [simp]:
"is_empty t \<longleftrightarrow> t = empty"
- by (simp add: rbt_eq_iff is_empty_def impl_of_empty split: rbt.split)
+ unfolding is_empty_def by transfer (simp split: rbt.split)
lemma RBT_lookup_empty [simp]: (*FIXME*)
"rbt_lookup t = Map.empty \<longleftrightarrow> t = RBT_Impl.Empty"
@@ -145,15 +145,15 @@
lemma lookup_empty_empty [simp]:
"lookup t = Map.empty \<longleftrightarrow> t = empty"
- by (cases t) (simp add: empty_def lookup_def RBT_inject RBT_inverse)
+ by transfer (rule RBT_lookup_empty)
lemma sorted_keys [iff]:
"sorted (keys t)"
- by (simp add: keys_def RBT_Impl.keys_def rbt_sorted_entries)
+ by transfer (simp add: RBT_Impl.keys_def rbt_sorted_entries)
lemma distinct_keys [iff]:
"distinct (keys t)"
- by (simp add: keys_def RBT_Impl.keys_def distinct_entries)
+ by transfer (simp add: RBT_Impl.keys_def distinct_entries)
end
\ No newline at end of file