Nominal/Ex/ExLeroy.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 27 Apr 2010 14:29:59 +0200
changeset 1958 e2e19188576e
parent 1773 c0eac04ae3b4
child 2042 495b6feb76a8
permissions -rw-r--r--
Function in Core Haskell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1600
e33e37fd4c7d More reorganization.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1599
diff changeset
     1
theory ExLeroy
1773
c0eac04ae3b4 added README and moved examples into separate directory
Christian Urban <urbanc@in.tum.de>
parents: 1600
diff changeset
     2
imports "../Parser"
1599
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
(* example form Leroy 96 about modules; OTT *)
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
atom_decl name
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
ML {* val _ = recursive := false  *}
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
nominal_datatype mexp =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
  Acc "path"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
| Stru "body"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
| Funct x::"name" "sexp" m::"mexp"    bind x in m
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
| FApp "mexp" "path"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
| Ascr "mexp" "sexp"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
and body =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  Empty
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
| Seq c::defn d::"body"     bind "cbinders c" in d
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
and defn =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  Type "name" "tyty"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
| Dty "name"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
| DStru "name" "mexp"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
| Val "name" "trmtrm"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
and sexp =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  Sig sbody
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
| SFunc "name" "sexp" "sexp"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
and sbody =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
  SEmpty
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
| SSeq C::spec D::sbody    bind "Cbinders C" in D
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
and spec =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  Type1 "name"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
| Type2 "name" "tyty"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
| SStru "name" "sexp"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
| SVal "name" "tyty"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
and tyty =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
  Tyref1 "name"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
| Tyref2 "path" "tyty"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
| Fun "tyty" "tyty"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
and path =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
  Sref1 "name"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
| Sref2 "path" "name"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
and trmtrm =
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  Tref1 "name"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
| Tref2 "path" "name"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
| Lam' v::"name" "tyty" M::"trmtrm"  bind v in M
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
| App' "trmtrm" "trmtrm"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
| Let' "body" "trmtrm"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
binder
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
    cbinders :: "defn \<Rightarrow> atom set"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
and Cbinders :: "spec \<Rightarrow> atom set"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
where
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
  "cbinders (Type t T) = {atom t}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
| "cbinders (Dty t) = {atom t}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
| "cbinders (DStru x s) = {atom x}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
| "cbinders (Val v M) = {atom v}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
| "Cbinders (Type1 t) = {atom t}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
| "Cbinders (Type2 t T) = {atom t}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
| "Cbinders (SStru x S) = {atom x}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
| "Cbinders (SVal v T) = {atom v}"
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.fv
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.eq_iff
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.bn
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.perm
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.induct
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.inducts
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.distinct
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.supp
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.fv[simplified mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.supp]
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
end
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
8b5a1ad60487 Move Leroy out of Test, rename accordingly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74