src/Tools/isac/Interpret/specification-elems.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Sat, 21 Jan 2017 12:01:30 +0100
changeset 59300 7d50cc375b7e
parent 59299 bf6e43b9ce92
child 59301 627f60c233bf
permissions -rw-r--r--
prep 3 for structure Tac : TACTIC
wneuper@59298
     1
signature SPECIFY_ELEMENT =
wneuper@59298
     2
sig
wneuper@59298
     3
  type fmz
wneuper@59298
     4
  type fmz_
wneuper@59299
     5
  type result
wneuper@59299
     6
  val res2str : term * term list -> string
wneuper@59299
     7
  datatype safe = Sundef | Safe | Unsafe | Helpless;
wneuper@59299
     8
  val safe2str : safe -> string
wneuper@59299
     9
  type scrstate
wneuper@59300
    10
  datatype istate = RrlsState of rrlsstate | ScrState of scrstate | Uistate
wneuper@59300
    11
  val istate2str : istate -> string
wneuper@59300
    12
  val e_istate : istate
wneuper@59300
    13
wneuper@59298
    14
(*----- needed for tac, tac_ immediately (probably pre-requisites missing)
wneuper@59298
    15
  type istate
wneuper@59298
    16
  type subte
wneuper@59298
    17
  type subs
wneuper@59298
    18
  type sube
wneuper@59298
    19
*)
wneuper@59298
    20
(* ---- for tests only: made visible in order to remove the warning --------------------------- *)
wneuper@59298
    21
 val e_fmz : fmz_ * spec                                                  (* for datatypes.sml *)
wneuper@59300
    22
 val scrstate2str : subst * loc_ * term option * term * safe * bool -> string
wneuper@59298
    23
wneuper@59299
    24
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
wneuper@59298
    25
wneuper@59299
    26
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
wneuper@59298
    27
end
wneuper@59298
    28
wneuper@59298
    29
structure Selem(**): SPECIFY_ELEMENT(**) =
wneuper@59298
    30
struct
wneuper@59298
    31
wneuper@59298
    32
type fmz_ = cterm' list;
wneuper@59298
    33
(* a formalization of an example containing data 
wneuper@59298
    34
   sufficient for mechanically finding the solution for the example
wneuper@59298
    35
   FIXME.WN051014: dont store fmz = (_,spec) in the PblObj, this is done in origin *)
wneuper@59298
    36
type fmz = fmz_ * spec;
wneuper@59298
    37
val e_fmz = ([], e_spec);
wneuper@59298
    38
wneuper@59299
    39
type result = term * term list
wneuper@59299
    40
fun res2str (t, ts) = pair2str (term2str t, terms2str ts); (* for tests only *)
wneuper@59299
    41
wneuper@59299
    42
datatype safe = Sundef | Safe | Unsafe | Helpless;
wneuper@59299
    43
fun safe2str Sundef   = "Sundef"
wneuper@59299
    44
  | safe2str Safe     = "Safe"
wneuper@59299
    45
  | safe2str Unsafe   = "Unsafe" 
wneuper@59299
    46
  | safe2str Helpless = "Helpless";
wneuper@59299
    47
wneuper@59299
    48
type scrstate =  (* state for script interpreter                       *)
wneuper@59299
    49
	 env(*stack*)  (* used to instantiate tac for checking assod
wneuper@59299
    50
		                12.03.noticed: e_ not updated during execution ?!? *)
wneuper@59299
    51
	 * loc_        (* location of tac in script                          *)
wneuper@59299
    52
	 * term option (* argument of curried functions                      *)
wneuper@59299
    53
	 * term        (* value obtained by tac executed
wneuper@59299
    54
		                updated also after a derivation by 'new_val'       *)
wneuper@59299
    55
	 * safe        (* estimation of how result will be obtained          *)
wneuper@59299
    56
	 * bool;       (* true = strongly .., false = weakly associated: 
wneuper@59299
    57
					          only used during ass_dn/up                         *)
wneuper@59299
    58
fun topt2str NONE = "NONE"
wneuper@59299
    59
  | topt2str (SOME t) = "SOME" ^ term2str t;
wneuper@59299
    60
fun scrstate2str (env, loc_, topt, t, safe, bool) = (* for tests only *)
wneuper@59299
    61
  "(" ^ env2str env ^ ", " ^ loc_2str loc_ ^ ", " ^ topt2str topt ^ ", \n" ^ 
wneuper@59299
    62
  term2str t ^ ", " ^ safe2str safe ^ ", " ^ bool2str bool ^ ")";
wneuper@59299
    63
wneuper@59300
    64
(* for handling type istate see fun from_pblobj_or_detail', +? *)
wneuper@59300
    65
datatype istate =              (*interpreter state*)
wneuper@59300
    66
	  Uistate                    (*undefined in modspec, in '_deriv'ation*)
wneuper@59300
    67
  | ScrState of scrstate       (*for script interpreter*)
wneuper@59300
    68
  | RrlsState of rrlsstate;    (*for reverse rewriting*)
wneuper@59300
    69
val e_istate = (ScrState ([], [], NONE, e_term, Sundef, false));
wneuper@59300
    70
wneuper@59300
    71
fun rta2str (r, (t, a)) = "\n(" ^ rule2str r ^ ",(" ^ term2str t ^", " ^ terms2str a ^ "))";
wneuper@59300
    72
fun istate2str Uistate = "Uistate"
wneuper@59300
    73
  | istate2str (ScrState (e, l, to, t, s, b)) =
wneuper@59300
    74
    "ScrState ("^ subst2str e ^ ",\n " ^ 
wneuper@59300
    75
    loc_2str l ^ ", " ^ termopt2str to ^ ",\n " ^
wneuper@59300
    76
    term2str t ^ ", " ^ safe2str s ^ ", " ^ bool2str b ^ ")"
wneuper@59300
    77
  | istate2str (RrlsState (t, t1, rss, rtas)) = 
wneuper@59300
    78
    "RrlsState (" ^ term2str t ^ ", " ^ term2str t1 ^ ", " ^
wneuper@59300
    79
    (strs2str o (map (strs2str o (map rule2str)))) rss ^ ", " ^
wneuper@59300
    80
    (strs2str o (map rta2str)) rtas ^ ")";
wneuper@59300
    81
fun istates2str (NONE, NONE) = "(#NONE, #NONE)"  (* for tests only *)
wneuper@59300
    82
  | istates2str (NONE, SOME ist) = "(#NONE,\n#SOME " ^ istate2str ist ^ ")"
wneuper@59300
    83
  | istates2str (SOME ist, NONE) = "(#SOME " ^ istate2str ist ^ ",\n #NONE)"
wneuper@59300
    84
  | istates2str (SOME i1, SOME i2) = "(#SOME " ^ istate2str i1 ^ ",\n #SOME " ^ istate2str i2 ^ ")";
wneuper@59300
    85
wneuper@59298
    86
end