src/HOL/ex/MT.thy
author krauss
Thu, 17 May 2007 22:33:41 +0200
changeset 22999 c1ce129e6f9c
parent 17289 8608f7a881eb
child 24326 3e9d3ba894b8
permissions -rw-r--r--
Added unification case study (using new function package)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
     1
(*  Title:      HOL/ex/mt.thy
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
     3
    Author:     Jacob Frost, Cambridge University Computer Laboratory
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     5
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     6
Based upon the article
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
    Robin Milner and Mads Tofte,
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
    Co-induction in Relational Semantics,
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
    Theoretical Computer Science 87 (1991), pages 209-220.
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
Written up as
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    12
    Jacob Frost, A Case Study of Co_induction in Isabelle/HOL
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    13
    Report 308, Computer Lab, University of Cambridge (1993).
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    14
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    15
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    16
theory MT
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    17
imports Main
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    18
begin
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    19
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    20
typedecl Const
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    21
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    22
typedecl ExVar
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    23
typedecl Ex
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    24
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    25
typedecl TyConst
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    26
typedecl Ty
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    27
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    28
typedecl Clos
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    29
typedecl Val
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    30
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    31
typedecl ValEnv
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    32
typedecl TyEnv
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    33
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    34
consts
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    35
  c_app :: "[Const, Const] => Const"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    36
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    37
  e_const :: "Const => Ex"
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    38
  e_var :: "ExVar => Ex"
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    39
  e_fn :: "[ExVar, Ex] => Ex" ("fn _ => _" [0,51] 1000)
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    40
  e_fix :: "[ExVar, ExVar, Ex] => Ex" ("fix _ ( _ ) = _" [0,51,51] 1000)
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    41
  e_app :: "[Ex, Ex] => Ex" ("_ @@ _" [51,51] 1000)
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    42
  e_const_fst :: "Ex => Const"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    43
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    44
  t_const :: "TyConst => Ty"
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    45
  t_fun :: "[Ty, Ty] => Ty" ("_ -> _" [51,51] 1000)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    46
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    47
  v_const :: "Const => Val"
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    48
  v_clos :: "Clos => Val"
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    49
1376
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    50
  ve_emp :: ValEnv
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    51
  ve_owr :: "[ValEnv, ExVar, Val] => ValEnv" ("_ + { _ |-> _ }" [36,0,0] 50)
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    52
  ve_dom :: "ValEnv => ExVar set"
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    53
  ve_app :: "[ValEnv, ExVar] => Val"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    54
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    55
  clos_mk :: "[ExVar, Ex, ValEnv] => Clos" ("<| _ , _ , _ |>" [0,0,0] 1000)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    56
1376
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    57
  te_emp :: TyEnv
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    58
  te_owr :: "[TyEnv, ExVar, Ty] => TyEnv" ("_ + { _ |=> _ }" [36,0,0] 50)
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    59
  te_app :: "[TyEnv, ExVar] => Ty"
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    60
  te_dom :: "TyEnv => ExVar set"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    61
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    62
  eval_fun :: "((ValEnv * Ex) * Val) set => ((ValEnv * Ex) * Val) set"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    63
  eval_rel :: "((ValEnv * Ex) * Val) set"
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    64
  eval :: "[ValEnv, Ex, Val] => bool" ("_ |- _ ---> _" [36,0,36] 50)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    65
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    66
  elab_fun :: "((TyEnv * Ex) * Ty) set => ((TyEnv * Ex) * Ty) set"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    67
  elab_rel :: "((TyEnv * Ex) * Ty) set"
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    68
  elab :: "[TyEnv, Ex, Ty] => bool" ("_ |- _ ===> _" [36,0,36] 50)
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    69
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    70
  isof :: "[Const, Ty] => bool" ("_ isof _" [36,36] 50)
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    71
  isof_env :: "[ValEnv,TyEnv] => bool" ("_ isofenv _")
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    72
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    73
  hasty_fun :: "(Val * Ty) set => (Val * Ty) set"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    74
  hasty_rel :: "(Val * Ty) set"
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    75
  hasty :: "[Val, Ty] => bool" ("_ hasty _" [36,36] 50)
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
    76
  hasty_env :: "[ValEnv,TyEnv] => bool" ("_ hastyenv _ " [36,36] 35)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    77
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    78
axioms
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    79
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    80
(*
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    81
  Expression constructors must be injective, distinct and it must be possible
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    82
  to do induction over expressions.
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    83
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    84
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    85
(* All the constructors are injective *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    86
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    87
  e_const_inj: "e_const(c1) = e_const(c2) ==> c1 = c2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    88
  e_var_inj: "e_var(ev1) = e_var(ev2) ==> ev1 = ev2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    89
  e_fn_inj: "fn ev1 => e1 = fn ev2 => e2 ==> ev1 = ev2 & e1 = e2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    90
  e_fix_inj:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    91
    " fix ev11e(v12) = e1 = fix ev21(ev22) = e2 ==>
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    92
     ev11 = ev21 & ev12 = ev22 & e1 = e2
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
    93
   "
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    94
  e_app_inj: "e11 @@ e12 = e21 @@ e22 ==> e11 = e21 & e12 = e22"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    95
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    96
(* All constructors are distinct *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    97
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    98
  e_disj_const_var: "~e_const(c) = e_var(ev)"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
    99
  e_disj_const_fn: "~e_const(c) = fn ev => e"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   100
  e_disj_const_fix: "~e_const(c) = fix ev1(ev2) = e"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   101
  e_disj_const_app: "~e_const(c) = e1 @@ e2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   102
  e_disj_var_fn: "~e_var(ev1) = fn ev2 => e"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   103
  e_disj_var_fix: "~e_var(ev) = fix ev1(ev2) = e"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   104
  e_disj_var_app: "~e_var(ev) = e1 @@ e2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   105
  e_disj_fn_fix: "~fn ev1 => e1 = fix ev21(ev22) = e2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   106
  e_disj_fn_app: "~fn ev1 => e1 = e21 @@ e22"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   107
  e_disj_fix_app: "~fix ev11(ev12) = e1 = e21 @@ e22"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   108
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   109
(* Strong elimination, induction on expressions  *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   110
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   111
  e_ind:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   112
    " [|  !!ev. P(e_var(ev));
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   113
         !!c. P(e_const(c));
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   114
         !!ev e. P(e) ==> P(fn ev => e);
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   115
         !!ev1 ev2 e. P(e) ==> P(fix ev1(ev2) = e);
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   116
         !!e1 e2. P(e1) ==> P(e2) ==> P(e1 @@ e2)
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   117
     |] ==>
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   118
   P(e)
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   119
   "
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   120
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   121
(* Types - same scheme as for expressions *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   122
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   123
(* All constructors are injective *)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   124
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   125
  t_const_inj: "t_const(c1) = t_const(c2) ==> c1 = c2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   126
  t_fun_inj: "t11 -> t12 = t21 -> t22 ==> t11 = t21 & t12 = t22"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   127
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   128
(* All constructors are distinct, not needed so far ... *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   129
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   130
(* Strong elimination, induction on types *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   131
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   132
 t_ind:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   133
    "[| !!p. P(t_const p); !!t1 t2. P(t1) ==> P(t2) ==> P(t_fun t1 t2) |]
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   134
    ==> P(t)"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   135
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   136
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   137
(* Values - same scheme again *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   138
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   139
(* All constructors are injective *)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   140
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   141
  v_const_inj: "v_const(c1) = v_const(c2) ==> c1 = c2"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   142
  v_clos_inj:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   143
    " v_clos(<|ev1,e1,ve1|>) = v_clos(<|ev2,e2,ve2|>) ==>
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   144
     ev1 = ev2 & e1 = e2 & ve1 = ve2"
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   145
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   146
(* All constructors are distinct *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   147
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   148
  v_disj_const_clos: "~v_const(c) = v_clos(cl)"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   149
15450
43dfc914d1b8 inserted quotes preparatory to conversion
paulson
parents: 12338
diff changeset
   150
(* No induction on values: they are a codatatype! ... *)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   151
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   152
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   153
(*
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   154
  Value environments bind variables to values. Only the following trivial
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   155
  properties are needed.
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   156
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   157
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   158
  ve_dom_owr: "ve_dom(ve + {ev |-> v}) = ve_dom(ve) Un {ev}"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   159
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   160
  ve_app_owr1: "ve_app (ve + {ev |-> v}) ev=v"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   161
  ve_app_owr2: "~ev1=ev2 ==> ve_app (ve+{ev1 |-> v}) ev2=ve_app ve ev2"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   162
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   163
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   164
(* Type Environments bind variables to types. The following trivial
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   165
properties are needed.  *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   166
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   167
  te_dom_owr: "te_dom(te + {ev |=> t}) = te_dom(te) Un {ev}"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   168
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   169
  te_app_owr1: "te_app (te + {ev |=> t}) ev=t"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   170
  te_app_owr2: "~ev1=ev2 ==> te_app (te+{ev1 |=> t}) ev2=te_app te ev2"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   171
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   172
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   173
(* The dynamic semantics is defined inductively by a set of inference
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   174
rules.  These inference rules allows one to draw conclusions of the form ve
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   175
|- e ---> v, read the expression e evaluates to the value v in the value
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   176
environment ve.  Therefore the relation _ |- _ ---> _ is defined in Isabelle
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   177
as the least fixpoint of the functor eval_fun below.  From this definition
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   178
introduction rules and a strong elimination (induction) rule can be
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   179
derived.
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   180
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   181
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   182
defs
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   183
  eval_fun_def:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   184
    " eval_fun(s) ==
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   185
     { pp.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   186
       (? ve c. pp=((ve,e_const(c)),v_const(c))) |
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   187
       (? ve x. pp=((ve,e_var(x)),ve_app ve x) & x:ve_dom(ve)) |
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   188
       (? ve e x. pp=((ve,fn x => e),v_clos(<|x,e,ve|>)))|
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   189
       ( ? ve e x f cl.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   190
           pp=((ve,fix f(x) = e),v_clos(cl)) &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   191
           cl=<|x, e, ve+{f |-> v_clos(cl)} |>
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   192
       ) |
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   193
       ( ? ve e1 e2 c1 c2.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   194
           pp=((ve,e1 @@ e2),v_const(c_app c1 c2)) &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   195
           ((ve,e1),v_const(c1)):s & ((ve,e2),v_const(c2)):s
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   196
       ) |
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   197
       ( ? ve vem e1 e2 em xm v v2.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   198
           pp=((ve,e1 @@ e2),v) &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   199
           ((ve,e1),v_clos(<|xm,em,vem|>)):s &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   200
           ((ve,e2),v2):s &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   201
           ((vem+{xm |-> v2},em),v):s
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   202
       )
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   203
     }"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   204
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   205
  eval_rel_def: "eval_rel == lfp(eval_fun)"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   206
  eval_def: "ve |- e ---> v == ((ve,e),v):eval_rel"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   207
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   208
(* The static semantics is defined in the same way as the dynamic
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   209
semantics.  The relation te |- e ===> t express the expression e has the
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   210
type t in the type environment te.
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   211
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   212
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   213
  elab_fun_def:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   214
  "elab_fun(s) ==
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   215
  { pp.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   216
    (? te c t. pp=((te,e_const(c)),t) & c isof t) |
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   217
    (? te x. pp=((te,e_var(x)),te_app te x) & x:te_dom(te)) |
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   218
    (? te x e t1 t2. pp=((te,fn x => e),t1->t2) & ((te+{x |=> t1},e),t2):s) |
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   219
    (? te f x e t1 t2.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   220
       pp=((te,fix f(x)=e),t1->t2) & ((te+{f |=> t1->t2}+{x |=> t1},e),t2):s
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   221
    ) |
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   222
    (? te e1 e2 t1 t2.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   223
       pp=((te,e1 @@ e2),t2) & ((te,e1),t1->t2):s & ((te,e2),t1):s
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   224
    )
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   225
  }"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   226
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   227
  elab_rel_def: "elab_rel == lfp(elab_fun)"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   228
  elab_def: "te |- e ===> t == ((te,e),t):elab_rel"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   229
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   230
(* The original correspondence relation *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   231
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   232
  isof_env_def:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   233
    " ve isofenv te ==
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   234
     ve_dom(ve) = te_dom(te) &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   235
     ( ! x.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   236
         x:ve_dom(ve) -->
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   237
         (? c. ve_app ve x = v_const(c) & c isof te_app te x)
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   238
     )
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   239
   "
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   240
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   241
axioms
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   242
  isof_app: "[| c1 isof t1->t2; c2 isof t1 |] ==> c_app c1 c2 isof t2"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   243
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   244
defs
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   245
(* The extented correspondence relation *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   246
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   247
  hasty_fun_def:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   248
    " hasty_fun(r) ==
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   249
     { p.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   250
       ( ? c t. p = (v_const(c),t) & c isof t) |
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   251
       ( ? ev e ve t te.
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   252
           p = (v_clos(<|ev,e,ve|>),t) &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   253
           te |- fn ev => e ===> t &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   254
           ve_dom(ve) = te_dom(te) &
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   255
           (! ev1. ev1:ve_dom(ve) --> (ve_app ve ev1,te_app te ev1) : r)
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   256
       )
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   257
     }
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   258
   "
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   259
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   260
  hasty_rel_def: "hasty_rel == gfp(hasty_fun)"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   261
  hasty_def: "v hasty t == (v,t) : hasty_rel"
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   262
  hasty_env_def:
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   263
    " ve hastyenv te ==
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   264
     ve_dom(ve) = te_dom(te) &
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 1026
diff changeset
   265
     (! x. x: ve_dom(ve) --> ve_app ve x hasty te_app te x)"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   266
17289
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   267
ML {* use_legacy_bindings (the_context ()) *}
8608f7a881eb converted to Isar theory format;
wenzelm
parents: 15450
diff changeset
   268
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   269
end