src/Tools/isac/Knowledge/Equation.thy
author Walther Neuper <neuper@ist.tugraz.at>
Wed, 16 May 2012 15:47:22 +0200
changeset 42425 da7fbace995b
parent 42398 04d3f0133827
child 52125 6f1d3415dc68
permissions -rw-r--r--
extended "type met" with errpats
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@37950
    51
neuper@37950
    52
neuper@37950
    53
store_pbt 
neuper@37972
    54
 (prep_pbt thy "pbl_equ" [] e_pblID
neuper@37950
    55
 (["equation"],
neuper@37981
    56
  [("#Given" ,["equality e_e","solveFor v_v"]),
neuper@37981
    57
   ("#Where" ,["matches (?a = ?b) e_e"]),
neuper@38012
    58
   ("#Find"  ,["solutions v_v'i'"])
neuper@37950
    59
  ],
neuper@37950
    60
  append_rls "equation_prls" e_rls 
neuper@37950
    61
	     [Calc ("Tools.matches",eval_matches "")],
neuper@37981
    62
  SOME "solve (e_e::bool, v_v)",
neuper@37950
    63
  []));
neuper@37950
    64
neuper@37950
    65
store_pbt
neuper@37972
    66
 (prep_pbt thy "pbl_equ_univ" [] e_pblID
neuper@37950
    67
 (["univariate","equation"],
neuper@37981
    68
  [("#Given" ,["equality e_e","solveFor v_v"]),
neuper@37981
    69
   ("#Where" ,["matches (?a = ?b) e_e"]),
neuper@38012
    70
   ("#Find"  ,["solutions v_v'i'"])
neuper@37950
    71
  ],
neuper@37981
    72
  univariate_equation_prls,SOME "solve (e_e::bool, v_v)",[]));
neuper@37950
    73
neuper@37950
    74
neuper@37950
    75
(*.function for handling the cas-input "solve (x+1=2, x)":
neuper@37950
    76
   make a model which is already in ptree-internal format.*)
neuper@37950
    77
(* val (h,argl) = strip_comb (str2term "solve (x+1=2, x)");
neuper@37950
    78
   val (h,argl) = strip_comb ((term_of o the o (parse thy)) 
neuper@37950
    79
				  "solveTest (x+1=2, x)");
neuper@37950
    80
   *)
neuper@41972
    81
fun argl2dtss [Const ("Product_Type.Pair", _) $ eq $ bdv] =
bonzai@41952
    82
    [((the o (parseNEW ctxt)) "equality", [eq]),
bonzai@41952
    83
     ((the o (parseNEW ctxt)) "solveFor", [bdv]),
bonzai@41952
    84
     ((the o (parseNEW ctxt)) "solutions", 
bonzai@41952
    85
      [(the o (parseNEW ctxt)) "L"])
neuper@37950
    86
     ]
neuper@38031
    87
  | argl2dtss _ = error "Equation.ML: wrong argument for argl2dtss";
neuper@37950
    88
neuper@37950
    89
castab := 
neuper@37950
    90
overwritel (!castab, 
neuper@37950
    91
	    [((term_of o the o (parse thy)) "solveTest", 
neuper@37991
    92
	      (("Test", ["univariate","equation","test"], ["no_met"]), 
neuper@37950
    93
	       argl2dtss)),
neuper@37950
    94
	     ((term_of o the o (parse thy)) "solve",  
neuper@37991
    95
	      (("Isac", ["univariate","equation"], ["no_met"]), 
neuper@37950
    96
	       argl2dtss))
neuper@37950
    97
	     ]);
neuper@37950
    98
neuper@37950
    99
neuper@37950
   100
neuper@37950
   101
store_met
neuper@37972
   102
    (prep_met thy "met_equ" [] e_metID
neuper@37950
   103
	      (["Equation"],
neuper@37950
   104
	       [],
neuper@37950
   105
	       {rew_ord'="tless_true", rls'=Erls, calc = [], 
neuper@37950
   106
		srls = e_rls, 
neuper@37950
   107
		prls=e_rls,
neuper@42425
   108
	     crls = Atools_erls, errpats = [], nrls = e_rls},
neuper@37950
   109
"empty_script"
neuper@37950
   110
));
neuper@37950
   111
*}
neuper@37950
   112
neuper@37906
   113
end