Theory CharacterDataClass
section‹CharacterData›
text‹In this theory, we introduce the types for the CharacterData class.›
theory CharacterDataClass
imports
ElementClass
begin
subsubsection‹CharacterData›
text‹The type @{type "DOMString"} is a type synonym for @{type "string"}, defined
\autoref{sec:Core_DOM_Basic_Datatypes}.›
record RCharacterData = RNode +
nothing :: unit
val :: DOMString
register_default_tvars "'CharacterData RCharacterData_ext"
type_synonym 'CharacterData CharacterData = "'CharacterData option RCharacterData_scheme"
register_default_tvars "'CharacterData CharacterData"
type_synonym ('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr, 'Node,
'Element, 'CharacterData) Node
= "('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr,
'CharacterData option RCharacterData_ext + 'Node, 'Element) Node"
register_default_tvars "('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr, 'Node,
'Element, 'CharacterData) Node"
type_synonym ('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr, 'Object, 'Node,
'Element, 'CharacterData) Object
= "('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr, 'Object,
'CharacterData option RCharacterData_ext + 'Node,
'Element) Object"
register_default_tvars "('node_ptr, 'element_ptr, 'character_data_ptr, 'shadow_root_ptr, 'Object,
'Node, 'Element, 'CharacterData) Object"
type_synonym ('object_ptr, 'node_ptr, 'element_ptr, 'character_data_ptr, 'document_ptr,
'shadow_root_ptr, 'Object, 'Node, 'Element, 'CharacterData) heap
= "('object_ptr, 'node_ptr, 'element_ptr, 'character_data_ptr, 'document_ptr, 'shadow_root_ptr,
'Object, 'CharacterData option RCharacterData_ext + 'Node, 'Element) heap"
register_default_tvars "('object_ptr, 'node_ptr, 'element_ptr, 'character_data_ptr, 'document_ptr,
'shadow_root_ptr, 'Object, 'Node, 'Element, 'CharacterData) heap"
type_synonym heap⇩f⇩i⇩n⇩a⇩l = "(unit, unit, unit, unit, unit, unit, unit, unit, unit, unit) heap"
definition character_data_ptr_kinds :: "(_) heap ⇒ (_) character_data_ptr fset"
where
"character_data_ptr_kinds heap = the |`| (cast |`| (ffilter is_character_data_ptr_kind
(node_ptr_kinds heap)))"
lemma character_data_ptr_kinds_simp [simp]:
"character_data_ptr_kinds (Heap (fmupd (cast character_data_ptr) character_data (the_heap h)))
= {|character_data_ptr|} |∪| character_data_ptr_kinds h"
by (auto simp add: character_data_ptr_kinds_def)
definition character_data_ptrs :: "(_) heap ⇒ _ character_data_ptr fset"
where
"character_data_ptrs heap = ffilter is_character_data_ptr (character_data_ptr_kinds heap)"
abbreviation "character_data_ptr_exts heap ≡ character_data_ptr_kinds heap - character_data_ptrs heap"
definition cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a :: "(_) Node ⇒ (_) CharacterData option"
where
"cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a node = (case RNode.more node of
Inr (Inl character_data) ⇒ Some (RNode.extend (RNode.truncate node) character_data)
| _ ⇒ None)"
adhoc_overloading cast cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
abbreviation cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a :: "(_) Object ⇒ (_) CharacterData option"
where
"cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a obj ≡ (case cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩N⇩o⇩d⇩e obj of Some node ⇒ cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a node
| None ⇒ None)"
adhoc_overloading cast cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
definition cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e :: "(_) CharacterData ⇒ (_) Node"
where
"cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e character_data = RNode.extend (RNode.truncate character_data)
(Inr (Inl (RNode.more character_data)))"
adhoc_overloading cast cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e
abbreviation cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩O⇩b⇩j⇩e⇩c⇩t :: "(_) CharacterData ⇒ (_) Object"
where
"cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩O⇩b⇩j⇩e⇩c⇩t ptr ≡ cast⇩N⇩o⇩d⇩e⇩2⇩O⇩b⇩j⇩e⇩c⇩t (cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e ptr)"
adhoc_overloading cast cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩O⇩b⇩j⇩e⇩c⇩t
consts is_character_data_kind :: 'a
definition is_character_data_kind⇩N⇩o⇩d⇩e :: "(_) Node ⇒ bool"
where
"is_character_data_kind⇩N⇩o⇩d⇩e ptr ⟷ cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a ptr ≠ None"
adhoc_overloading is_character_data_kind is_character_data_kind⇩N⇩o⇩d⇩e
lemmas is_character_data_kind_def = is_character_data_kind⇩N⇩o⇩d⇩e_def
abbreviation is_character_data_kind⇩O⇩b⇩j⇩e⇩c⇩t :: "(_) Object ⇒ bool"
where
"is_character_data_kind⇩O⇩b⇩j⇩e⇩c⇩t ptr ≡ cast⇩O⇩b⇩j⇩e⇩c⇩t⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a ptr ≠ None"
adhoc_overloading is_character_data_kind is_character_data_kind⇩O⇩b⇩j⇩e⇩c⇩t
lemma character_data_ptr_kinds_commutes [simp]:
"cast character_data_ptr |∈| node_ptr_kinds h
⟷ character_data_ptr |∈| character_data_ptr_kinds h"
proof (rule iffI)
show "cast character_data_ptr |∈| node_ptr_kinds h ⟹
character_data_ptr |∈| character_data_ptr_kinds h"
by (metis (no_types, opaque_lifting) character_data_ptr_casts_commute2
character_data_ptr_kinds_def ffmember_filter fimageI is_character_data_ptr_kind⇩_cast option.sel)
next
show "character_data_ptr |∈| character_data_ptr_kinds h ⟹
cast character_data_ptr |∈| node_ptr_kinds h"
by (auto simp add: character_data_ptr_kinds_def)
qed
definition get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a :: "(_) character_data_ptr ⇒ (_) heap ⇒ (_) CharacterData option"
where
"get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr h = Option.bind (get⇩N⇩o⇩d⇩e (cast character_data_ptr) h) cast"
adhoc_overloading get get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
locale l_type_wf_def⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
begin
definition a_type_wf :: "(_) heap ⇒ bool"
where
"a_type_wf h = (ElementClass.type_wf h
∧ (∀character_data_ptr ∈ fset (character_data_ptr_kinds h).
get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr h ≠ None))"
end
global_interpretation l_type_wf_def⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a defines type_wf = a_type_wf .
lemmas type_wf_defs = a_type_wf_def
locale l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a = l_type_wf type_wf for type_wf :: "((_) heap ⇒ bool)" +
assumes type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a: "type_wf h ⟹ CharacterDataClass.type_wf h"
sublocale l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a ⊆ l_type_wf⇩E⇩l⇩e⇩m⇩e⇩n⇩t
apply(unfold_locales)
using ElementClass.a_type_wf_def
by (meson CharacterDataClass.a_type_wf_def l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_axioms l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def)
locale l_get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_lemmas = l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
begin
sublocale l_get⇩E⇩l⇩e⇩m⇩e⇩n⇩t_lemmas by unfold_locales
lemma get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_type_wf:
assumes "type_wf h"
shows "character_data_ptr |∈| character_data_ptr_kinds h
⟷ get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr h ≠ None"
using l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_axioms assms
apply(simp add: type_wf_defs get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def l_type_wf⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def)
by (metis assms bind.bind_lzero character_data_ptr_kinds_commutes
local.get⇩N⇩o⇩d⇩e_type_wf option.exhaust option.simps(3))
end
global_interpretation l_get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_lemmas type_wf
by unfold_locales
definition put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a :: "(_) character_data_ptr ⇒ (_) CharacterData ⇒ (_) heap ⇒ (_) heap"
where
"put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr character_data = put⇩N⇩o⇩d⇩e (cast character_data_ptr)
(cast character_data)"
adhoc_overloading put put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
lemma put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_ptr_in_heap:
assumes "put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr character_data h = h'"
shows "character_data_ptr |∈| character_data_ptr_kinds h'"
using assms put⇩N⇩o⇩d⇩e_ptr_in_heap
unfolding put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def character_data_ptr_kinds_def
by (metis character_data_ptr_kinds_commutes character_data_ptr_kinds_def put⇩N⇩o⇩d⇩e_ptr_in_heap)
lemma put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_put_ptrs:
assumes "put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr character_data h = h'"
shows "object_ptr_kinds h' = object_ptr_kinds h |∪| {|cast character_data_ptr|}"
using assms
by (simp add: put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def put⇩N⇩o⇩d⇩e_put_ptrs)
lemma cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e_inject [simp]: "cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e x = cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e y ⟷ x = y"
apply(simp add: cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e_def RObject.extend_def RNode.extend_def)
by (metis (full_types) RNode.surjective old.unit.exhaust)
lemma cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_none [simp]:
"cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a node = None ⟷ ¬ (∃character_data. cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e character_data = node)"
apply(auto simp add: cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e_def RObject.extend_def RNode.extend_def
split: sum.splits)[1]
by (metis (full_types) RNode.select_convs(2) RNode.surjective old.unit.exhaust)
lemma cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_some [simp]:
"cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a node = Some character_data ⟷ cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e character_data = node"
by(auto simp add: cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e_def RObject.extend_def RNode.extend_def
split: sum.splits)
lemma cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_inv [simp]:
"cast⇩N⇩o⇩d⇩e⇩2⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a (cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e character_data) = Some character_data"
by simp
lemma cast_element_not_character_data [simp]:
"(cast⇩E⇩l⇩e⇩m⇩e⇩n⇩t⇩2⇩N⇩o⇩d⇩e element ≠ cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e character_data)"
"(cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e character_data ≠ cast⇩E⇩l⇩e⇩m⇩e⇩n⇩t⇩2⇩N⇩o⇩d⇩e element)"
by(auto simp add: cast⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a⇩2⇩N⇩o⇩d⇩e_def cast⇩E⇩l⇩e⇩m⇩e⇩n⇩t⇩2⇩N⇩o⇩d⇩e_def RNode.extend_def)
lemma get_CharacterData_simp1 [simp]:
"get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr (put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr character_data h)
= Some character_data"
by(auto simp add: get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def)
lemma get_CharacterData_simp2 [simp]:
"character_data_ptr ≠ character_data_ptr' ⟹ get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr
(put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_ptr' character_data 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 put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def)
lemma get_CharacterData_simp3 [simp]:
"get⇩E⇩l⇩e⇩m⇩e⇩n⇩t element_ptr (put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a character_data_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 put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def)
lemma get_CharacterData_simp4 [simp]:
"get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a element_ptr (put⇩E⇩l⇩e⇩m⇩e⇩n⇩t character_data_ptr f h) = get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a element_ptr h"
by(auto simp add: get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def put⇩E⇩l⇩e⇩m⇩e⇩n⇩t_def)
lemma new⇩E⇩l⇩e⇩m⇩e⇩n⇩t_get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a [simp]:
assumes "new⇩E⇩l⇩e⇩m⇩e⇩n⇩t h = (new_element_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⇩E⇩l⇩e⇩m⇩e⇩n⇩t_def Let_def)
abbreviation "create_character_data_obj val_arg
≡ ⦇ RObject.nothing = (), RNode.nothing = (), RCharacterData.nothing = (), val = val_arg, … = None ⦈"
definition new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a :: "(_) heap ⇒ ((_) character_data_ptr × (_) heap)"
where
"new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h =
(let new_character_data_ptr = character_data_ptr.Ref (Suc (fMax (character_data_ptr.the_ref
|`| (character_data_ptrs h)))) in
(new_character_data_ptr, put new_character_data_ptr (create_character_data_obj '''') h))"
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_ptr_in_heap:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
shows "new_character_data_ptr |∈| character_data_ptr_kinds h'"
using assms
unfolding new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def Let_def
using put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_ptr_in_heap by blast
lemma new_character_data_ptr_new:
"character_data_ptr.Ref (Suc (fMax (finsert 0 (character_data_ptr.the_ref |`| character_data_ptrs h))))
|∉| character_data_ptrs h"
by (metis Suc_n_not_le_n character_data_ptr.sel(1) fMax_ge fimage_finsert finsertI1
finsertI2 set_finsert)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_ptr_not_in_heap:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
shows "new_character_data_ptr |∉| character_data_ptr_kinds h"
using assms
unfolding new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def
by (metis Pair_inject character_data_ptrs_def fMax_finsert fempty_iff ffmember_filter
fimage_is_fempty is_character_data_ptr_ref max_0L new_character_data_ptr_new)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_new_ptr:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
shows "object_ptr_kinds h' = object_ptr_kinds h |∪| {|cast new_character_data_ptr|}"
using assms
by (metis Pair_inject new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_put_ptrs)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_is_character_data_ptr:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
shows "is_character_data_ptr new_character_data_ptr"
using assms
by(auto simp add: new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def Let_def)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_get⇩O⇩b⇩j⇩e⇩c⇩t [simp]:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
assumes "ptr ≠ cast new_character_data_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⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def Let_def put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def put⇩N⇩o⇩d⇩e_def)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_get⇩N⇩o⇩d⇩e [simp]:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
assumes "ptr ≠ cast new_character_data_ptr"
shows "get⇩N⇩o⇩d⇩e ptr h = get⇩N⇩o⇩d⇩e 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 put⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_get⇩E⇩l⇩e⇩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⇩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⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def Let_def)
lemma new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_get⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a [simp]:
assumes "new⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a h = (new_character_data_ptr, h')"
assumes "ptr ≠ new_character_data_ptr"
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⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a_def Let_def)
locale l_known_ptr⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a
begin
definition a_known_ptr :: "(_) object_ptr ⇒ bool"
where
"a_known_ptr ptr = (known_ptr ptr ∨ is_character_data_ptr ptr)"
lemma known_ptr_not_character_data_ptr:
"¬is_character_data_ptr ptr ⟹ a_known_ptr ptr ⟹ known_ptr ptr"
by(simp add: a_known_ptr_def)
end
global_interpretation l_known_ptr⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a defines known_ptr = a_known_ptr .
lemmas known_ptr_defs = a_known_ptr_def
locale l_known_ptrs⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a = 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⇩C⇩h⇩a⇩r⇩a⇩c⇩t⇩e⇩r⇩D⇩a⇩t⇩a known_ptr defines known_ptrs = a_known_ptrs .
lemmas known_ptrs_defs = a_known_ptrs_def
lemma known_ptrs_is_l_known_ptrs: "l_known_ptrs known_ptr known_ptrs"
using known_ptrs_known_ptr known_ptrs_preserved known_ptrs_subset known_ptrs_new_ptr l_known_ptrs_def
by blast
end