src/Tools/isac/Knowledge/Equation.thy
author Walther Neuper <neuper@ist.tugraz.at>
Sun, 22 Sep 2013 18:09:05 +0200
changeset 52125 6f1d3415dc68
parent 42425 da7fbace995b
child 52155 e4ddf21390fd
permissions -rw-r--r--
add functions accessing Theory_Data in parallel to those accessing "ruleset' = Unsynchronized.ref"

updates have been done incrementally following Build_Isac.thy:
# ./bin/isabelle jedit -l HOL src/Tools/isac/ProgLang/ProgLang.thy &
# ./bin/isabelle jedit -l HOL src/Tools/isac/Interpret/Interpret.thy &
# ./bin/isabelle jedit -l HOL src/Tools/isac/xmlsrc/xmlsrc.thy &
# ./bin/isabelle jedit -l HOL src/Tools/isac/Frontend/Frontend.thy &

Note, that the original access function "fun assoc_rls" is still outcommented;
so the old and new functionality is established in parallel.
     1 (* equations and functions; functions NOT as lambda-terms
     2    author: Walther Neuper 2005, 2006
     3    (c) due to copyright terms
     4 *)
     5 
     6 theory Equation imports Atools begin
     7 
     8 text {* univariate equations over terms :
     9   In 2003 Richard Lang prototyped ISAC's equation solver while also alpha-testing
    10   the Lucas-Interpreter's Subproblem mechanism.
    11   This prototype suffers from the drop-out of Matthias Goldgruber for a year,
    12   who had started to work on simplification in parallel. So this implementation
    13   replaced simplifiers by many specific theorems for specific terms in specific
    14   phases of equation solving; these specific solutions wait for generalisation
    15   in future improvements of ISAC's equation solver.
    16 *}
    17 
    18 consts
    19 
    20   (*descriptions in the related problems TODOshift here from Descriptions.thy*)
    21   substitution      :: "bool => una"
    22 
    23   (*the CAS-commands*)
    24   solve             :: "[bool * 'a] => bool list" (* solve (x+1=2, x) *)
    25   solveTest         :: "[bool * 'a] => bool list" (* for test collection *)
    26   
    27   (*Script-names*)
    28   Function2Equality :: "[bool, bool,       bool] 
    29 					 => bool"
    30                   ("((Script Function2Equality (_ _ =))// (_))" 9)
    31 
    32 text {* defines equation and univariate-equation
    33         created by: rlang 
    34               date: 02.09
    35         changed by: rlang
    36         last change by: rlang
    37                   date: 02.11.29
    38         (c) by Richard Lang, 2003 *}
    39 
    40 ML {*
    41 val thy = @{theory};
    42 val ctxt = thy2ctxt thy;
    43 
    44 val univariate_equation_prls = 
    45     append_rls "univariate_equation_prls" e_rls 
    46 	       [Calc ("Tools.matches",eval_matches "")];
    47 ruleset' := 
    48 overwritelthy @{theory} (!ruleset',
    49 		   [("univariate_equation_prls",
    50 		     prep_rls univariate_equation_prls)]);
    51 *}
    52 setup {* KEStore_Elems.add_rlss [("univariate_equation_prls",
    53   (Context.theory_name @{theory}, prep_rls univariate_equation_prls))] *}
    54 ML {*
    55 
    56 
    57 store_pbt 
    58  (prep_pbt thy "pbl_equ" [] e_pblID
    59  (["equation"],
    60   [("#Given" ,["equality e_e","solveFor v_v"]),
    61    ("#Where" ,["matches (?a = ?b) e_e"]),
    62    ("#Find"  ,["solutions v_v'i'"])
    63   ],
    64   append_rls "equation_prls" e_rls 
    65 	     [Calc ("Tools.matches",eval_matches "")],
    66   SOME "solve (e_e::bool, v_v)",
    67   []));
    68 
    69 store_pbt
    70  (prep_pbt thy "pbl_equ_univ" [] e_pblID
    71  (["univariate","equation"],
    72   [("#Given" ,["equality e_e","solveFor v_v"]),
    73    ("#Where" ,["matches (?a = ?b) e_e"]),
    74    ("#Find"  ,["solutions v_v'i'"])
    75   ],
    76   univariate_equation_prls,SOME "solve (e_e::bool, v_v)",[]));
    77 
    78 
    79 (*.function for handling the cas-input "solve (x+1=2, x)":
    80    make a model which is already in ptree-internal format.*)
    81 (* val (h,argl) = strip_comb (str2term "solve (x+1=2, x)");
    82    val (h,argl) = strip_comb ((term_of o the o (parse thy)) 
    83 				  "solveTest (x+1=2, x)");
    84    *)
    85 fun argl2dtss [Const ("Product_Type.Pair", _) $ eq $ bdv] =
    86     [((the o (parseNEW ctxt)) "equality", [eq]),
    87      ((the o (parseNEW ctxt)) "solveFor", [bdv]),
    88      ((the o (parseNEW ctxt)) "solutions", 
    89       [(the o (parseNEW ctxt)) "L"])
    90      ]
    91   | argl2dtss _ = error "Equation.ML: wrong argument for argl2dtss";
    92 
    93 castab := 
    94 overwritel (!castab, 
    95 	    [((term_of o the o (parse thy)) "solveTest", 
    96 	      (("Test", ["univariate","equation","test"], ["no_met"]), 
    97 	       argl2dtss)),
    98 	     ((term_of o the o (parse thy)) "solve",  
    99 	      (("Isac", ["univariate","equation"], ["no_met"]), 
   100 	       argl2dtss))
   101 	     ]);
   102 
   103 
   104 
   105 store_met
   106     (prep_met thy "met_equ" [] e_metID
   107 	      (["Equation"],
   108 	       [],
   109 	       {rew_ord'="tless_true", rls'=Erls, calc = [], 
   110 		srls = e_rls, 
   111 		prls=e_rls,
   112 	     crls = Atools_erls, errpats = [], nrls = e_rls},
   113 "empty_script"
   114 ));
   115 *}
   116 
   117 end