I wrote the 'term rewriting system' this spring. However, to use it in TryAlgebra, I had to create a system in which users can set up their own custom parser to convert mathematical expressions into terms and back again. This is because TRS works on terms, which have specific rules.
The workflow now looks like this: you select the expression, right-click and choose the formula you want to apply from the list of allowed formulas.

Click the arrow to perform the substitution.
This is where you write your formulas. You should create a separate file with this header and specify which TRS and parser to use. I know this may seem intimidating, but I'm working on ways to simplify the process. This is rather the prototype.
You also need to set up the algebra rules. These could be commutativity, distributivity, or your own rules.

The scariest part is the parser itself. This will be given further consideration. Currently, you specify rewriting rules to rewrite a selected expression into a term. The parser has two modes: top-down parsing with a single substitution at each level and an exhaustive top-down parser.
My aim is to make the parsing routine as intuitive as possible so that users can experiment with it. This is why I abandoned the Backus–Naur Form approach. I want something simpler and more math syntax oriented. So this part will definitely be redone.
The parsing file currently looks like this🫪.
The color indicates how the variable captures the symbols (one-multi, zero-multi or one).





Top comments (1)
tr.ee/dev-to