Theory DocumentClass
section‹Document›
text‹In this theory, we introduce the types for the Document class.›
theory DocumentClass
imports
CharacterDataClass
begin
text‹The type @{type "doctype"} is a type synonym for @{type "string"}, defined
in \autoref{sec:Core_DOM_Basic_Datatypes}.›
record ('node_ptr, 'element_ptr, 'character_data_ptr) RDocument = RObject +
nothing :: unit
doctype :: doctype
document_element :: "(_) element_ptr option"
disconnected_nodes :: "('node_ptr, 'element_ptr, 'character_data_ptr) node_ptr list"
type_synonym
('node_ptr, 'element_ptr, 'character_data_ptr, 'Document) Document
= "('node_ptr, 'element_ptr, 'character_data_ptr, 'Document option) RDocument_scheme"
register_default_tvars
"('node_ptr, 'element_ptr, 'character_data_ptr, 'Document) Document"
type_synonym
('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr, 'Object, 'Node,
'Element, 'CharacterData, 'Document) Object
= "('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr,
('node_ptr, 'element_ptr, 'character_data_ptr, 'Document option)
RDocument_ext + 'Object, 'Node, 'Element, 'CharacterData) Object"
register_default_tvars "('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr,
'Object, 'Node, 'Element, 'CharacterData, 'Document) Object"
type_synonym ('object_ptr, 'node_ptr, 'element_ptr, 'character_data_ptr, 'document_ptr,
'shadow_root_ptr, 'Object, 'Node, 'Element, 'CharacterData, 'Document) heap
= "('object_ptr, 'node_ptr, 'element_ptr, 'character_data_ptr, 'document_ptr,
'shadow_root_ptr,
('node_ptr, 'element_ptr, 'character_data_ptr, 'Document option) RDocument_ext + 'Object, 'Node,
'Element, 'CharacterData) heap"
register_default_tvars
"('object_ptr, 'node_ptr, 'element_ptr, 'character_data_ptr, 'document_ptr,
'shadow_root_ptr, 'Object, 'Node, 'Element, 'CharacterData, 'Document) heap"
type_synonym heap⇩f⇩i⇩n⇩a⇩l = "(unit, unit, unit, unit, unit, unit, unit, unit, unit, unit, unit) heap"
definition document_ptr_kinds :: "(_) heap ⇒ (_) document_ptr fset"
where
"document_ptr_kinds heap = the |`| (cast⇩o⇩b⇩j⇩e⇩c⇩t⇩_⇩p⇩t⇩r⇩2⇩d⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩_⇩p⇩t⇩r |`|
(ffilter is_document_ptr_kind (object_ptr_kinds heap)))"
definition document_ptrs :: "(_) heap ⇒ (_) document_ptr fset"
where
"document_ptrs heap = ffilter is_document_ptr (document_ptr_kinds heap)"
definition cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t :: "(_) Object ⇒ (_) Document option"
where
"cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t obj = (case RObject.more obj of
Inr (Inl document) ⇒ Some (RObject.extend (RObject.truncate obj) document)
| _ ⇒ None)"
adhoc_overloading cast cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t
definition cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t:: "(_) Document ⇒ (_) Object"
where
"cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t document = (RObject.extend (RObject.truncate document)
(Inr (Inl (RObject.more document))))"
adhoc_overloading cast cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t
definition is_document_kind :: "(_) Object ⇒ bool"
where
"is_document_kind ptr ⟷ cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ptr ≠ None"
lemma document_ptr_kinds_simp [simp]:
"document_ptr_kinds (Heap (fmupd (cast document_ptr) document (the_heap h)))
= {|document_ptr|} |∪| document_ptr_kinds h"
by (auto simp add: document_ptr_kinds_def)
lemma document_ptr_kinds_commutes [simp]:
"cast document_ptr |∈| object_ptr_kinds h ⟷ document_ptr |∈| document_ptr_kinds h"
proof (rule iffI)
show "cast document_ptr |∈| object_ptr_kinds h ⟹ document_ptr |∈| document_ptr_kinds h"
by (metis (no_types, opaque_lifting) document_ptr_casts_commute2 document_ptr_document_ptr_cast
document_ptr_kinds_def ffmember_filter fimage_eqI option.sel)
next
show "document_ptr |∈| document_ptr_kinds h ⟹ cast document_ptr |∈| object_ptr_kinds h"
by (auto simp: document_ptr_kinds_def)
qed
definition get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t :: "(_) document_ptr ⇒ (_) heap ⇒ (_) Document option"
where
"get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr h = Option.bind (get (cast document_ptr) h) cast"
adhoc_overloading get get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t
locale l_type_wf_def⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t
begin
definition a_type_wf :: "(_) heap ⇒ bool"
where
"a_type_wf h = (CharacterDataClass.type_wf h ∧
(∀document_ptr ∈ fset (document_ptr_kinds h). get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr h ≠ None))"
end
global_interpretation l_type_wf_def⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t defines type_wf = a_type_wf .
lemmas type_wf_defs = a_type_wf_def
locale l_type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t = l_type_wf type_wf for type_wf :: "((_) heap ⇒ bool)" +
assumes type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t: "type_wf h ⟹ DocumentClass.type_wf h"
sublocale l_type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ⊆ l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
apply(unfold_locales)
by (metis (full_types) type_wf_defs l_type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_axioms l_type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
locale l_get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_lemmas = l_type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t
begin
sublocale l_get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_lemmas by unfold_locales
lemma get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_type_wf:
assumes "type_wf h"
shows "document_ptr |∈| document_ptr_kinds h ⟷ get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr h ≠ None"
using l_type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_axioms assms
apply(simp add: type_wf_defs get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def l_type_wf⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
by (metis document_ptr_kinds_commutes is_none_bind is_none_simps(1)
is_none_simps(2) local.get⇩O⇩b⇩j⇩e⇩c⇩t_type_wf)
end
global_interpretation l_get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_lemmas type_wf by unfold_locales
definition put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t :: "(_) document_ptr ⇒ (_) Document ⇒ (_) heap ⇒ (_) heap"
where
"put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr document = put (cast document_ptr) (cast document)"
adhoc_overloading put put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t
lemma put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_ptr_in_heap:
assumes "put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr document h = h'"
shows "document_ptr |∈| document_ptr_kinds h'"
using assms
unfolding put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def
by (metis document_ptr_kinds_commutes put⇩O⇩b⇩j⇩e⇩c⇩t_ptr_in_heap)
lemma put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_put_ptrs:
assumes "put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr document h = h'"
shows "object_ptr_kinds h' = object_ptr_kinds h |∪| {|cast document_ptr|}"
using assms
by (simp add: put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def put⇩O⇩b⇩j⇩e⇩c⇩t_put_ptrs)
lemma cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t_inject [simp]: "cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t x = cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t y ⟷ x = y"
apply(simp add: cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t_def RObject.extend_def)
by (metis (full_types) RObject.surjective old.unit.exhaust)
lemma cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_none [simp]:
"cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t obj = None ⟷ ¬ (∃document. cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t document = obj)"
apply(auto simp add: cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t_def RObject.extend_def
split: sum.splits)[1]
by (metis (full_types) RObject.select_convs(2) RObject.surjective old.unit.exhaust)
lemma cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_some [simp]:
"cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t obj = Some document ⟷ cast document = obj"
by(auto simp add: cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t_def RObject.extend_def
split: sum.splits)
lemma cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_inv [simp]: "cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t (cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t document) = Some document"
by simp
lemma cast_document_not_node [simp]:
"cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t document ≠ cast⇩N⇩o⇩d⇩e⇩2⇩O⇩b⇩j⇩e⇩c⇩t node"
"cast⇩N⇩o⇩d⇩e⇩2⇩O⇩b⇩j⇩e⇩c⇩t node ≠ cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t document"
by(auto simp add: cast⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t⇩2⇩O⇩b⇩j⇩e⇩c⇩t_def cast⇩N⇩o⇩d⇩e⇩2⇩O⇩b⇩j⇩e⇩c⇩t_def RObject.extend_def)
lemma get_document_ptr_simp1 [simp]:
"get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr (put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr document h) = Some document"
by(auto simp add: get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
lemma get_document_ptr_simp2 [simp]:
"document_ptr ≠ document_ptr'
⟹ get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr (put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr' document h) = get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr h"
by(auto simp add: get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
lemma get_document_ptr_simp3 [simp]:
"get⇩E⇩l⇩e⇩m⇩e⇩n⇩t element_ptr (put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr f h) = get⇩E⇩l⇩e⇩m⇩e⇩n⇩t element_ptr h"
by(auto simp add: get⇩E⇩l⇩e⇩m⇩e⇩n⇩t_def get⇩N⇩o⇩d⇩e_def put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
lemma get_document_ptr_simp4 [simp]:
"get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr (put⇩E⇩l⇩e⇩m⇩e⇩n⇩t element_ptr f h) = get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr h"
by(auto simp add: get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def put⇩E⇩l⇩e⇩m⇩e⇩n⇩t_def put⇩N⇩o⇩d⇩e_def)
lemma get_document_ptr_simp5 [simp]:
"get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr (put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr f h) = get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr h"
by(auto simp add: get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def get⇩N⇩o⇩d⇩e_def put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
lemma get_document_ptr_simp6 [simp]:
"get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr (put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr f h) = get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t document_ptr h"
by(auto simp add: get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def put⇩N⇩o⇩d⇩e_def)
lemma new⇩E⇩l⇩e⇩m⇩e⇩n⇩t_get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t [simp]:
assumes "new⇩E⇩l⇩e⇩m⇩e⇩n⇩t h = (new_element_ptr, h')"
shows "get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ptr h = get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ptr h'"
using assms
by(auto simp add: new⇩E⇩l⇩e⇩m⇩e⇩n⇩t_def Let_def)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t [simp]:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
shows "get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ptr h = get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ptr h'"
using assms
by(auto simp add: new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def Let_def)
abbreviation
create_document_obj :: "char list ⇒ (_) element_ptr option ⇒ (_) node_ptr list ⇒ (_) Document"
where
"create_document_obj doctype_arg document_element_arg disconnected_nodes_arg
≡ ⦇ RObject.nothing = (), RDocument.nothing = (), doctype = doctype_arg,
document_element = document_element_arg,
disconnected_nodes = disconnected_nodes_arg, … = None ⦈"
definition new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t :: "(_)heap ⇒ ((_) document_ptr × (_) heap)"
where
"new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h =
(let new_document_ptr = document_ptr.Ref (Suc (fMax (finsert 0 (document_ptr.the_ref |`| (document_ptrs h)))))
in
(new_document_ptr, put new_document_ptr (create_document_obj '''' None []) h))"
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_ptr_in_heap:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
shows "new_document_ptr |∈| document_ptr_kinds h'"
using assms
unfolding new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def Let_def
using put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_ptr_in_heap by blast
lemma new_document_ptr_new:
"document_ptr.Ref (Suc (fMax (finsert 0 (document_ptr.the_ref |`| document_ptrs h))))
|∉| document_ptrs h"
by (metis Suc_n_not_le_n document_ptr.sel(1) fMax_ge fimage_finsert finsertI1 finsertI2 set_finsert)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_ptr_not_in_heap:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
shows "new_document_ptr |∉| document_ptr_kinds h"
using assms
unfolding new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def
by (metis Pair_inject document_ptrs_def fMax_finsert fempty_iff ffmember_filter
fimage_is_fempty is_document_ptr_ref max_0L new_document_ptr_new)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_new_ptr:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
shows "object_ptr_kinds h' = object_ptr_kinds h |∪| {|cast new_document_ptr|}"
using assms
by (metis Pair_inject new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_put_ptrs)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_is_document_ptr:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
shows "is_document_ptr new_document_ptr"
using assms
by(auto simp add: new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def Let_def)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_get⇩O⇩b⇩j⇩e⇩c⇩t [simp]:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
assumes "ptr ≠ cast new_document_ptr"
shows "get⇩O⇩b⇩j⇩e⇩c⇩t ptr h = get⇩O⇩b⇩j⇩e⇩c⇩t ptr h'"
using assms
by(auto simp add: new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def Let_def put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_get⇩N⇩o⇩d⇩e [simp]:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
shows "get⇩N⇩o⇩d⇩e ptr h = get⇩N⇩o⇩d⇩e ptr h'"
using assms
apply(simp add: new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def Let_def put⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def)
by(auto simp add: get⇩N⇩o⇩d⇩e_def)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_get⇩E⇩l⇩e⇩m⇩e⇩n⇩t [simp]:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
shows "get⇩E⇩l⇩e⇩m⇩e⇩n⇩t ptr h = get⇩E⇩l⇩e⇩m⇩e⇩n⇩t ptr h'"
using assms
by(auto simp add: new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def Let_def)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a [simp]:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
shows "get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a ptr h = get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a ptr h'"
using assms
by(auto simp add: new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def Let_def)
lemma new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t [simp]:
assumes "new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t h = (new_document_ptr, h')"
assumes "ptr ≠ new_document_ptr"
shows "get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ptr h = get⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t ptr h'"
using assms
by(auto simp add: new⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t_def Let_def)
locale l_known_ptr⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t
begin
definition a_known_ptr :: "(_) object_ptr ⇒ bool"
where
"a_known_ptr ptr = (known_ptr ptr ∨ is_document_ptr ptr)"
lemma known_ptr_not_document_ptr: "¬is_document_ptr ptr ⟹ a_known_ptr ptr ⟹ known_ptr ptr"
by(simp add: a_known_ptr_def)
end
global_interpretation l_known_ptr⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t defines known_ptr = a_known_ptr .
lemmas known_ptr_defs = a_known_ptr_def
locale l_known_ptrs⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t = l_known_ptr known_ptr for known_ptr :: "(_) object_ptr ⇒ bool"
begin
definition a_known_ptrs :: "(_) heap ⇒ bool"
where
"a_known_ptrs h = (∀ptr ∈ fset (object_ptr_kinds h). known_ptr ptr)"
lemma known_ptrs_known_ptr: "a_known_ptrs h ⟹ ptr |∈| object_ptr_kinds h ⟹ known_ptr ptr"
by (simp add: a_known_ptrs_def)
lemma known_ptrs_preserved:
"object_ptr_kinds h = object_ptr_kinds h' ⟹ a_known_ptrs h = a_known_ptrs h'"
by(auto simp add: a_known_ptrs_def)
lemma known_ptrs_subset:
"object_ptr_kinds h' |⊆| object_ptr_kinds h ⟹ a_known_ptrs h ⟹ a_known_ptrs h'"
by(simp add: a_known_ptrs_def less_eq_fset.rep_eq subsetD)
lemma known_ptrs_new_ptr:
"object_ptr_kinds h' = object_ptr_kinds h |∪| {|new_ptr|} ⟹ known_ptr new_ptr ⟹
a_known_ptrs h ⟹ a_known_ptrs h'"
by(simp add: a_known_ptrs_def)
end
global_interpretation l_known_ptrs⇩D⇩o⇩c⇩u⇩m⇩e⇩n⇩t known_ptr defines known_ptrs = a_known_ptrs .
lemmas known_ptrs_defs = a_known_ptrs_def
lemma known_ptrs_is_l_known_ptrs [instances]: "l_known_ptrs known_ptr known_ptrs"
using known_ptrs_known_ptr known_ptrs_preserved l_known_ptrs_def known_ptrs_subset known_ptrs_new_ptr
by blast
end