3. Quick examples of usage

Having finished the installation step, we are now ready to use the system1.

In this document word problem means a mathematical problem requiring writing the equations describing all the relevant information needed to get the solution. We we'll split the solution of such a problem into:

Modeling:
Finding out the equations describing all the relevant information needed to get the solution. This requires the student to use common sense reasonong abot the world and the ability to write these relations in the mathematical language.
Solving:
Determining the solution by handling the equations in a pure formal way.

There are a lot of applications for helping students with solving step but only a few for the modeling step. We will present here a prototype for addressing this step for problems requiring just elementary arithmetics.

The system allows two modes of usage, for authors (teachers) and for students:

  • creation of a word problem
  • tutorial dialog for solving a word problem.

The first application runs inside the Scala REPL, and consists in a library implementing the class Problem with resources for constructing problems from natural language sentences. Problems are saved as Prolog clauses with comments used to reconstruct the originating sentences. The second application is a Scala executable that loads a saved problem and engages the student in a nalural lenguage dialog conducting to have the problem correctly modeled.

Both applications use a Prolog database to reason about the problem. The basic difference is that for the author tool, the system constructs the model automatically in order to check if the problem is consistent (it does not contain contradictions) and complete (it has enough information to give a single solution), while for the student tool, the model construction is driven by the sentences proposed by the student. The system leads the student through several discovering steps (see next section) and checks that the proposed sentences are correct and relevant.

Writing a word problem

Invoke the author tool by:

./create

Create a new problem to be saved into file fruit.pl

scala: val p = new Problem("fruit.pl")
p: wp.Problem = Problem with 0 statements

We could use the Statement class to add new statements to the problem with the += operator. However, it is more convenient to define a statement factory for entering them in natural language (denoted by its 3-letter ISO code):

scala: val en = new StatementFactory("Eng")

We can now use a predictive parser to enter a new sentence into the problem:

scala: p += en.read
Eng: John has seven fruit .

Notice the final period. We can keep track of how many statements our problem has by:

scala: p
res1: wp.Problem = Problem with 1 statements

Let us add some more facts:

scala: p += en.read
Eng: John has two apples , some oranges and three bananas .
scala: p += en.read
Eng: how many oranges does John have ?

To take a look to the internal representation of the problem, use print:

scala: p.print

We can check if the problem is consistent (it does not contain contradictory statements) or complete (it has a single solution) by using the methods consistent and complete:

scala: p.complete
res3: Boolean = true

Remember to save the problem:

scala: p.save()
Saved to 'fruit.pl'

and now we can exit:

:q

Solving the problem

We can now try to solve our problem, by calling model with the file containing the problem:

 ./model fruit.pl 

It shows us the statement of the problem:

John has seven fruit .
John has two apples , some oranges and three bananas .
how many oranges does John have ?

and displays the prompt:

 ?

We can always press return at the prompt (or type help) for the system to suggest the proper action:

you must assign a variable to the oranges that John has .

But we do not know how to assign variables. Let us ask for an example:

? give me an example
let $x$ denote the animals that Mary has

Using this template we can now compose a definition for the variable x:

? let x denote the oranges that Mary has
you must assign a variable to the oranges that John has .

I forgot that we were dealing with John's fruit, not Mary's:

? let x denote the oranges that John has
it is right .

Press again return for the next suggestion:

you must split the fruit that John has .

This means that we have to specify how John's fruit are split in different classes:

 ? the fruit that John has are the apples that John has and the bananas that John has
 you must consider oranges .

Yes, there are oranges too. Let us correct it:

 ? the fruit that John has are the apples that John has , the bananas that John has and the oranges that John has
 it is right .

Good. Next suggestion:

you must write an equation which says that the fruit that John has are the bananas that John has , 
the oranges that John has and the apples that John has .

What about this?

? y plus 2 plus 3 is equal to 7
it doesn't follow .

This means that the proposed equation can not be deduced from the statement of the problem. Let us see what is wrong with the variable y:

? tell me about y
nothing is known about it .

Perhaps we used a different variable to denote the amount of oranges:

? tell me about the oranges that John has
the oranges that John has are $x$ oranges .

So we used x for it. Just to confirm it:

  ? tell me about x
  $x$ denotes the oranges that John has .

We rewrite the equation using x:

? x plus 2 plus 3 is equal to 7
it is right .

Now the problem is correctly modeled. The next action will give us the solution:

the oranges that John has are two oranges .

Going multilingual

To run the same problem but in Spanish, add the 3-letter-ISO code of the language as second argument:

./model examples/fruit.pl spa
...
Juan tiene siete frutas .
Juan tiene dos manzanas , algunas naranjas y tres plátanos .
¿ cuantas naranjas tiene Juan ?

Asking for help:

? 
debes asignar una variable a las naranjas que Juan tiene .

Asking for an example:

? dame un ejemplo
denota las cartas que María tiene por $z$

  1. The system will start/stop the GF-java service for you, but if you run into trouble you can check the state of the service by: bin/wpserver status and stop it by: bin/wpserver stop