Theory Monitor_Impl
theory Monitor_Impl
imports Monitor
Optimized_MTL
"HOL-Library.Code_Target_Nat"
Containers.Containers
begin
section ‹Instantiation of the generic algorithm and code setup›
declare [[code drop: card]] Set_Impl.card_code[code]
instantiation enat :: set_impl begin
definition set_impl_enat :: "(enat, set_impl) phantom" where
"set_impl_enat = phantom set_RBT"
instance ..
end
derive ccompare Formula.trm
derive (eq) ceq Formula.trm
derive (rbt) set_impl Formula.trm
derive (eq) ceq Monitor.mregex
derive ccompare Monitor.mregex
derive (rbt) set_impl Monitor.mregex
derive (rbt) mapping_impl Monitor.mregex
derive (no) cenum Monitor.mregex
derive (rbt) set_impl event_data
derive (rbt) mapping_impl event_data
definition add_new_mmuaux' :: "args ⇒ event_data table ⇒ event_data table ⇒ ts ⇒ event_data mmuaux ⇒
event_data mmuaux" where
"add_new_mmuaux' = add_new_mmuaux"
interpretation muaux valid_mmuaux init_mmuaux add_new_mmuaux' length_mmuaux eval_mmuaux
using valid_init_mmuaux valid_add_new_mmuaux valid_length_mmuaux valid_eval_mmuaux
unfolding add_new_mmuaux'_def
by unfold_locales assumption+
type_synonym 'a vmsaux = "nat × (nat × 'a table) list"
definition valid_vmsaux :: "args ⇒ nat ⇒ event_data vmsaux ⇒
(nat × event_data table) list ⇒ bool" where
"valid_vmsaux = (λ_ cur (t, aux) auxlist. t = cur ∧ aux = auxlist)"
definition init_vmsaux :: "args ⇒ event_data vmsaux" where
"init_vmsaux = (λ_. (0, []))"
definition add_new_ts_vmsaux :: "args ⇒ nat ⇒ event_data vmsaux ⇒ event_data vmsaux" where
"add_new_ts_vmsaux = (λargs nt (t, auxlist). (nt, filter (λ(t, rel).
enat (nt - t) ≤ right (args_ivl args)) auxlist))"
definition join_vmsaux :: "args ⇒ event_data table ⇒ event_data vmsaux ⇒ event_data vmsaux" where
"join_vmsaux = (λargs rel1 (t, auxlist). (t, map (λ(t, rel).
(t, join rel (args_pos args) rel1)) auxlist))"
definition add_new_table_vmsaux :: "args ⇒ event_data table ⇒ event_data vmsaux ⇒
event_data vmsaux" where
"add_new_table_vmsaux = (λargs rel2 (cur, auxlist). (cur, (case auxlist of
[] => [(cur, rel2)]
| ((t, y) # ts) ⇒ if t = cur then (t, y ∪ rel2) # ts else (cur, rel2) # auxlist)))"
definition result_vmsaux :: "args ⇒ event_data vmsaux ⇒ event_data table" where
"result_vmsaux = (λargs (cur, auxlist).
foldr (∪) [rel. (t, rel) ← auxlist, left (args_ivl args) ≤ cur - t] {})"
type_synonym 'a vmuaux = "nat × (nat × 'a table × 'a table) list"
definition valid_vmuaux :: "args ⇒ nat ⇒ event_data vmuaux ⇒
(nat × event_data table × event_data table) list ⇒ bool" where
"valid_vmuaux = (λ_ cur (t, aux) auxlist. t = cur ∧ aux = auxlist)"
definition init_vmuaux :: "args ⇒ event_data vmuaux" where
"init_vmuaux = (λ_. (0, []))"
definition add_new_vmuaux :: "args ⇒ event_data table ⇒ event_data table ⇒ nat ⇒
event_data vmuaux ⇒ event_data vmuaux" where
"add_new_vmuaux = (λargs rel1 rel2 nt (t, auxlist). (nt, update_until args rel1 rel2 nt auxlist))"
definition length_vmuaux :: "args ⇒ event_data vmuaux ⇒ nat" where
"length_vmuaux = (λ_ (_, auxlist). length auxlist)"
definition eval_vmuaux :: "args ⇒ nat ⇒ event_data vmuaux ⇒
event_data table list × event_data vmuaux" where
"eval_vmuaux = (λargs nt (t, auxlist).
(let (res, auxlist') = eval_until (args_ivl args) nt auxlist in (res, (t, auxlist'))))"