Theory JMM_Type2
section ‹JMM heap implementation 2›
theory JMM_Type2
imports
"../Common/ExternalCallWF"
"../Common/ConformThreaded"
JMM_Heap
begin
subsection ‹Definitions›
datatype addr = Address htype nat
lemma rec_addr_conv_case_addr [simp]: "rec_addr = case_addr"
by(auto intro!: ext split: addr.split)
instantiation addr :: addr begin
definition "hash_addr (a :: addr) = (case a of Address ht n ⇒ int n)"
definition "monitor_finfun_to_list (ls :: addr ⇒f nat) = (SOME xs. set xs = {x. finfun_dom ls $ x })"
instance
proof
fix ls :: "addr ⇒f nat"
show "set (monitor_finfun_to_list ls) = Collect (($) (finfun_dom ls))"
unfolding monitor_finfun_to_list_addr_def
using finite_list[OF finite_finfun_dom, where ?f.1 = "ls"]
by(rule someI_ex)
qed
end
primrec the_Address :: "addr ⇒ htype × nat"
where "the_Address (Address hT n) = (hT, n)"
text ‹
The JMM heap only stores which sequence numbers of a given @{typ "htype"} have already been allocated.
›
type_synonym JMM_heap = "htype ⇒ nat set"
translations (type) "JMM_heap" <= (type) "htype ⇒ nat set"
definition jmm_allocate :: "JMM_heap ⇒ htype ⇒ (JMM_heap × addr) set"
where "jmm_allocate h hT = (let hhT = h hT in (λn. (h(hT := insert n hhT), Address hT n)) ` (- hhT))"
abbreviation jmm_empty :: "JMM_heap" where "jmm_empty == (λ_. {})"
definition jmm_typeof_addr :: "'m prog ⇒ JMM_heap ⇒ addr ⇀ htype"
where "jmm_typeof_addr P h = (λhT. if is_htype P hT then Some hT else None) ∘ fst ∘ the_Address"
definition jmm_typeof_addr' :: "'m prog ⇒ addr ⇀ htype"
where "jmm_typeof_addr' P = (λhT. if is_htype P hT then Some hT else None) ∘ fst ∘ the_Address"
lemma jmm_typeof_addr'_conv_jmm_type_addr: "jmm_typeof_addr' P = jmm_typeof_addr P h"
by(simp add: jmm_typeof_addr_def jmm_typeof_addr'_def)
lemma jmm_typeof_addr'_conv_jmm_typeof_addr: "(λ_. jmm_typeof_addr' P) = jmm_typeof_addr P"
by(simp add: jmm_typeof_addr_def jmm_typeof_addr'_def fun_eq_iff)
lemma jmm_typeof_addr_conv_jmm_typeof_addr': "jmm_typeof_addr = (λP _. jmm_typeof_addr' P)"
by(simp add: jmm_typeof_addr'_conv_jmm_typeof_addr)
definition jmm_heap_read :: "JMM_heap ⇒ addr ⇒ addr_loc ⇒ addr val ⇒ bool"
where "jmm_heap_read h a ad v = True"
context
notes [[inductive_internals]]
begin
inductive jmm_heap_write :: "JMM_heap ⇒ addr ⇒ addr_loc ⇒ addr val ⇒ JMM_heap ⇒ bool"
where "jmm_heap_write h a ad v h"
end
definition jmm_hconf :: "JMM_heap ⇒ bool"
where "jmm_hconf h ⟷ True"
definition jmm_allocated :: "JMM_heap ⇒ addr set"
where "jmm_allocated h = {Address CTn n|CTn n. n ∈ h CTn}"
definition jmm_spurious_wakeups :: "bool"
where "jmm_spurious_wakeups = True"
lemmas jmm_heap_ops_defs =
jmm_allocate_def jmm_typeof_addr_def
jmm_heap_read_def jmm_heap_write_def
jmm_allocated_def jmm_spurious_wakeups_def
type_synonym thread_id = "addr"
abbreviation (input) addr2thread_id :: "addr ⇒ thread_id"
where "addr2thread_id ≡ λx. x"
abbreviation (input) thread_id2addr :: "thread_id ⇒ addr"
where "thread_id2addr ≡ λx. x"