src/Tools/isac/Knowledge/Simplify.thy
author Walther Neuper <neuper@ist.tugraz.at>
Tue, 28 Sep 2010 09:06:56 +0200
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 37972 66fc615a1e89
child 38083 a1d13f3de312
permissions -rw-r--r--
tuned error and writeln

# raise error --> error
# writeln in atomtyp, atomty, atomt and xmlsrc
     1 (* simplification of terms
     2    author: Walther Neuper 050912
     3    (c) due to copyright terms
     4 *)
     5 
     6 theory Simplify imports Atools begin
     7 
     8 consts
     9 
    10   (*descriptions in the related problem*)
    11   TERM        :: "real => una"
    12   normalform  :: "real => una"
    13 
    14   (*the CAS-command*)
    15   Simplify    :: "real => real"  (*"Simplify (1+2a+3+4a)*)
    16   Vereinfache :: "real => real"  (*"Vereinfache (1+2a+3+4a)*)
    17 
    18   (*Script-name*)
    19   SimplifyScript      :: "[real,  real] => real"
    20                   ("((Script SimplifyScript (_ =))// (_))" 9)
    21 
    22 ML {*
    23 val thy = @{theory};
    24 
    25 (** problems **)
    26 store_pbt
    27  (prep_pbt thy "pbl_simp" [] e_pblID
    28  (["simplification"],
    29   [("#Given" ,["TERM t_t"]),
    30    ("#Find"  ,["normalform n_n"])
    31   ],
    32   append_rls "e_rls" e_rls [(*for preds in where_*)], 
    33   SOME "Simplify t_t", 
    34   []));
    35 
    36 store_pbt
    37  (prep_pbt thy "pbl_vereinfache" [] e_pblID
    38  (["vereinfachen"],
    39   [("#Given" ,["TERM t_t"]),
    40    ("#Find"  ,["normalform n_n"])
    41   ],
    42   append_rls "e_rls" e_rls [(*for preds in where_*)], 
    43   SOME "Vereinfache t_t", 
    44   []));
    45 
    46 (** methods **)
    47 
    48 store_met
    49     (prep_met thy "met_tsimp" [] e_metID
    50 	      (["simplification"],
    51 	       [("#Given" ,["TERM t_t"]),
    52 		("#Find"  ,["normalform n_n"])
    53 		],
    54 	       {rew_ord'="tless_true",
    55 		rls'= e_rls, 
    56 		calc = [], 
    57 		srls = e_rls, 
    58 		prls=e_rls,
    59 		crls = e_rls, nrls = e_rls},
    60 	       "empty_script"
    61 	       ));
    62 
    63 (** CAS-command **)
    64 
    65 (*.function for handling the cas-input "Simplify (2*a + 3*a)":
    66    make a model which is already in ptree-internal format.*)
    67 (* val (h,argl) = strip_comb (str2term "Simplify (2*a + 3*a)");
    68    val (h,argl) = strip_comb ((term_of o the o (parse (theory "Simplify"))) 
    69 				  "Simplify (2*a + 3*a)");
    70    *)
    71 fun argl2dtss t =
    72     [((term_of o the o (parse thy)) "TERM", t),
    73      ((term_of o the o (parse thy)) "normalform", 
    74       [(term_of o the o (parse thy)) "N"])
    75      ]
    76   | argl2dtss _ = error "Simplify.ML: wrong argument for argl2dtss";
    77 
    78 castab := 
    79 overwritel (!castab, 
    80 	    [((term_of o the o (parse thy)) "Simplify",  
    81 	      (("Isac", ["simplification"], ["no_met"]), 
    82 	       argl2dtss)),
    83 	     ((term_of o the o (parse thy)) "Vereinfache",  
    84 	      (("Isac", ["vereinfachen"], ["no_met"]), 
    85 	       argl2dtss))
    86 	     ]);
    87 *}
    88 
    89 end