walther@59659
|
1 |
(* Title: interpreter-state for Lucas-Interpretation
|
walther@59659
|
2 |
Author: Walther Neuper 191017
|
walther@59659
|
3 |
(c) due to copyright terms
|
walther@59659
|
4 |
*)
|
walther@59659
|
5 |
signature ENVIRONMENT =
|
walther@59659
|
6 |
sig
|
walther@59659
|
7 |
(*Celem*)
|
walther@59659
|
8 |
type T
|
walther@59659
|
9 |
val env2str: Rule.subst -> string
|
walther@59659
|
10 |
val subst2str: Rule.subst -> string
|
walther@59659
|
11 |
val subst2str': Rule.subst -> string
|
walther@59697
|
12 |
val update: T -> term * term -> T
|
walther@59697
|
13 |
val update': term -> term * T -> T
|
walther@59697
|
14 |
val update_opt: T -> term option * term -> T
|
walther@59697
|
15 |
val update_opt': T * (term option * term) -> T
|
walther@59697
|
16 |
val update_opt'': ((term * T) * term option) -> T
|
walther@59659
|
17 |
|
walther@59659
|
18 |
end
|
walther@59659
|
19 |
|
walther@59659
|
20 |
(**)
|
walther@59659
|
21 |
structure Env(**): ENVIRONMENT(**) =
|
walther@59659
|
22 |
struct
|
walther@59659
|
23 |
(**)
|
walther@59659
|
24 |
type T = (term * term) list;
|
walther@59659
|
25 |
|
walther@59660
|
26 |
fun subst2str s =
|
walther@59660
|
27 |
(strs2str o
|
walther@59660
|
28 |
(map (
|
walther@59660
|
29 |
Celem.linefeed o pair2str o (apsnd Rule.term2str) o (apfst Rule.term2str)))) s;
|
walther@59660
|
30 |
fun subst2str' s =
|
walther@59660
|
31 |
(strs2str' o
|
walther@59660
|
32 |
(map (
|
walther@59660
|
33 |
pair2str o (apsnd Rule.term2str) o (apfst Rule.term2str)))) s;
|
walther@59660
|
34 |
val env2str = subst2str;
|
walther@59660
|
35 |
|
walther@59659
|
36 |
(* update environment; t <> empty if coming from listexpr *)
|
walther@59697
|
37 |
fun update env (id, vl) =
|
walther@59668
|
38 |
let val env' = if vl = Rule.e_term then env else overwrite (env, (id, vl));
|
walther@59659
|
39 |
in env' end;
|
walther@59697
|
40 |
fun update' id (vl, env) = update env (id, vl)
|
walther@59659
|
41 |
|
walther@59691
|
42 |
(*WN020526: not clear, when a is available in scan_up1 for eval_true*)
|
walther@59659
|
43 |
(*WN060906: in "fun handle_leaf" eg. uses "SOME M__"(from some PREVIOUS
|
walther@59659
|
44 |
curried Rewrite) for CURRENT value (which may be different from PREVIOUS);
|
walther@59659
|
45 |
thus "NONE" must be set at the end of currying (ill designed anyway)*)
|
walther@59697
|
46 |
fun update_opt env (SOME id, vl) = update env (id, vl)
|
walther@59697
|
47 |
| update_opt env (NONE, vl) =
|
walther@59697
|
48 |
((**)tracing ("*** update_opt: (NONE," ^ Rule.term2str vl ^ ")");(**) env);
|
walther@59697
|
49 |
fun update_opt' (env, (id, vl)) = update_opt env (id, vl)
|
walther@59697
|
50 |
fun update_opt'' ((vl, env), id) = update_opt env (id, vl)
|
walther@59659
|
51 |
|
walther@59659
|
52 |
|
walther@59659
|
53 |
(**)end(**)
|