In June of 2011 Chris Sangwin told me he was interested in software that could do step-by-step equation solving. Since that time I have been working on creating an open source, JavaScript-based CAS (Computer Algebra System) that is capable of doing semi-automatic and fully-automatic step-by-step equation solving. It is being designed for use in demonstrations, exercises, and assessments.

Here are some examples that show a prototype of this CAS solving equations that contain a single copy of the unknown (I had to remove the http:// from this URL, because this is my first forum post and the forum only permits one URL in an initial post):

patternmatics.com/examples/expressions/stepbystep/single_unknown/

A student must have a clear understanding of the structure of mathematical expressions before they can successfully interact with a step-by-step CAS. Therefore, the first features I am implementing in the CAS are related to teaching this structure in a visual way. This is what I have working so far:

http://patternmatics.com/test/expression_structure.html

I am thinking about integrating this software with Moodle in some way. Is anyone in this forum interested in this idea?

Ted Kosan

### Patternmatics, a step-by-step equation solving CAS

Number of replies: 4### Re: Patternmatics, a step-by-step equation solving CAS

Ted,

This is very exciting work. I think, having some elementary CAS in javascript would be a very valuable project.

This kind of functionality has been done before, although sadly some of the work is now trapped in legacy code. It would be great to have this kind of functionality available in Moodle for our students to use.

For people who've not looked into this before

- The software Aplusix has the kind of "reasoning by equivalence" which Ted refers to here. http://www.aplusix.com/ The authors of this software have thought a lot about editing algebraic expressions, e.g. http://hal.archives-ouvertes.fr/docs/00/59/15/53/PDF/Nicaud-JeanFrancois-2008.pdf
- The work of Michael Beeson on MathXpert is inspirational, and should be essential reading. See http://www.helpwithmath.com/ and his paper http://www.michaelbeeson.com/research/papers/hisc.pdf is a good place to start.
- The Numbas people (http://www.ncl.ac.uk/maths/numbas/) are also working on a Javascript CAS. I wonder if there is any milage in collaborating with them?

Thank you very much for the reference to Patrick Thompon's interesting paper.

Chris

### Re: Patternmatics, a step-by-step equation solving CAS

Chris,

I would add Alan Bundy's research to the list of sources you provided. In 2011 you told me about Alan Bundy's book "The Computer Modeling of Mathematical Reasoning", and I think you became aware of this book because it is listed as a reference in Michael Beeson's paper you linked to in your post.

A .pdf version of this book, along with most of Alan Bundy's research papers, can be found here:

http://patternmatics.com/research/research.html

Alan Bundy and his research group at the University of Edinburgh developed an AI-based step-by-step equation solving system named PRESS (PRolog Equation Solving System), and it was the focus of much of their work in the 1970s and 1980s. The final version of PRESS was the result of over 10 years of research, and it was capable of solving most of the equations that were present on A-level examinations at the time.

The CAS I am building is based upon Alan Bundy's research and PRESS. I updated the PRESS source code so it would run on a modern implementation of Prolog, and I am in the process of reverse engineering it.

Alan Bundy still teaches at the University of Edinburgh. He has been assisting me by providing me with additional information related to PRESS that is difficult to obtain on the Internet.

Ted

### Re: Patternmatics, a step-by-step equation solving CAS

Hi Ted. I am "the Numbas people" Chris referred to. I've done a fair amount of work on parsing and rewriting mathematical expressions, but nothing on equation solving.

The Numbas source code is online at https://github.com/numbas/Numbas. In particular, the mathematical parser/evaluator is in runtime/scripts/jme.js and the code for rewriting expressions is in runtime/scripts/jme-display.js.

I think the Numbas parser is a bit more sophisticated than the Khan Academy parser you're using, so it might be worth taking a look at. In fact, I did some work for the OU a while ago supporting someone to make the parser work standalone, but that didn't end up going anywhere. Maybe it's worth having another go at that! At the moment it lives inside a rather clunky script-loading system; it should really be a single JS file that you can drop in without much setup.

Anyway, you'll probably be interested in the expression rewriting system I have. It's mainly used to make randomly generated expressions look more like the way a human would write them, but it could be twisted to do step-by-step equation solving. At the bottom of jme-display.js, there's a big list of "simplification rules".These are pattern-matching rules working on trees - each rule specifies a syntax tree to match, as well as conditions on the leaves/subtrees, and then gives a new tree pattern to rewrite the expression as.

Something I would like to do, and I'd be interested in collaborating with someone on, is making this pattern-matching system more powerful. I'd like to work towards a kind of regular expression algorithm for syntax trees, which could do things like match repeated groups, or account for the commutativity/associativity/distributivity of operations explicitly. For example, I'd like to be able to say "collect all constant terms together" in a single step, rather than the bubble-sort that the system currently does by repeatedly applying the rule "variables go on the left of constants".

### Re: Patternmatics, a step-by-step equation solving CAS

Christian,

The parser/evaluator in jme.js is significantly more sophisticated than the parser I am currently using. The expression rewriting system in jme-display.js looks like it is very useful, and I especially like the way pattern-matching rules are defined in it. I think there is quite a bit I can use in this code. Thank you for making me aware of it.

The pattern-matching system I have been using for my prototype work is the one that is in the MathPiper CAS. However, it is a fairly simple pattern matcher that does not “know” about the commutativity and associativity of addition and multiplication. PRESS has two pattern matchers. The simpler matcher (which is the one it uses by default) is aware of the commutativity and associativity of addition and multiplication. A more powerful experimental matcher was also created for PRESS, and it is described in the following paper:

http://www.research.ed.ac.uk/portal/en/publications/using-matching-in-algebraic-equation-solving%28dd8c9205-12f6-4512-a79e-325c2d9d6420%29.html

I am going to attempt to make a JavaScript version of the simpler PRESS pattern matcher for the CAS I am building. If I am successful, this pattern matcher might be of use in Numbas.

Ted