src/HOL/Bali/Type.thy
author blanchet
Tue Sep 09 20:51:36 2014 +0200 (2014-09-09)
changeset 58249 180f1b3508ed
parent 37956 ee939247b2fb
child 58310 91ea607a34d8
permissions -rw-r--r--
use 'datatype_new' (soon to be renamed 'datatype') in Isabelle's libraries
wenzelm@12857
     1
(*  Title:      HOL/Bali/Type.thy
schirmer@12854
     2
    Author:     David von Oheimb
schirmer@12854
     3
*)
schirmer@12854
     4
schirmer@12854
     5
header {* Java types *}
schirmer@12854
     6
haftmann@16417
     7
theory Type imports Name begin
schirmer@12854
     8
schirmer@12854
     9
text {*
schirmer@12854
    10
simplifications:
schirmer@12854
    11
\begin{itemize}
schirmer@12854
    12
\item only the most important primitive types
schirmer@12854
    13
\item the null type is regarded as reference type
schirmer@12854
    14
\end{itemize}
schirmer@12854
    15
*}
schirmer@12854
    16
blanchet@58249
    17
datatype_new prim_ty        --{* primitive type, cf. 4.2 *}
wenzelm@32960
    18
        = Void          --{* result type of void methods *}
wenzelm@32960
    19
        | Boolean
wenzelm@32960
    20
        | Integer
schirmer@12854
    21
schirmer@12854
    22
blanchet@58249
    23
datatype_new ref_ty         --{* reference type, cf. 4.3 *}
wenzelm@32960
    24
        = NullT         --{* null type, cf. 4.1 *}
wenzelm@32960
    25
        | IfaceT qtname --{* interface type *}
wenzelm@32960
    26
        | ClassT qtname --{* class type *}
wenzelm@32960
    27
        | ArrayT ty     --{* array type *}
schirmer@12854
    28
wenzelm@32960
    29
and ty                  --{* any type, cf. 4.1 *}
wenzelm@32960
    30
        = PrimT prim_ty --{* primitive type *}
wenzelm@32960
    31
        | RefT  ref_ty  --{* reference type *}
schirmer@12854
    32
wenzelm@35067
    33
abbreviation "NT == RefT NullT"
wenzelm@35067
    34
abbreviation "Iface I == RefT (IfaceT I)"
wenzelm@35067
    35
abbreviation "Class C == RefT (ClassT C)"
wenzelm@35067
    36
abbreviation Array :: "ty \<Rightarrow> ty"  ("_.[]" [90] 90)
wenzelm@35067
    37
  where "T.[] == RefT (ArrayT T)"
schirmer@12854
    38
wenzelm@37956
    39
definition
wenzelm@37956
    40
  the_Class :: "ty \<Rightarrow> qtname"
wenzelm@37956
    41
  where "the_Class T = (SOME C. T = Class C)" (** primrec not possible here **)
schirmer@12854
    42
 
schirmer@12854
    43
lemma the_Class_eq [simp]: "the_Class (Class C)= C"
schirmer@12854
    44
by (auto simp add: the_Class_def)
schirmer@12854
    45
schirmer@12854
    46
end