Theory BaseClass
section‹The Class Infrastructure›
text‹In this theory, we introduce the basic infrastructure for our encoding
of classes.›
theory BaseClass
imports
"HOL-Library.Finite_Map"
"../pointers/Ref"
"../Core_DOM_Basic_Datatypes"
begin
named_theorems instances
consts get :: 'a
consts put :: 'a
consts delete :: 'a
text ‹Overall, the definition of the class types follows closely the one of the pointer
types. Instead of datatypes, we use records for our classes. This allows us to, first,
make use of record inheritance, which is, in addition to the type synonyms of
previous class types, the second place where the inheritance relationship of
our types manifest. Second, we get a convenient notation to define classes, in
addition to automatically generated getter and setter functions.›
text ‹Along with our class types, we also develop our heap type, which is a finite
map at its core. It is important to note that while the map stores a mapping
from @{term "object_ptr"} to @{term "Object"}, we restrict the type variables
of the record extension slot of @{term "Object"} in such a way that allows
down-casting, but requires a bit of taking-apart and re-assembling of our records
before they are stored in the heap.›
text ‹Throughout the theory files, we will use underscore case to reference pointer
types, and camel case for class types.›
text ‹Every class type contains at least one attribute; nothing. This is used for
two purposes: first, the record package does not allow records without any
attributes. Second, we will use the getter of nothing later to check whether a
class of the correct type could be retrieved, for which we will be able to use
our infrastructure regarding the behaviour of getters across different heaps.›
locale l_type_wf = fixes type_wf :: "'heap ⇒ bool"
locale l_known_ptr = fixes known_ptr :: "'ptr ⇒ bool"
end