src/HOL/NanoJava/Decl.thy
author huffman
Thu, 08 Sep 2011 10:07:53 -0700
changeset 44846 e9d1fcbc7d20
parent 44375 dfc2e722fe47
child 58249 180f1b3508ed
permissions -rw-r--r--
remove unnecessary intermediate lemmas
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     1
(*  Title:      HOL/NanoJava/Decl.thy
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     2
    Author:     David von Oheimb
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     3
    Copyright   2001 Technische Universitaet Muenchen
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     4
*)
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     5
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     6
header "Types, class Declarations, and whole programs"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14134
diff changeset
     8
theory Decl imports Term begin
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
     9
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    10
datatype ty
11558
6539627881e8 simplified vnam/vname, introduced fname, improved comments
oheimb
parents: 11486
diff changeset
    11
  = NT           --{* null type  *}
6539627881e8 simplified vnam/vname, introduced fname, improved comments
oheimb
parents: 11486
diff changeset
    12
  | Class cname  --{* class type *}
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    13
11565
ab004c0ecc63 Minor improvements, added Example
oheimb
parents: 11558
diff changeset
    14
text{* Field declaration *}
42463
f270e3e18be5 modernized specifications;
wenzelm
parents: 35431
diff changeset
    15
type_synonym fdecl           
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    16
        = "fname \<times> ty"
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    17
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    18
record  methd           
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    19
        = par :: ty 
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    20
          res :: ty 
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    21
          lcl ::"(vname \<times> ty) list"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    22
          bdy :: stmt
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    23
11565
ab004c0ecc63 Minor improvements, added Example
oheimb
parents: 11558
diff changeset
    24
text{* Method declaration *}
42463
f270e3e18be5 modernized specifications;
wenzelm
parents: 35431
diff changeset
    25
type_synonym mdecl
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    26
        = "mname \<times> methd"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    27
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    28
record  "class"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    29
        = super   :: cname
12264
9c356e2da72f renamed "fields" to "flds" (avoid clash with new "fields" operation);
wenzelm
parents: 11565
diff changeset
    30
          flds    ::"fdecl list"
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    31
          methods ::"mdecl list"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    32
11565
ab004c0ecc63 Minor improvements, added Example
oheimb
parents: 11558
diff changeset
    33
text{* Class declaration *}
42463
f270e3e18be5 modernized specifications;
wenzelm
parents: 35431
diff changeset
    34
type_synonym cdecl
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    35
        = "cname \<times> class"
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    36
42463
f270e3e18be5 modernized specifications;
wenzelm
parents: 35431
diff changeset
    37
type_synonym prog
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    38
        = "cdecl list"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    39
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    40
translations
35431
8758fe1fc9f8 cleanup type translations;
wenzelm
parents: 35416
diff changeset
    41
  (type) "fdecl" \<leftharpoondown> (type) "fname \<times> ty"
8758fe1fc9f8 cleanup type translations;
wenzelm
parents: 35416
diff changeset
    42
  (type) "mdecl" \<leftharpoondown> (type) "mname \<times> ty \<times> ty \<times> stmt"
8758fe1fc9f8 cleanup type translations;
wenzelm
parents: 35416
diff changeset
    43
  (type) "class" \<leftharpoondown> (type) "cname \<times> fdecl list \<times> mdecl list"
8758fe1fc9f8 cleanup type translations;
wenzelm
parents: 35416
diff changeset
    44
  (type) "cdecl" \<leftharpoondown> (type) "cname \<times> class"
8758fe1fc9f8 cleanup type translations;
wenzelm
parents: 35416
diff changeset
    45
  (type) "prog " \<leftharpoondown> (type) "cdecl list"
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    46
44375
dfc2e722fe47 modernized specifications
krauss
parents: 42463
diff changeset
    47
axiomatization
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    48
  Prog    :: prog       --{* program as a global value *}
44375
dfc2e722fe47 modernized specifications
krauss
parents: 42463
diff changeset
    49
and
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 18551
diff changeset
    50
  Object  :: cname      --{* name of root class *}
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    51
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    52
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    53
definition "class" :: "cname \<rightharpoonup> class" where
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    54
 "class      \<equiv> map_of Prog"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    55
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    56
definition is_class   :: "cname => bool" where
11376
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    57
 "is_class C \<equiv> class C \<noteq> None"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    58
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    59
lemma finite_is_class: "finite {C. is_class C}"
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    60
apply (unfold is_class_def class_def)
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    61
apply (fold dom_def)
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    62
apply (rule finite_dom_map_of)
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    63
done
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    64
bf98ad1c22c6 added NanoJava
oheimb
parents:
diff changeset
    65
end