src/Tools/isac/BaseDefinitions/model-pattern.sml
author Walther Neuper <walther.neuper@jku.at>
Sat, 16 May 2020 14:04:35 +0200
changeset 59987 73225ca9e0aa
parent 59957 d63363c45af6
child 59998 5dd825c9e2d5
permissions -rw-r--r--
shift code (O_Model, M_Match, Model_Pattern)
     1 (* Title:  BaseDefinitions/model-pattern.sml
     2    Author: Walther Neuper
     3    (c) due to copyright terms
     4 
     5 A pattern to be combined with a formalisation (Formalise.T) yielding an O_Model.T..
     6 *)
     7 signature MODEL_PATTERN =
     8 sig
     9   type T
    10   type single
    11   val to_string: single list -> string
    12   type m_field = string
    13   type descriptor = term
    14   val variables: T -> term list
    15 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
    16   val to_string': T -> string
    17 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
    18   (*NONE*)                                                                      
    19 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
    20 end
    21 
    22 (**)
    23 structure Model_Pattern(**): MODEL_PATTERN(**) =
    24 struct
    25 (**)
    26 
    27 (* the pattern for an item of a problems model or a methods guard *)
    28 type m_field = string;
    29 type descriptor = term;
    30 type single =
    31   (m_field *      (* field Given, Find, Relate *)
    32 	  (descriptor * (* for snd term              *)
    33 	     term))     (* id | arbitrary term       *);
    34 type T = single list;
    35 
    36 fun pat2str (field, (dsc, id)) = pair2str (field, pair2str (UnparseC.term dsc, UnparseC.term id));
    37 fun to_string pats = (strs2str o (map pat2str)) pats;
    38 fun pat2str' (field, (dsc, id)) = pair2str (field, pair2str (UnparseC.term dsc, UnparseC.term id)) ^ "\n";
    39 fun to_string' pats = (strs2str o (map pat2str')) pats;
    40 
    41 (* get the variables out of a pbl_; FIXME.WN.0311: is_copy_named ...obscure!!! *)
    42 fun variables pbl_ = 
    43   let
    44     fun var_of_pbl_ (_, (_, t)) = t: term
    45   in ((map var_of_pbl_)(* o (filter_out is_copy_named)*)) pbl_ end
    46 
    47 (**)end(**)