Theory OBJ
theory OBJ imports Main begin
section‹Base-line non-interference with objects›
text‹\label{sec:Objects} We now extend the encoding for base-line
non-interference to a language with objects. The development follows
the structure of Sections \ref{sec:IMP} to
\ref{sec:BaseLineNI}. Syntax and operational semantics are defined in
Section \ref{sec:ObjLanguage}, the axiomatic semantics in Section
\ref{sec:ObjLogic}. The generalised definition of non-interference is
given in \ref{sec:ObjNI}, the derived proof rules in Section
\ref{sec:ObjDerivedRules}, and a type system in the style of Volpano
et al.~in Section \ref{sec:ObjTypeSystem}. Finally, Section
\ref{sec:contextObj} concludes with results on contextual closure.›
subsection ‹Syntax and operational semantics›
text‹\label{sec:ObjLanguage}›
text‹First, some operations for association lists›
primrec lookup :: "('a × 'b) list ⇒ 'a ⇒ 'b option"
where
"lookup [] l = None" |
"lookup (h # t) l = (if (fst h)=l then Some (snd h) else lookup t l)"
definition Dom::"('a × 'b) list ⇒ 'a set"
where "Dom L = {l . ∃ a . lookup L l = Some a}"
lemma lookupNoneAppend[rule_format]:
"∀ l L2. (lookup L1 l = None ⟶ lookup L2 l = None ⟶ lookup (L1 @ L2) l = None)"
by (induct L1, simp+)
lemma DomAppendUnion[rule_format]: "∀ ab. Dom (a @ ab) = Dom a ∪ Dom ab"
apply (induct a)
apply (simp add: Dom_def)
apply (simp add: Dom_def)
apply clarsimp apply fast
done
lemma DomAppend: "Dom L ⊆ Dom((a, b) # L)"
by (simp add: Dom_def, auto)
lemma lookupSomeAppend1[rule_format]:
"∀ L2 l c . lookup L1 l = Some c ⟶ lookup (L1 @ L2) l = Some c"
by (induct L1, simp, simp)
lemma DomUnion[rule_format]:"Dom ((a,b) # L) = {a} ∪ Dom L"
by (simp add: Dom_def DomAppendUnion, fast)
lemma lookupSomeAppend2[rule_format]:
"∀ l c L2 . lookup L2 l = Some c ⟶ Dom L1 ∩ Dom L2 = {} ⟶ lookup (L1 @ L2) l = Some c"
apply (induct L1)
apply (simp add: Dom_def)
apply clarsimp
apply rule
apply clarsimp apply (subgoal_tac "l:Dom L2") apply (simp add: DomUnion)
apply (simp add: Dom_def)
apply clarsimp
apply (erule_tac x=l in allE)
apply (erule_tac x=c in allE)
apply (erule_tac x=L2 in allE)
apply simp apply (erule impE) apply (simp add: DomUnion)
apply simp
done
text‹Abstract types of variables, class names, field names, and
locations.›
typedecl Var
typedecl Class
typedecl Field
typedecl Location
text‹References are either null or a location. Values are either
integers or references.›
datatype Ref = Nullref | Loc Location
datatype Val = RVal Ref | IVal int
text‹The heap is a finite map from locations to objects. Objects have
a dynamic class and a field map.›
type_synonym Object = "Class × ((Field × Val) list)"
type_synonym Heap = "(Location × Object) list"
text‹Stores contain values for all variables, and states are pairs of
stores and heaps.›
type_synonym Store = "Var ⇒ Val"
definition update :: "Store ⇒ Var ⇒ Val ⇒ Store"
where "update s x v = (λ y . if x=y then v else s y)"
type_synonym State = "Store × Heap"
text‹Arithmetic and boolean expressions are as before.›