src/Tools/isac/Knowledge/DiophantEq.thy
author Walther Neuper <wneuper@ist.tugraz.at>
Wed, 29 May 2019 10:36:16 +0200
changeset 59545 4035ec339062
parent 59505 a1f223658994
child 59551 6ea6d9c377a0
permissions -rw-r--r--
[-Test_Isac] funpack: switch from Script to partial_function
     1 (* Title:  Knowledge/DiophantEq.thy
     2    Author: Mathias Lehnfeld 2011
     3    (c) due to copyright terms
     4 12345678901234567890123456789012345678901234567890123456789012345678901234567890
     5         10        20        30        40        50        60        70        80
     6 *)
     7 
     8 theory DiophantEq imports Base_Tools Equation Test
     9 begin
    10 
    11 consts
    12   Diophant'_equation :: "[bool, int, bool ] 
    13                                        => bool "
    14                     ("((Script Diophant'_equation (_ _ =))//(_))" 9)
    15 
    16 axiomatization where
    17   int_isolate_add: "(bdv + a = b) = (bdv = b + (-1)*(a::int))"
    18 
    19 ML \<open>val thy = @{theory}\<close>
    20 
    21 text \<open>problemclass for the usecase\<close>
    22 setup \<open>KEStore_Elems.add_pbts
    23   [(Specify.prep_pbt thy "pbl_equ_dio" [] Celem.e_pblID
    24       (["diophantine","equation"],
    25         [("#Given" ,["boolTestGiven e_e","intTestGiven (v_v::int)"]),
    26           (*                                      TODO: drop ^^^^^*)
    27           ("#Where" ,[]),
    28           ("#Find"  ,["boolTestFind s_s"])],
    29         Rule.e_rls, SOME "solve (e_e::bool, v_v::int)", [["LinEq","solve_lineq_equation"]]))]\<close>
    30 
    31 text \<open>method solving the usecase\<close>
    32 
    33 partial_function (tailrec) diophant_equation :: "bool => int => bool"
    34   where
    35 "diophant_equation e_e v_v =
    36   (Repeat
    37       ((Try (Rewrite_Inst [(''bdv'', v_v)] ''int_isolate_add'' False)) @@
    38        (Try (Calculate ''PLUS'')) @@
    39        (Try (Calculate ''TIMES''))) e_e)"
    40 setup \<open>KEStore_Elems.add_mets
    41     [Specify.prep_met thy "met_test_diophant" [] Celem.e_metID
    42       (["Test","solve_diophant"],
    43         [("#Given" ,["boolTestGiven e_e","intTestGiven (v_v::int)"]),
    44           (*                                      TODO: drop ^^^^^*)
    45           ("#Where" ,[]),
    46           ("#Find"  ,["boolTestFind s_s"])],
    47         {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls, prls = Rule.e_rls, calc = [],
    48           crls = tval_rls, errpats = [], nrls = Test_simplify},
    49         @{thm diophant_equation.simps}
    50 	    (*"Script Diophant_equation (e_e::bool) (v_v::int)=                  " ^
    51           "(Repeat                                                          " ^
    52           "    ((Try (Rewrite_Inst [(''bdv'',v_v::int)] ''int_isolate_add'' False)) @@" ^
    53           "     (Try (Calculate ''PLUS'')) @@  " ^
    54           "     (Try (Calculate ''TIMES''))) e_e::bool)"*))]
    55 \<close>
    56 
    57 end