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