Theory Examples
theory Examples
imports Monitor Checker_Code
begin
section ‹Examples›
definition monitor :: "(('n :: linorder × 'd :: {default, linorder} list) set × nat) list ⇒ ('n, 'd) formula ⇒ ('n, 'd) expl list" where
"monitor π φ = map (λi. eval (trace_of_list π) (λp q. size p ≤ size q) (sorted_list_of_set (fv φ)) i φ) [0 ..< length π]"
definition check :: "(('n :: linorder × 'd :: {default, linorder} list) set × nat) list ⇒ ('n, 'd) formula ⇒ bool" where
"check π φ = list_all (check_all (trace_of_list π) φ) (monitor π φ)"
subsection ‹Infinite Domain›
definition prefix :: "((string × string list) set × nat) list" where
"prefix =
[({(''mgr_S'', [''Mallory'', ''Alice'']),
(''mgr_S'', [''Merlin'', ''Bob'']),
(''mgr_S'', [''Merlin'', ''Charlie''])}, 1307532861::nat),
({(''approve'', [''Mallory'', ''152''])}, 1307532861),
({(''approve'', [''Merlin'', ''163'']),
(''publish'', [''Alice'', ''160'']),
(''mgr_F'', [''Merlin'', ''Charlie''])}, 1307955600),
({(''approve'', [''Merlin'', ''187'']),
(''publish'', [''Bob'', ''163'']),
(''publish'', [''Alice'', ''163'']),
(''publish'', [''Charlie'', ''163'']),
(''publish'', [''Charlie'', ''152''])}, 1308477599)]"
definition phi :: "(string, string) Formula.formula" where
"phi = Formula.Imp (Formula.Pred ''publish'' [Formula.Var ''a'', Formula.Var ''f''])
(Formula.Once (init 604800) (Formula.Exists ''m'' (Formula.Since
(Formula.Neg (Formula.Pred ''mgr_F'' [Formula.Var ''m'', Formula.Var ''a''])) all
(Formula.And (Formula.Pred ''mgr_S'' [Formula.Var ''m'', Formula.Var ''a''])
(Formula.Pred ''approve'' [Formula.Var ''m'', Formula.Var ''f''])))))"
value "monitor prefix phi"
lemma "check prefix phi"
by eval
subsection ‹Finite Domain›