3 theory example_3 imports Isac
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}*}
11 (*----START----Example Function Decleration from Rationals.thy----*)
13 text{*Define Method name and input, output types*}
16 get_denominator :: "real => real"
18 text{*Always add a comment with the method name and where it can be found.*}
23 * ("Rational.get_denominator", eval_get_denominator ""))
25 fun eval_get_denominator (thmid:string) _
26 (t as Const ("Rational.get_denominator", _) $
27 (Const ("Rings.inverse_class.divide", _) $num
29 SOME (mk_thmid thmid ""
31 (Syntax.string_of_term (thy2ctxt thy)) denom) "",
32 Trueprop $ (mk_equality (t, denom)))
33 | eval_get_denominator _ _ _ _ = NONE;
35 (*----END----Example Function Decleration from Rationals.thy----*)
37 text{*Apply the Method to an expression.*}
40 val input = term_of (the (parse thy "get_denominator ((a + b) / c)"));
41 val SOME (_, output) = eval_get_denominator "" 0 input thy;