Handling of Errorpatterns

A prerequisite for understanding the page below visiting Dialog_Architecture is recommended; a related page is Rule-based_Dialog.

Error patterns
Error patterns (EPs) are ISAC's formalization of "misconceptions" in mathematics. They are recognized mechanically by TP-technology and they are a prerequisite for automated generation of adaptive dialogues.

For instance, $$\frac{1+3}{2+3} = \frac{1}{2}$$ is an error in cancelling ($$+3$$ from the numerator and from the denominator), well-known to everybody who teaches calculating with fractions. This misconception can be modelled as an error pattern in an ML structure as follows:

val errpats = [("cancel", (*see master thesis gdarocy. p.TODO*)     [parse_patt thy "(?a + ?b)/?a = ?b",       parse_patt thy "(?a + ?b)/?b = ?a",       parse_patt thy "(?a + ?b)/(?b + ?c) = ?a / ?c",       parse_patt thy "(?a + ?c)/(?b + ?c) = ?a / ?b",       parse_patt thy "(?a + ?c)/(?b + ?c) = ?a / ?c",       parse_patt thy "(?a + ?b)/(?c + ?a) = ?b / ?c",       parse_patt thy "(?a*?b + ?c)/?a = ?b + ?c",       parse_patt thy "(?a*?b + ?c)/?b = ?a + ?c",       parse_patt thy "(?a + ?b*?c)/?b = ?a + ?c",       parse_patt thy "(?a + ?b*?c)/?b = ?a + ?b",       parse_patt thy "(?a + ?b*?e)/(?c + ?d*?e) = (?a + ?b)/(?c + ?d)"],      [@{thm real_times_divide_1_eq}, (*TODO*) @{thm real_times_divide_1_eq}]) ("addition"), [(*patterns*)], [(*theorems*)]]: errpat list;

The above structure errpats contains two items "cancel" and "addition", "cancel" is complete and "addition", as an example for dialog authors of how to extend the structure. Each item contains the


 * 1) the name, a unique identifier for the error pattern (for instance, "cancel")
 * 2) the patterns, a list of specific patterns for the same general kind of error (for instance, cancelling in a wrong way)
 * 3) the theorems, a list of theorems which have a left-hand-side (lhs) which match the lhs of the patterns.

For instance, these theorems have the same lhs as the "cancel" error pattern:

ML {* @{thm frac_eq_eq}; @{thm divide_cancel_left}; @{thm divide_cancel_right}; *} val it = "?y ≠ (0∷?'a) ⟹ ?z ≠ (0∷?'a) ⟹ (?x / ?y = ?w / ?z) = (?x * ?z = ?w * ?y)": thm val it = "(?c / ?a = ?c / ?b) = (?c = (0∷?'a) ∨ ?a = ?b)": thm val it = "(?a / ?c = ?b / ?c) = (?c = (0∷?'a) ∨ ?a = ?b)": thm

The error patterns are stored in the programs, which guide the calculations within which respective errors are expected. See, for instance, ''store_met .. "met_diff_onR" in file Knowledge/Diff.thy''.

Hint pages for error patterns
One possibility to automatically create dialog guidance by use of error patterns is connection with a "hint page". In case ISAC's math-engine detects an error pattern, the dialog might pop up a page, which gives hints about this specific error.

In order to implement this possibility, the file xmldata/error_patterns__hint_pages.properties must get specific entries; for instance, the first two lines implement a hint page found in the ExampleBrowser's file hierarchay at Examples > Etc > Fractions > Hints > Hint_3:

HierarchyKey_cancel=Examples,Etc,Fractions,Hints,Hint_3 KEStoreKey_cancel=exp_Etc_Frac_Hint_EP3 # HierarchyKey_chain-rule-diff-both=Examples,IsacCore,Calculus,Differentiation,Introduction,chained functions KEStoreKey_chain-rule-diff-both=exp_IsacCore_CDi_chain

This file contains "key=value" pairs, where each error pattern has two "key=value"-pairs:
 * 1) the HierarchyKey pointing at the hierarchy in the Examplebrowser
 * 2) *  key: "HierarchyKey_" + "error-pattern"
 * 3) *  value: the HierarchyKey: pay attention to have no blanks around ","
 * 4) the KEStoreKey, ISAC's unique identifier for files
 * 5) *  key: "KEStoreKey_" + "error-pattern"
 * 6) *  value: the KEStoreKey usually pointing to xmldata/exp

