src/Tools/isac/ProgLang/Script.thy
author Walther Neuper <wneuper@ist.tugraz.at>
Fri, 14 Dec 2018 18:46:04 +0100
changeset 59484 c5f3da9e3645
parent 59477 5cf2512966c6
child 59485 aaba46d31a6e
permissions -rw-r--r--
[-Test_Isac] funpack: prep. replace ID::type by char string
     1 (* Title:  tactics, tacticals etc. for scripts
     2    Author: Walther Neuper 000224
     3    (c) due to copyright terms
     4  *)
     5 
     6 theory Script imports Tools begin
     7 
     8 typedecl
     9   ID	(* identifiers for thy, ruleset,... *)
    10 
    11 typedecl
    12   arg	(* argument of subproblem           *)
    13 
    14 consts
    15 
    16 (*types of subproblems' arguments*)
    17   REAL        :: "real => arg"
    18   REAL_LIST   :: "(real list) => arg"
    19   REAL_SET    :: "(real set) => arg"
    20   BOOL        :: "bool => arg"
    21   BOOL_LIST   :: "(bool list) => arg"
    22   REAL_REAL   :: "(real => real) => arg"
    23 
    24 (*tactics*)
    25   Rewrite      :: "[ID, bool, 'a] => 'a"
    26   Rewrite'_Inst:: "[(real * real) list, ID, bool, 'a] => 'a"
    27 			             ("(Rewrite'_Inst (_ _ _))" 11)
    28                                      (*without last argument ^^ for @@*)
    29   Rewrite'_Set :: "[char list, bool, 'a] => 'a" ("(Rewrite'_Set (_ _))" 11)
    30   Rewrite'_Set'_Inst
    31                :: "[(real * real) list, ID, bool, 'a] => 'a"
    32 		                     ("(Rewrite'_Set'_Inst (_ _ _))" 11)
    33                                      (*without last argument ^^ for @@*)
    34   Calculate    :: "[ID, 'a] => 'a" (*WN100816 PLUS, TIMES, POWER miss.in scr*)
    35   Calculate1   :: "[ID, 'a] => 'a" (*FIXXXME: unknown to script-interpreter*)
    36 
    37   (* WN0509 substitution now is rewriting by a list of terms (of type bool)
    38   Substitute   :: "[(real * real) list, 'a] => 'a"*)
    39   Substitute   :: "[bool list, 'a] => 'a"
    40 
    41   Map          :: "['a => 'b, 'a list] => 'b list"
    42   Check'_elementwise ::
    43 		  "['a list, 'b set] => 'a list"
    44                                      ("Check'_elementwise (_ _)" 11)
    45   Take         :: "'a => 'a"         (*for non-var args as long as no 'o'*)
    46   SubProblem   :: "[char list * char list list * char list list, arg list] => 'a"
    47 
    48   Or'_to'_List :: "bool => 'a list"  ("Or'_to'_List (_)" 11)
    49   (*=========== record these ^^^ in 'tacs' in Script.ML =========*)
    50 
    51   Assumptions  :: bool
    52   Problem      :: "[ID * ID list] => 'a"
    53 
    54 (*special formulas for frontend 'CAS format'*)
    55   Subproblem   :: "(ID * ID list) => 'a" 
    56 
    57 (*script-expressions (tacticals)*)
    58   Seq      :: "['a => 'a, 'a => 'a, 'a] => 'a" (infixr "@@" 10) (*@ used*)
    59   Try      :: "['a => 'a, 'a] => 'a"
    60   Repeat   :: "['a => 'a, 'a] => 'a" 
    61   Or       :: "['a => 'a, 'a => 'a, 'a] => 'a" (infixr "Or" 10)
    62   While    :: "[bool, 'a => 'a, 'a] => 'a"     ("((While (_) Do)//(_))" 9)
    63 (*WN100723 because of "Error in syntax translation" below...
    64         (*'b => bool doesn't work with "contains_root _"*)
    65   Letpar   :: "['a, 'a => 'b] => 'b"
    66   (*--- defined in Isabelle/scr/HOL/HOL.thy:
    67   Let      :: "['a, 'a => 'b] => 'b"
    68   "_Let"   :: "[letbinds, 'a] => 'a"       ("(let (_)/ in (_))" 10)
    69   If       :: "[bool, 'a, 'a] => 'a"       ("(if (_)/ then (_)/ else (_))" 10)
    70   %x. P x  .. lambda is defined in Isabelles meta logic
    71   --- *)
    72 *)
    73   failtac :: 'a
    74   idletac :: 'a
    75   (*... + RECORD IN 'screxpr' in Script.ML *)
    76 
    77 (*for scripts generated automatically from rls*)
    78   Stepwise      :: "['z,     'z] => 'z" ("((Script Stepwise (_   =))// (_))" 9)
    79   Stepwise'_inst:: "['z,real,'z] => 'z" 
    80 	("((Script Stepwise'_inst (_ _ =))// (_))" 9)
    81 
    82 
    83 (*SHIFT -> resp.thys ----vvv---------------------------------------------*)
    84 (*script-names: initial capital letter,
    85 		type of last arg (=script-body) == result-type !
    86   Xxxx       :: script ids, duplicate result-type 'r in last argument:
    87              "['a, ... , \
    88 	       \         'r] => 'r
    89 *)
    90 			    
    91 (*make'_solution'_set :: "bool => bool list" 
    92 			("(make'_solution'_set (_))" 11)    
    93 					   
    94   max'_on'_interval
    95              :: "[ID * (ID list) * ID, bool,real,real set] => real"
    96                ("(max'_on'_interval (_)/ (_ _ _))" 9)
    97   find'_vals
    98              :: "[ID * (ID list) * ID,
    99 		  real,real,real,real,bool list] => bool list"
   100                ("(find'_vals (_)/ (_ _ _ _ _))" 9)
   101 
   102   make'_fun  :: "[ID * (ID list) * ID, real,real,bool list] => bool"
   103                ("(make'_fun (_)/ (_ _ _))" 9)
   104 
   105   solve'_univar
   106              :: "[ID * (ID list) * ID, bool,real] => bool list"
   107                ("(solve'_univar (_)/ (_ _ ))" 9)
   108   solve'_univar'_err
   109              :: "[ID * (ID list) * ID, bool,real,bool] => bool list"
   110                ("(solve'_univar (_)/ (_ _ _))" 9)
   111 ----------*)
   112 
   113   Testeq     :: "[bool, bool] => bool"
   114                ("((Script Testeq (_ =))// (_))" 9)
   115   
   116   Testeq2    :: "[bool, bool list] => bool list"
   117                ("((Script Testeq2 (_ =))// (_))" 9)
   118   
   119   Testterm   :: "[real, real] => real"
   120                ("((Script Testterm (_ =))// (_))" 9)
   121   
   122   Testchk    :: "[bool, real, real list] => real list"
   123                ("((Script Testchk (_ _ =))// (_))" 9)
   124   (*... + RECORD IN 'subpbls' in Script.ML *)
   125 (*SHIFT -> resp.thys ----^^^----------------------------*)
   126 
   127 (*Makarius 10.03
   128 syntax
   129 
   130   "_Letpar"     :: "[letbinds, 'a] => 'a"      ("(letpar (_)/ in (_))" 10)
   131 
   132 translations
   133 
   134   "_Letpar (_binds b bs) e"  == "_Letpar b (_Letpar bs e)"
   135   "letpar x = a in e"        == "Letpar a (%x. e)"
   136 *** Error in syntax translation rule: rhs contains extra variables
   137 *** ("_Letpar" ("_bind" x a) e)  ->  (Letpar a ("_abs" x e))
   138 *** At command "translations" (line 140 of "/usr/local/isabisac/src/Pure/isac/Scripts/Script").
   139 *)
   140 end