Theory Decl
section ‹Class Declarations and Programs›
theory Decl imports Type begin
type_synonym
fdecl = "vname × ty"
type_synonym
sig = "mname × ty list"
type_synonym
'c mdecl = "sig × ty × 'c"
type_synonym
'c "class" = "cname × fdecl list × 'c mdecl list"
type_synonym
'c cdecl = "cname × 'c class"
type_synonym
'c prog = "'c cdecl list"
translations
(type) "fdecl" <= (type) "vname × ty"
(type) "sig" <= (type) "mname × ty list"
(type) "'c mdecl" <= (type) "sig × ty × 'c"
(type) "'c class" <= (type) "cname × fdecl list × ('c mdecl) list"
(type) "'c cdecl" <= (type) "cname × ('c class)"
(type) "'c prog" <= (type) "('c cdecl) list"
definition "class" :: "'c prog => (cname ⇀ 'c class)" where
"class ≡ map_of"
definition is_class :: "'c prog => cname => bool" where
"is_class G C ≡ class G C ≠ None"
lemma finite_is_class: "finite {C. is_class G C}"
apply (unfold is_class_def class_def)
apply (fold dom_def)
apply (rule finite_dom_map_of)
done
primrec is_type :: "'c prog => ty => bool" where
"is_type G (PrimT pt) = True"
| "is_type G (RefT t) = (case t of NullT => True | ClassT C => is_class G C)"
end