Both, the HierarchyKeys and the KEStoreKeys, are found in the respective hierarchy, i.e. in xmmldata/exp/exp_hierarchy.xml.

TODO: the format of the strings in error_patterns__hint_pages.properties is not yet fixed in detail.

.

Fill patterns and fill forms
A rewrite rule can be associated with fill patterns. Candidates to take fill patterns related to the error pattern "cancel" from above are the following rules (theorems thm in Isabelle):

ML {* @{thm cancel_left}; @{thm cancel_right}; *} val it = "?a ≠ (0∷?'a) ⟹ ?b ≠ (0∷?'a) ⟹ (?a * ?b) / (?a * ?c) = ?b / ?c": thm val it = "?b ≠ (0∷?'a) ⟹ ?c ≠ (0∷?'a) ⟹ (?a * ?b) / (?c * ?b) = ?a / ?c": thm

Theorem "cancel_left" can be associated with these fill patterns (defined in an ML structure in a similar way as the error patterns; note the the last element indicates the related EPs):

ML {* val fillpat = ([("fill-cancel-left-num", parse_patt @{theory Rational} "(?a * ?b) / (?a * ?c) = _ / ?c", ["cancel", "cancel+/+", "cancel0/_"]),    ("fill-cancel-left-den", parse_patt @{theory Rational} "(?a * ?b) / (?a * ?c) = ?b / _", ["cancel", "cancel+/+", "cancel0/_"]),    ("fill-cancel-none", parse_patt @{theory Rational} "(?a * ?b) / (?a * ?c) = ?b / ?c", ["cancel", "cancel+/+", "cancel0/_"])],   NONE): fillpat; *} Then, given a certain step in a calculation involving this theorem, the dialog might choose not to simply apply the theorem and come up with the complete result, but instead give a fill form; for instance

$$\frac{1}{2} + \frac{a}{b} + \frac{2*(x+z)}{2*(y+z)} = $$ $$\frac{1}{2} + \frac{a}{b} + \frac{x+z}{\_\_\_} = $$

in case the dialog has chosen the fill pattern "fill-cancel-left-den". This example suggests to anticipate error patterns; ISAC's math-engine is able to select fill patterns which match a certain step in a calculation. So, given these fill patterns in addition to the above

ML {* val fillpat = ([("fill-cancel-left-add1", parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * (?d + ?c)) = (_ + _) / (_ + _)", "cancel"),    ("fill-cancel-left-add2", parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * (?d + ?c)) = (?b + _) / (_ + _)", "cancel"),     ("fill-cancel-left-add3", parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * (?d + ?c)) = (?b + _) / (?d + _)", "cancel"),     ("fill-cancel-left-add4", parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * (?d + ?c)) = (?b + ?c) / (?d + ?c)", "cancel")],    SOME "exp_Etc_Frac_Hint_EP5"): fillpat; *}

the dialog also could have selected "fill-cancel-left-add3" in the example calculation from above (while ISAC's math-engine finds "fill-cancel-left-num", "fill-cancel-left-den", "fill-cancel-none", ... not matching):

$$\frac{1}{2} + \frac{a}{b} + \frac{2*(x+z)}{2*(y+z)} = $$ $$\frac{1}{2} + \frac{a}{b} + \frac{x+\_\_}{y+\_\_} = $$

Together with this fill-form the specific hint-page "exp_Etc_Frac_Hint_EP5" could be displayed. The additional possibilities in dialog guidance are bought by an increasing number number of fill patterns; experience will teach to balance the number of possibilities and the number of patterns.

As already mentioned, fill patterns are associated with theorems; however, presently they cannot be inserted in the respective theory, but only in Knowledge/Build_Thydata. See, for instance

insert_fillpats @{theory Rational} "IsacKnowledge" ("diff_sin_chain", @{thm diff_sin_chain}) fillpats;

Dialogue modes
A dialogue mode (DM) comprises settings which are the same for all learners at each level etc. Presently there are two modes
 * 1) normal-mode: the dialog checks input for EPs; if an EP is found, normal handling is done: EP_counter, etc.
 * 2) check-EPs-mode: forces the individual learner to formulas, where only one EP can happen. This mode is switched on by error_patterns_to_check_ != [].

TODO
TODO