author | wenzelm |
Wed, 03 Mar 2010 00:33:02 +0100 | |
changeset 35431 | 8758fe1fc9f8 |
parent 35069 | 09154b995ed8 |
child 37956 | ee939247b2fb |
permissions | -rw-r--r-- |
12857 | 1 |
(* Title: HOL/Bali/Value.thy |
12854 | 2 |
Author: David von Oheimb |
3 |
*) |
|
4 |
header {* Java values *} |
|
5 |
||
6 |
||
7 |
||
16417 | 8 |
theory Value imports Type begin |
12854 | 9 |
|
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
12858
diff
changeset
|
10 |
typedecl loc --{* locations, i.e. abstract references on objects *} |
12854 | 11 |
|
12 |
datatype val |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
13 |
= Unit --{* dummy result value of void methods *} |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
14 |
| Bool bool --{* Boolean value *} |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
15 |
| Intg int --{* integer value *} |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
16 |
| Null --{* null reference *} |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
17 |
| Addr loc --{* addresses, i.e. locations of objects *} |
12854 | 18 |
|
19 |
||
20 |
consts the_Bool :: "val \<Rightarrow> bool" |
|
21 |
primrec "the_Bool (Bool b) = b" |
|
22 |
consts the_Intg :: "val \<Rightarrow> int" |
|
23 |
primrec "the_Intg (Intg i) = i" |
|
24 |
consts the_Addr :: "val \<Rightarrow> loc" |
|
25 |
primrec "the_Addr (Addr a) = a" |
|
26 |
||
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
27 |
types dyn_ty = "loc \<Rightarrow> ty option" |
12854 | 28 |
consts |
29 |
typeof :: "dyn_ty \<Rightarrow> val \<Rightarrow> ty option" |
|
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
12858
diff
changeset
|
30 |
defpval :: "prim_ty \<Rightarrow> val" --{* default value for primitive types *} |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
12858
diff
changeset
|
31 |
default_val :: " ty \<Rightarrow> val" --{* default value for all types *} |
12854 | 32 |
|
33 |
primrec "typeof dt Unit = Some (PrimT Void)" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
34 |
"typeof dt (Bool b) = Some (PrimT Boolean)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
35 |
"typeof dt (Intg i) = Some (PrimT Integer)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
36 |
"typeof dt Null = Some NT" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
37 |
"typeof dt (Addr a) = dt a" |
12854 | 38 |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
39 |
primrec "defpval Void = Unit" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
40 |
"defpval Boolean = Bool False" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
41 |
"defpval Integer = Intg 0" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
42 |
primrec "default_val (PrimT pt) = defpval pt" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
17160
diff
changeset
|
43 |
"default_val (RefT r ) = Null" |
12854 | 44 |
|
45 |
end |