FAQs of TP-PL programmers

This collection started during update of ISAC from Isabelle 2002 to 2010. See also test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy for Jan Rocnik's experiences as the first TP-PL programmer.

me Apply_Method => ("Empty_Tac", Empty_Tac)
While checking a calculation by '= me' you get 'nxt = ("Apply_Method"...' and with the subsequent '= me' you get 'nxt = ("Empty_Tac", Empty_Tac)'. In order to find the reason you check further
 * 1) Does the specification phase finish correctly: see 'tests/../biegelinie.sml --- Bsp 7.27 me ---'
 * 2) Do the elements in the model match the program's arguments ? There are tests, but they do not cover all error cases.
 * 3) Step into the code

Design of sub-problems
A program can call a sub-program using the keyword "SubProblem"; the arguments are a triple and a list. The triple comprises a theory (modified by an apostrophe for typing reasons), a problem identifier and a method identifier. The latter can be "[no_met]"; in this case the Lucas-Interpreter refines the problem and takes the method of the refined problem; see "problem hierarchy" > equation > univariate for an example.

Note that there should be no space between the elements of the problem identifier and the method identifier (coding convention for "grep" through the sources).

The list is the argument list of the sub-program; the type constraints of the arguments still look unusual. Here is an example in the method "["RatEq","solve_rat_equation"]": is_copy_named_generating_idstr "Script Solve_rat_equation (e_e::bool) (v_v::real) =      " ^ "(let e_e =                                               " ^   " ((Repeat(Try (Rewrite_Set RatEq_simplify True))) @@      " ^ " (Repeat(Try (Rewrite_Set norm_Rational True))) @@       " ^ "  (Repeat(Try (Rewrite_Set common_nominator_p True))) @@ " ^ "  (Repeat(Try (Rewrite_Set RatEq_eliminate True)))) e_e; " ^   "   (L_L::bool list) =                                     " ^   "     (SubProblem (RatEq', [univariate,equation], [no_met])" ^ "    [BOOL e_e, REAL v_v])                                " ^   "in Check_elementwise L_L {(v_v::real). Assumptions})"

A problem is defined by a specification pattern, which gives a pattern of the input values, the pre-condition on the input, the output values and the post-condition relating input and output. For instance, the problem "univariate equation" is defined in Equation.thy by

store_pbt (prep_pbt thy "pbl_equ" [] e_pblID     (["equation"], [("#Given" ,["equality e_e","solveFor v_v"]), ("#Where" ,["matches (?a = ?b) e_e"]), ("#Find" ,["solutions v_v'i'"])], ("#Relate",["simplify (substitute [v_v = v_v'i'"] (lhs e_e)) = (substitute [v_v = v_v'i'"] (rhs e_e)))"], (*to be generalised*) append_rls "equation_prls" e_rls [Calc ("Tools.matches",eval_matches "")], SOME "solve (e_e::bool, v_v)", []));

Copy-named output
Interactive specification allows to determine the name to the output in general; with equations this is not the case: the interesting part of equations are the bound variables which stay with the same identifier until the solution is found. In this case we have a "copy-named" output and the output needs not to be contained in the argument list (as shown in the example above). The identifier of "copy-named" output must end with "*'.'"; for details see the functions

fun is_copy_named_idstr is_copy_named_generating_idstr

The Lucas-Interpreter matches actual arguments (in the program) with the formal arguments in the specification pattern, the number of actual arguments and formal arguments must be the same. In the case of "copy-named" output the "*'.'" mark the special case where the number of arguments might differ. Violations cause cryptic error messages like

actual arg(s) missing for '["(#Find, (decomposedFunction, p_p))"]' i.e. should be 'copy-named' by "*''"

Named output
TODO

There are problems which handle identifiers in the output specifically. For instance, one wants to change the left-hand-side of an equation; so, in the case of integration one can get

$$ f(x) = \int{1+x}\;dx $$ $$ F(x) = c + x + \frac{x^2}{2} $$

TODO

(SubProblem (Biegelinie',[named,integrate,function], [diff,integration,named])                                [REAL (rhs q___q), REAL v_v, REAL_REAL Q]);

CAS-commands
Isac allows input like in CAS systems: one can request a  worksheet and input to the first line (be aware of overwriting "_______"), e.g Sort [|| 3, 1, 2 ||] Diff (x^2 + x + 1, x) Differentiate (E = a + a^2 + a*b, a) ... Take InsSort.thy as the most recent example.