test/Tools/isac/ADDTESTS/course/CADGME/example_3.thy
author Jan Rocnik <jan.rocnik@student.tugraz.at>
Fri, 31 Aug 2012 19:19:07 +0200
changeset 42461 94c9a0735e2f
parent 42444 2768aa42a383
child 48789 498ed5bb1004
permissions -rwxr-xr-x
cadgme finals - outstanding commit
     1 
     2 
     3 theory example_3 imports Isac
     4 begin
     5 
     6 section{*Function Decleration*}
     7 text{*Following code should only represent an example and was taken as a
     8       snipset from Rationals.thy located in 
     9       \texttt{/src/Tools/isac/Knowledge}*}
    10 
    11 (*----START----Example Function Decleration from Rationals.thy----*)
    12 
    13 text{*Define Method name and input, output types*}
    14 
    15 consts
    16   get_denominator :: "real => real"
    17 
    18 text{*Always add a comment with the method name and where it can be found.*}
    19   
    20 ML {*
    21 (*
    22  *("get_denominator",
    23  *  ("Rational.get_denominator", eval_get_denominator ""))
    24  *)
    25 fun eval_get_denominator (thmid:string) _ 
    26 		      (t as Const ("Rational.get_denominator", _) $
    27               (Const ("Rings.inverse_class.divide", _) $num 
    28                 $denom)) thy = 
    29         SOME (mk_thmid thmid "" 
    30             (Print_Mode.setmp [] 
    31               (Syntax.string_of_term (thy2ctxt thy)) denom) "", 
    32 	          Trueprop $ (mk_equality (t, denom)))
    33   | eval_get_denominator _ _ _ _ = NONE; 
    34 *}
    35 (*----END----Example Function Decleration from Rationals.thy----*)
    36 
    37 text{*Apply the Method to an expression.*}
    38 
    39 ML{*
    40   val input = term_of (the (parse thy "get_denominator ((a + b) / c)"));
    41   val SOME (_, output) = eval_get_denominator "" 0 input thy;
    42 *}
    43 
    44 ML{*
    45  term2str output;
    46 *}
    47 
    48 end