src/Tools/isac/Specify/model.sml
author Walther Neuper <walther.neuper@jku.at>
Sat, 09 May 2020 15:31:15 +0200
changeset 59956 05e5a8498634
parent 59953 933211a252f2
child 59958 c06b7df89dcd
permissions -rw-r--r--
collect code for I_Model.add_single
wneuper@59316
     1
(* Title: Model for (sub-)calculations.
wneuper@59316
     2
          Various representations: item and ppc for frontend, itm_ and itm for internal functions.
wneuper@59316
     3
          The former are related to structure Specify, the latter to structure Chead --
wneuper@59316
     4
          -- apt to re-arrangement of structures
wneuper@59316
     5
   Author: Walther Neuper 170207
wneuper@59316
     6
   (c) due to copyright terms
wneuper@59316
     7
*)
wneuper@59316
     8
wneuper@59316
     9
signature MODEL =
wneuper@59316
    10
sig
wneuper@59316
    11
  datatype item
walther@59865
    12
  = Correct of TermC.as_string | False of TermC.as_string | Incompl of TermC.as_string | Missing of TermC.as_string | Superfl of string
wneuper@59316
    13
     | SyntaxE of string | TypeE of string
walther@59943
    14
wneuper@59316
    15
  type 'a ppc
wneuper@59316
    16
  val empty_ppc : item ppc
wneuper@59316
    17
  val ppc2str : {Find: string list, Given: string list, Relate: string list, Where: string list,
wneuper@59316
    18
    With: string list} -> string
wneuper@59316
    19
  val itemppc2str : item ppc -> string
wneuper@59316
    20
wneuper@59316
    21
  val mkval' : term list -> term
wneuper@59316
    22
wneuper@59316
    23
(* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
walther@59943
    24
  (* NONE *)
walther@59886
    25
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
wneuper@59316
    26
  (* NONE *)
walther@59886
    27
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
wneuper@59316
    28
end
wneuper@59316
    29
wneuper@59316
    30
structure Model(**) : MODEL(**) =
wneuper@59316
    31
struct
wneuper@59316
    32
(*==========================================================================
walther@59943
    33
23.3.02 TODO: ideas on redesign of type I_Model.feedback,type item,type ori,type item ppc
wneuper@59316
    34
(1) kinds of itms:
wneuper@59316
    35
  (1.1) untouched: for modeling only dsc displayed(impossible after match_itms)
wneuper@59316
    36
        =(presently) Mis (? should be Inc initially, and Mis after match_itms?)
wneuper@59316
    37
  (1.2)  Syn,Typ,Sup: not related to oris
walther@59956
    38
    Syn, Typ (presently) should be accepted in I_Model.add_single (instead Error')
walther@59956
    39
    Sup      (presently) should be accepted in I_Model.add_single (instead Error')
wneuper@59316
    40
         _could_ be w.r.t current vat (and then _is_ related to vat
walther@59956
    41
    Mis should _not_ be  made Inc ((presently, by I_Model.add_single & match_itms)
walther@59943
    42
- dsc in I_Model.feedback is timeconsuming -- keep id for respective queries ?
wneuper@59316
    43
- order of items in ppc should be stable w.r.t order of itms
wneuper@59316
    44
wneuper@59316
    45
- stepwise input of itms --- match_itms (in one go) ..not coordinated
wneuper@59316
    46
  - unify code
wneuper@59316
    47
  - match_itms / match_itms_oris ..2 versions ?!
wneuper@59316
    48
    (fast, for refine / slow, for modeling)
wneuper@59316
    49
wneuper@59316
    50
- clarify: efficiency <--> simplicity !!!
walther@59943
    51
  ?: shift dsc I_Model.feedback -> itm | discard int in ori,itm | take int instead dsc 
wneuper@59316
    52
    | take int for perserving order of item ppc in itms 
wneuper@59316
    53
    | make all(!?) handling of itms stable against reordering(?)
wneuper@59316
    54
    | field in ori ?? (not from fmz!) -- meant for efficiency (not doc!???)
wneuper@59316
    55
      -"- "#undef" ?= not touched ?= (id,..)
wneuper@59316
    56
-----------------------------------------------------------------
wneuper@59316
    57
27.3.02:
wneuper@59316
    58
def: type pbt = (field, (dsc, pid)) *** design considerations ***
wneuper@59316
    59
wneuper@59316
    60
(1) fmz + pbt -> oris
wneuper@59316
    61
(2) input + oris -> itm
wneuper@59316
    62
(3) match_itms      : schnell(?) f"ur refine
wneuper@59316
    63
    match_itms_oris : r"uckmeldung f"ur item ppc
wneuper@59316
    64
wneuper@59316
    65
(1.1) in oris fehlt daher pid: (i,v,f,d,ts,pid)
wneuper@59316
    66
---------- ^^^^^ --- dh. pbt meist als argument zu viel !!!
wneuper@59316
    67
wneuper@59316
    68
(3.1) abwarten, wie das matchen mehr unterschiedlicher pbt's sich macht;
wneuper@59316
    69
      wenn Problem pbt v"ollig neue, dann w"are eigentlich n"otig ????:
wneuper@59316
    70
      (a) (_,_,d1,ts,_):ori + pbt -> (i,vt,d2,ts,pid)  dh.vt neu  ????
wneuper@59316
    71
      (b) 
wneuper@59316
    72
==========================================================================*)
wneuper@59316
    73
wneuper@59316
    74
fun mkval _(*dsc*) [] = error "mkval called with []"
wneuper@59316
    75
  | mkval _ [t] = t
wneuper@59389
    76
  | mkval _ ts = TermC.list2isalist ((type_of o hd) ts) ts;
walther@59861
    77
fun mkval' x = mkval TermC.empty x;
wneuper@59316
    78
wneuper@59316
    79
(* for _output_ of the items of a Model *)
wneuper@59316
    80
datatype item = 
walther@59865
    81
    Correct of TermC.as_string (* labels a correct formula (type cterm') *)
wneuper@59316
    82
  | SyntaxE of string (**)
wneuper@59316
    83
  | TypeE   of string (**)
walther@59865
    84
  | False   of TermC.as_string (* WN050618 notexistent in itm_: only used in Where *)
walther@59865
    85
  | Incompl of TermC.as_string (**)
wneuper@59316
    86
  | Superfl of string (**)
walther@59865
    87
  | Missing of TermC.as_string;
walther@59937
    88
fun item2str (Correct  s) = "Correct " ^ s
walther@59937
    89
  | item2str (SyntaxE  s) = "SyntaxE " ^ s
walther@59937
    90
  | item2str (TypeE    s) = "TypeE " ^ s
walther@59937
    91
  | item2str (False    s) = "False " ^ s
walther@59937
    92
  | item2str (Incompl  s) = "Incompl " ^ s
walther@59937
    93
  | item2str (Superfl  s) = "Superfl " ^ s
walther@59937
    94
  | item2str (Missing  s) = "Missing " ^ s;
walther@59937
    95
wneuper@59316
    96
type 'a ppc = 
wneuper@59316
    97
  {Given : 'a list, Where: 'a list, Find  : 'a list, With : 'a list, Relate: 'a list};
wneuper@59316
    98
fun ppc2str {Given = Given, Where = Where, Find = Find, With = With, Relate = Relate}=
wneuper@59316
    99
  "{Given =" ^ strs2str Given ^ ",Where=" ^ strs2str Where ^ ",Find  =" ^ strs2str Find ^
wneuper@59316
   100
  ",With =" ^ strs2str With ^ ",Relate=" ^ strs2str Relate ^ "}";
wneuper@59316
   101
wneuper@59316
   102
fun itemppc2str ({Given=Given,Where=Where,
wneuper@59316
   103
		 Find=Find,With=With,Relate=Relate}:item ppc)=
wneuper@59316
   104
    ("{Given =" ^ ((strs2str' o (map item2str))	 Given ) ^
wneuper@59316
   105
     ",Where=" ^ ((strs2str' o (map item2str))	 Where) ^
wneuper@59316
   106
     ",Find  =" ^ ((strs2str' o (map item2str))	 Find  ) ^
wneuper@59316
   107
     ",With =" ^ ((strs2str' o (map item2str))	 With ) ^
wneuper@59316
   108
     ",Relate=" ^ ((strs2str' o (map item2str))	 Relate) ^ "}");
wneuper@59316
   109
wneuper@59316
   110
val empty_ppc = {Given = [], Where= [], Find  = [], With = [], Relate= []};
wneuper@59316
   111
walther@59938
   112
(**)end(**);