Nominal/ExCoreHaskell.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 23 Mar 2010 09:38:03 +0100
changeset 1605 d46a32cfcd89
parent 1601 5f0bb35114c3
child 1606 75403378068b
permissions -rw-r--r--
compiles
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1601
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory ExCoreHaskell
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
imports "Parser"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
(* core haskell *)
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
ML {* val _ = recursive := false  *}
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
atom_decl var
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
atom_decl tvar
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
(* there are types, coercion types and regular types *)
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
(* list-data-structure
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
nominal_datatype tkind =
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  KStar
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
| KFun "tkind" "tkind"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
and ckind =
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  CKEq "ty" "ty"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
and ty =
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  TVar "tvar"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
| TC "string"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
| TApp "ty" "ty"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
| TFun "string" "ty list"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
| TAll tv::"tvar" "tkind" T::"ty"  bind tv in T
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
| TEq "ty" "ty" "ty"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
and co =
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
  CC "string"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
| CApp "co" "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
| CFun "string" "co list"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
| CAll tv::"tvar" "ckind" C::"co"  bind tv in C
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
| CEq "co" "co" "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
| CSym "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
| CCir "co" "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
| CLeft "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
| CRight "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
| CSim "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
| CRightc "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
| CLeftc "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
| CCoe "co" "co"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
abbreviation
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  "atoms A \<equiv> atom ` A"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
nominal_datatype trm =
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  Var "var"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
| C "string"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
| LAM tv::"tvar" "kind" t::"trm"   bind tv in t
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
| APP "trm" "ty"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
| Lam v::"var" "ty" t::"trm"       bind v in t
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
| App "trm" "trm"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
| Let x::"var" "ty" "trm" t::"trm" bind x in t
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
| Case "trm" "assoc list"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
| Cast "trm" "ty"                   --"ty is supposed to be a coercion type only"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
and assoc =
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
  A p::"pat" t::"trm" bind "bv p" in t
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
and pat =
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
  K "string" "(tvar \<times> kind) list" "(var \<times> ty) list"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
binder
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
 bv :: "pat \<Rightarrow> atom set"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
where
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
 "bv (K s ts vs) = (atoms (set (map fst ts))) \<union> (atoms (set (map fst vs)))"
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
*)
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
end
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
5f0bb35114c3 Added missing file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67