<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A Rule-Based Approach to teach Mathematics using Animation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Nada Sharaf</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Slim Abdennadher</string-name>
          <email>slim.abdennadherg@guc.edu.eg</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Thom Fruhwirth</string-name>
          <email>thom.fruehwirth@uni-ulm.de</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>The German University in Cairo</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Ulm</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>There are di erent available methodologies for teaching mathematics to children. Teachers use di erent approaches. Some of the exiting approaches include engaging students with di erent activities and games. Computer games/tools have been proven e ective with teaching mathematics. The aim of the paper is to provide teachers with no background in Computer Science with a utility that enables them to build their own games. In this way, teachers will be able to customize games according to the principles they want their students to learn.</p>
      </abstract>
      <kwd-group>
        <kwd>Constraint Handling Rules</kwd>
        <kwd>Mathematics</kwd>
        <kwd>Learning</kwd>
        <kwd>Program Animation</kwd>
        <kwd>Visualization</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        One of the recently introduced activities for teaching in di erent elds,
including mathematics, is using games and computer platforms [
        <xref ref-type="bibr" rid="ref1 ref2 ref3">1,2,3</xref>
        ]. Students have
proven to have positive attitudes towards games involving maths. Such approach
encourages active learning. Such tools have been proven to be e ective in
enhancing learning of complex content as well [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>The provided tools are however, to the best knowledge of the authors, static
ones. Teachers do not have the option to customize the games in any way. For
example, the appearance cannot be changed. Users will have to stick to the look
provided by the original programmers of the tools. In addition, teachers cannot
customize the mathematical concepts tackled by the tools. They might thus have
to use di erent games/tools in case they need to tackle more than one concept.
The work in this paper aims at overcoming these drawbacks. It introduces a
new rule-based approach for generating di erent interactive customizable games.
Through the o ered tool, teachers are able to de ne the mathematical concepts
students should practice. They are then able to state how numbers should be
visualized.</p>
      <p>
        The tool makes use of the recently introduced annotation rules for
animating Constraint Handling Rules' (CHR) programs [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Such rules were able to
embed visualization features into CHR programs. With the new extension, CHR
programs were animated during execution. The tool used source-to-source
transformation to eliminate the need for changing the CHR compiler.
      </p>
      <p>The tool introduced in the paper generates CHR programs representing the
di erent mathematical concepts entered by the teacher. Annotation rules are
then utilized to visualize the execution of the program using the inputs of the
teacher.</p>
      <p>The paper is organized as follows: Section 2 introduces CHR. In Section 3,
annotation rules are discussed in more details. Section 4 introduces the di erent
features o ered to teachers. Section 5 shows how students can use the platform.
Finally, conclusions and directions to future work are o ered.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Constraint Handling Rules</title>
      <p>
        CHR [
        <xref ref-type="bibr" rid="ref6 ref7 ref8 ref9">6,7,8,9</xref>
        ] was initially introduced for writing constraint solvers. However,
over the years, it has been used as a general purpose language. CHR programs
consist of di erent rules that rewrite constraints in the constraint store until a
xed point is reached. A CHR rule has a head and a body and an optional guard.
A rule is only applied if the constraint store contains constraints matching the
head constraints and if the guard is satis ed. For example the below \simpli
cation rule" is able to sort a list of numbers. Each element in the list is represented
by the CHR constraint list(Index,Value).
list(I1,V1),list(I2,V2)&lt;=&gt;I1&lt;I2,V1&gt;V2|list(I2,V1),list(I1,V2).
The rule is applied on any two elements that are not sorted. The elements are
then swapped with respect to each other by removing the head constraints from
the store and adding the constraints in the body. In order for the rule to be
applied, two list constraints have to be in the store. The two constraints have
to satisfy the guard as well. Upon successive applications of the rule, all
elements are sorted. Propagation rules, on the other hand, do not remove the head
constraints from the constraint store. They only add the body constraints such
as the transitivity rule for the less than or equal constraint (leq):
leq(A,B),leq(B,C)==&gt;leq(A,C).
      </p>
      <p>The last, and more general, type is the simpagation rule. A simpagation rule has
two types of head constraints separated by a backslash: \n". On executing a
simpagation rule, the constraints before the backslash are kept and the ones after the
backslash are removed. For example the rule min(A)\min(B)&lt;=&gt;A&lt;B|true
compares two constraints and keeps only the one having the lower number. Thus,
upon applying this rule successively, the only constraint remaining is the one
with the smallest number.
3</p>
      <p>
        Annotation Rules for Animating CHR Programs
With CHR becoming a general purpose language, the need of tracing tools has
been evoked. In [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], a tracing utility for CHR was added. It was able to show
at each step of the execution, the constraint store and which rules were being
applied. The tool used source-to-source transformation. However, since CHR
is used with di erent types of algorithms (such as sorting, tree and graph
algorithms), an algorithm animation tool was required. In order to keep the platform
a generic one, visual annotation rules were added [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The idea is that every CHR
constraint was linked with a visual object. CHR rules operate on constraints,
adding and removing them. Each time a new constraint is added to/removed
from the store, its corresponding visual object(s) (if any) is added/removed.
Users are supplied with an interface to mark the interesting constraints. Such
constraints a ect the visualization and are linked to visual objects. For example,
in the sorting program shown in Section 2, the interesting constraint is list/2.
Every list constraint could be visualized as a bar where the height of the bar
is a factor of the \value" of the list element. The x-position of the bar is a
factor of the \index" of the list element. The whole list is visualized to the user
in this case. When a list constraint is added/removed, its corresponding bar is
added/removed animating the executed algorithm. To keep the system generic,
the scripting tool Jawaa1 [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] was used. Jawaa o ers users with a wide range of
visual objects and actions.
4
      </p>
    </sec>
    <sec id="sec-3">
      <title>Teacher Module</title>
      <p>In this section, the \teacher module" is introduced. This module is used by
teachers to specify the mathematical concepts students should learn and the
appearance of the output game. Figure 1 shows the rst screen teachers get.
They have the option to de ne a \simple rule" and a \Rule with Steps". A
simple rule is a rule computed through one step. Teachers can also de ne a rule
with several cases/steps.</p>
      <p>In the case of simple rules, teachers have to de ne the input(s) and output.
Figure 2a shows the view teachers get once they decide to add a simple rule.
The name of the rule is editable. As seen in Figure 2b, it was changed to sum.
Users can enter any number of inputs. An input could be a variable name or
an actual value as seen in Figure 2b. The output could also be a value or an
expression as shown in Figure 2c.</p>
      <p>In the case of de ning a rule with steps, instead of only de ning the expression
for the output, teachers de ne steps. Except for the rst step, each step takes
the output of the previous step as one of its inputs. There is an upper limit to
the number of steps that could be performed. As a proof of the concept, the
paper will focus only on the case of simple rules since the core principles for
generating the animations in both cases are the same.
4.1</p>
      <sec id="sec-3-1">
        <title>De ning Animations</title>
        <p>After teachers de ne the mathematical rule that students should practice, they
can de ne how the quizzes students get look like. They can rst choose a color or
an image for the background. They can also specify how numbers should appear.
The idea is that each number m could be represented by a visual object or n
visual objects. Teachers can customize what the objects are. Objects could be
1 http://www.cs.duke.edu/csed/jawaa2/
4
simple shapes (provided by Jawaa) such as circles, rectangles, etc. Objects could
also be linked to pictures to match a speci c theme. Teachers get the window
shown in Figure 3 where they can link a number to its corresponding visual
object to produce the required annotation rules. Once the teacher chooses an
object, the panel gets populated with the corresponding parameters that have to
be lled. In order to link a number to several objects, the teacher should choose
to connect it with the visual object \nObjects". nObjects is a newly added object
to Jawaa. It groups visual objects together.</p>
        <p>For the example shown in the Figure 3, it was required that a number X gets
associated with X di erent objects. The number was thus linked with \nObjects".
The teacher enters a value for the required number of generated objects. In
this case, X objects are needed. The teacher should then choose which type
of visual object should be generated X times for each number X. The object
\imageobject" was used in this case. An imageobject is an actual image with
the extension \jpg" or \png". It was also added to Jawaa. For each imageobject
users have to specify where the image should be shown (x and y coordinates) in
addition to the location of the image (path). In general, each parameter could
be one of the following values or expressions based on them:
1. a constant e.g. 30, red, etc
2. the built-in function valueOf (X) representing the value of the number X.
3. the keyword valueOf (N ) used in the case of nObjects to represent the
varying number. For example the rst generated object would have an N = 0,
the second would have an N = 1, etc.
In the previous example the x-coordinate of each shown imageobject was set to
30 + valueOf (N ) 40. Thus for the rst image shown the x-coordinate will be
30 + 0 40 which is 30. The second image will have an x-coordinate of 30 + 1 40
or 70, etc. A user can also associate a number through more than one rule. For
example, a number could be associated with a colored circle and a text object.
Thus more than one object would be shown for the same number.</p>
        <p>Once the teacher de nes the needed annotation rule(s), they move to the next
(optional) step. In this step, teachers can de ne any number of constraints on the
input numbers students will get. For example teachers can add constraints for
an input to be a one-digit number (i.e. &lt; 10 and 0). Constraints can also link
more than one input together (e.g. X &lt; Y ). Figure 4 shows an example where
every input has more than one associated constraint. The available constraints
are &lt;, &gt;, , , =, ! =. Teachers also choose lower and upper bounds for the
generated numbers.
Every simple rule named rule name with inputs X1; : : : ; XN is represented with
the CHR constraint rule(rule_name,N). Inputs are represented separately through
the constraints input(Rule_name,Value,Index). The output of the rule
contains in most of the cases an expression to be evaluated. The evaluated output
is stored inside the constraint output(Rule_name,Output). Thus such a simple
rule is represented by the following CHR program:</p>
        <p>The CHR le is automatically generated. Thus, the teacher does not have to
be aware of CHR to use the system. The produced le is transformed using the
CHRAnimation tool to be able to produce the required visual objects during
execution.
5</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Student Module</title>
      <p>Once users start to play, the background is set to the background chosen by the
teacher. It could be just a color or an image. Afterwards, the random generator is
used to generate numbers ful lling the needed constraints. Once the numbers are
generated, the CHR le produced in Section 4.2 is queried. The aim of querying
the CHR le is to:
{ generate the correct output to be able to compare the answer of the student
with the correct one.
{ represent the inputs and output as CHR constraints activating the
animation.</p>
      <p>Every input is associated with the constraint input/3. Every time, such a
constraint is added, its corresponding visual object(s) is added. For instance, in
the previous example, every input with value X is associated with X pictures
each showing an \apple". Thus every time a constraint for an input is added,
CHRAnimation adds the corresponding visual objects to the animation frame
resulting in the window shown in Figure 5a showing the two input numbers (2
and 4)1.</p>
      <p>The student can then start to add the suggested output. Every time the
student presses \Add", the output is incremented. Since the output is a number,
it is visualized in the same way. Figure 5b shows the window after pressing the
button one time. The output is thus now visualized with one apple. Figure 5c
shows the window after setting the output to 6. In this case, six apples are shown.
At any point, the student can \check" whether the current output is correct or
not. They get the corresponding message in each case.
5.1</p>
      <sec id="sec-4-1">
        <title>Another Quiz</title>
        <p>Another option for producing interesting interactive animations is to:
1. Link every input number with a normal Jawaa circular node. The text inside
the node is its value. Its background is blue.
2. Link the output with a random number of nObjects displaying a group of
nodes. Each node is placed in a random position. The text inside each node
is also a random number. CHRAnimation has the keyword \Random" that
could be utilized in this case. Such nodes have green backgrounds.
1 The y-coordinate speci ed by the teacher is automatically multiplied by the index
of the input to have each input on separate line
(a) Inputs</p>
        <p>(b) Editing output I
(c) Editing output II
3. Link the output with a Jawaa circular node with the name (jawaanodeout)
displaying the actual output of the rule. It is also placed at a random position.</p>
        <p>Its background is green as well.
4. Add an annotation rule linking the output constraint with an onclick
command for the object jawaanodeout. Once it is clicked, the changeParam
command is activated changing its color to red.1
1 The onclick command was previously added to Jawaa. It allows an action to be
performed on clicking a speci ed object.
Once the generated CHR le is queried two blue nodes representing the two
inputs are shown. In addition, a group of green nodes are shown. Only one of
them represents the output. Once the user clicks on the node representing the
output value, its color changes to red. If the user clicks on any other node,
nothing happens. Figure 6a shows the initial setup with the randomly placed
nodes. Figure 6b shows the node with the output being highlighted after the
user clicked it.</p>
        <p>(a) Randomly placed nodes
(b) Highlighted node after clicking</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Conclusion &amp; Future Work</title>
      <p>This paper shows how annotation rules could be utilized for generating quizzes to
teach mathematics. The tool was able to customize the look of the games
according to the inputs of the teachers unlike existing games with static looks and
operations (such as: http://www.iboard.co.uk/iwb/Simple-Addition-Stories-721).
The tool does not need any computer science background. As seen through the
examples, annotation rules were able to produce interactive animations that
could be used to teach mathematical rules. In the future, di erent mathematical
concepts should be explored and animated. The tool should be linked with
different visualization libraries as well. The paper o ered a prototype for a proof of
concept. In the future, the tool should be extended in a way to handle di erent
kinds of output quizzes in a generic way.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>S.</given-names>
            <surname>Barab</surname>
          </string-name>
          , M. Thomas,
          <string-name>
            <given-names>T.</given-names>
            <surname>Dodge</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Carteaux</surname>
          </string-name>
          , and
          <string-name>
            <given-names>H.</given-names>
            <surname>Tuzun</surname>
          </string-name>
          , \
          <article-title>Making learning fun: Quest Atlantis, a game without guns,"</article-title>
          <source>Educational Technology Research and Development</source>
          , vol.
          <volume>53</volume>
          , no.
          <issue>1</issue>
          , pp.
          <volume>86</volume>
          {
          <issue>107</issue>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>R.</given-names>
            <surname>Rosas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Nussbaum</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Cumsille</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Marianov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Correa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Flores</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Grau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Lagos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Lopez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Lopez</surname>
          </string-name>
          , P. Rodr guez, and M. Salinas, \
          <article-title>Beyond Nintendo: design and assessment of educational video games for rst and second grade students,"</article-title>
          <source>Computers &amp; Education</source>
          , vol.
          <volume>40</volume>
          , no.
          <issue>1</issue>
          , pp.
          <volume>71</volume>
          {
          <issue>94</issue>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>G.</given-names>
            <surname>Lopez-Morteo</surname>
          </string-name>
          and G. Lopez, \
          <article-title>Computer support for learning mathematics: A learning environment based on recreational learning objects,"</article-title>
          <source>Computers &amp; Education</source>
          , vol.
          <volume>48</volume>
          , no.
          <issue>4</issue>
          , pp.
          <volume>618</volume>
          {
          <issue>641</issue>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>F.</given-names>
            <surname>Ke</surname>
          </string-name>
          , \
          <article-title>A case study of computer gaming for math: Engaged learning from gameplay?,"</article-title>
          <source>Computers &amp; Education</source>
          , vol.
          <volume>51</volume>
          , no.
          <issue>4</issue>
          , pp.
          <volume>1609</volume>
          {
          <issue>1620</issue>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>N.</given-names>
            <surname>Sharaf</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Abdennadher</surname>
          </string-name>
          , and T. W. Fruhwirth, \
          <article-title>CHRAnimation: An Animation Tool for Constraint Handling Rules," in Logic-Based Program Synthesis</article-title>
          and Transformation - 24th
          <source>International Symposium</source>
          ,
          <string-name>
            <surname>LOPSTR</surname>
          </string-name>
          <year>2014</year>
          .
          <article-title>(M. Proietti and H</article-title>
          . Seki, eds.), vol.
          <volume>8981</volume>
          of Lecture Notes in Computer Science, pp.
          <volume>92</volume>
          {
          <issue>110</issue>
          , Springer,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. T. W. Fruhwirth, \
          <article-title>Theory and Practice of Constraint Handling Rules,"</article-title>
          <source>J. Log. Program.</source>
          , vol.
          <volume>37</volume>
          , no.
          <issue>1-3</issue>
          , pp.
          <volume>95</volume>
          {
          <issue>138</issue>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>T.</given-names>
            <surname>Fru</surname>
          </string-name>
          <article-title>hwirth, Constraint Handling Rules</article-title>
          . Cambridge University Press,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>H.</given-names>
            <surname>Betz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Raiser</surname>
          </string-name>
          , and T. W. Fruhwirth, \
          <article-title>A complete and terminating execution model for Constraint Handling Rules,"</article-title>
          <source>TPLP</source>
          , vol.
          <volume>10</volume>
          , no.
          <issue>4-6</issue>
          , pp.
          <volume>597</volume>
          {
          <issue>610</issue>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. T. W. Fruhwirth, \
          <article-title>Constraint Handling Rules - What Else?," in Rule Technologies: Foundations, Tools,</article-title>
          and Applications - 9th
          <source>International Symposium, RuleML</source>
          <year>2015</year>
          , Berlin, Germany,
          <source>August 2-5</source>
          ,
          <year>2015</year>
          ,
          <string-name>
            <surname>Proceedings (N. Bassiliades</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <string-name>
            <surname>Gottlob</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <string-name>
            <surname>Sadri</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Paschke</surname>
          </string-name>
          , and D. Roman, eds.), vol.
          <volume>9202</volume>
          of Lecture Notes in Computer Science, pp.
          <volume>13</volume>
          {
          <issue>34</issue>
          , Springer,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>S.</given-names>
            <surname>Abdennadher</surname>
          </string-name>
          and
          <string-name>
            <given-names>N.</given-names>
            <surname>Sharaf</surname>
          </string-name>
          , \
          <article-title>Visualization of CHR through Source-to-Source Transformation,"</article-title>
          <source>in Technical Communications of the 28th International Conference on Logic Programming</source>
          ,
          <source>ICLP 2012, September 4-8</source>
          ,
          <year>2012</year>
          , Budapest, Hungary (
          <string-name>
            <given-names>A.</given-names>
            <surname>Dovier</surname>
          </string-name>
          and V. S. Costa, eds.), vol.
          <volume>17</volume>
          of LIPIcs, pp.
          <volume>109</volume>
          {
          <issue>118</issue>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>W. C.</given-names>
            <surname>Pierson</surname>
          </string-name>
          and
          <string-name>
            <given-names>S. H.</given-names>
            <surname>Rodger</surname>
          </string-name>
          , \
          <article-title>Web-based animation of data structures using JAWAA,"</article-title>
          <source>in Proceedings of the 29th SIGCSE Technical Symposium on Computer Science Education</source>
          ,
          <year>1998</year>
          , Atlanta, Georgia, USA,
          <source>February 26 - March 1</source>
          ,
          <string-name>
            <surname>1998 (J. Lewis</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Prey</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Joyce</surname>
          </string-name>
          , and J. Impagliazzo, eds.), pp.
          <volume>267</volume>
          {
          <issue>271</issue>
          ,
          <string-name>
            <surname>ACM</surname>
          </string-name>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>