<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: TryAlgebra</title>
    <description>The latest articles on DEV Community by TryAlgebra (@tryalgebra).</description>
    <link>https://dev.to/tryalgebra</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3663432%2F5f658377-161a-47ed-8999-a95413b15ea2.jpg</url>
      <title>DEV Community: TryAlgebra</title>
      <link>https://dev.to/tryalgebra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tryalgebra"/>
    <language>en</language>
    <item>
      <title>Term rewriting system + pattern matching now in TryAlgebra</title>
      <dc:creator>TryAlgebra</dc:creator>
      <pubDate>Sat, 10 Oct 2026 16:43:34 +0000</pubDate>
      <link>https://dev.to/tryalgebra/term-rewriting-system-pattern-matching-now-in-tryalgebra-1jbc</link>
      <guid>https://dev.to/tryalgebra/term-rewriting-system-pattern-matching-now-in-tryalgebra-1jbc</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmywa9wylgcqux47ft2q8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmywa9wylgcqux47ft2q8.png" alt="List of allowed formulas" width="558" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the arrow to perform the substitution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnasptpz1t9jegsf1bxa2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnasptpz1t9jegsf1bxa2.png" alt="Formula 1" width="563" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdfo8ratiocgdizlr1d1e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdfo8ratiocgdizlr1d1e.png" alt="Formula 2" width="561" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frq0f0d8gni8djxb7zcgy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frq0f0d8gni8djxb7zcgy.png" alt="Formulas file" width="570" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You also need to set up the algebra rules. These could be commutativity, distributivity, or your own rules.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffntb6e8hr1uhrgp172yi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffntb6e8hr1uhrgp172yi.png" alt="Trs file" width="556" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;br&gt;
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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhb8b67b8l6ujd8nrovyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhb8b67b8l6ujd8nrovyy.png" alt="Parsing" width="765" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The parsing file currently looks like this🫪.&lt;br&gt;
The color indicates how the variable captures the symbols (one-multi, zero-multi or one).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6au3sl7m9im4gophy7jf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6au3sl7m9im4gophy7jf.png" alt="Parsing2" width="591" height="779"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>programming</category>
      <category>showdev</category>
      <category>software</category>
    </item>
    <item>
      <title>Why term rewriting system is such a cool thing</title>
      <dc:creator>TryAlgebra</dc:creator>
      <pubDate>Sat, 03 Oct 2026 08:04:51 +0000</pubDate>
      <link>https://dev.to/tryalgebra/why-term-rewriting-system-is-such-a-cool-thing-1pif</link>
      <guid>https://dev.to/tryalgebra/why-term-rewriting-system-is-such-a-cool-thing-1pif</guid>
      <description>&lt;p&gt;The main feature of TryAlgebra is its ability to recognise formulas. Rather than applying formulas manually by rewriting expressions by hand, you simply select the expression to which you want to apply a formula, and choose it from the list of suggestions.&lt;br&gt;
Previously, you created a file containing identities as a template for mathematical expressions, with placeholders that captured the actual values. TryAlgebra then attempts to apply these templates to the selected expression. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwe85nggeljbh0q3ca7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwe85nggeljbh0q3ca7h.png" alt="TryAlgebra interface" width="799" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Simple string pattern matching, such as that used in regular expressions, is too restrictive. Furthermore, it does not recognize mathematical syntax, which can result in incorrect interpretation and matching. The solution is to parse the expression as a syntax tree, assigning a precedence order to each operator. Although this makes pattern matching more restrictive than simple string matching, fewer expressions will match the structured pattern. However, this approach at least preserves syntax and mathematical rules to some extent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcdjqa0xcya01i5yryvx5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcdjqa0xcya01i5yryvx5.png" alt="Syntax tree" width="532" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This still isn't very useful. &lt;br&gt;
We want the system to be more flexible so that it can use some math to determine whether the expression matches the template. For example, it could apply the commutativity or distributivity properties. It could also cancel out something. This would make it really useful.&lt;/p&gt;

&lt;p&gt;This is where the term rewriting system comes into play. It works like this: you provide it with basic mathematical identities, which it then uses to match the selected expression against the template. &lt;/p&gt;

&lt;p&gt;These systems are used for compiler optimization and simplifying expressions, as well as in computer algebra systems. In fact, the range of applications is not as extensive as I thought. However, the idea and mathematical principles behind them are very powerful and fundamental to the entire field of mathematics. TRS is formalized in math books using notions from 'universal algebra'. This topic is also fundamental and abstracts the entire field of algebra. The main idea is that we do not need to know the actual meaning of functions; we can simply treat them as symbols, and the relationship between them can be described using equivalence classes.&lt;/p&gt;

&lt;p&gt;I have currently implemented the TRS using saturation, which is similar to what Egg Optimizer does. Put simply, saturation involves applying identities to parts of the selected expression until it matches the template. There are few significant optimizations involved. The first is the equivalence graph, or e-graph, which stores mathematical expressions and all their rewritten versions in a compact way. The second is the congruence closure. I won't go into detail here, but this property enables more identities to be found without the need to apply mathematical rules. This property operates at a meta level and is applicable to any set of mathematical rules. It is actually a very simple property, but I will write about it in another post.&lt;/p&gt;

&lt;p&gt;The example below illustrates how TRS algorithm is used. &lt;br&gt;
It attempts to match '(ac + k)²' with '2ab + a² + b²' using listed identities. It is written in prefix notation; in TryAlgebra you'll be able to apply it to the familiar math notation. As you can see, it finds how to substitute a and b to match expressions modulo identities:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fibvivfj7tzjwa9kc3we3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fibvivfj7tzjwa9kc3we3.png" alt=" " width="505" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following posts will provide more details on the main aspects of the TRS. There are actually a lot of interesting things!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>Tree pattern matching</title>
      <dc:creator>TryAlgebra</dc:creator>
      <pubDate>Sun, 27 Sep 2026 21:06:52 +0000</pubDate>
      <link>https://dev.to/tryalgebra/tree-pattern-matching-26c8</link>
      <guid>https://dev.to/tryalgebra/tree-pattern-matching-26c8</guid>
      <description>&lt;p&gt;I managed to find a very effective decomposition of the pattern tree, which gives several useful properties for pattern matching. I finally finished the paper on this topic: &lt;a href="https://zenodo.org/records/22972752" rel="noopener noreferrer"&gt;https://zenodo.org/records/22972752&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the main highlights:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The algorithm treats unresolved variables as connections between different parts of the tree.&lt;/li&gt;
&lt;li&gt;Using these connections, it identifies independent parts of the pattern, each corresponding to its own system of Diophantine equations.&lt;/li&gt;
&lt;li&gt;During matching, the tree can be matched against independent parts of the pattern in parallel, since the result of matching one part does not affect the matching process of another.&lt;/li&gt;
&lt;li&gt;As a bonus, the backtracking is very simple, and the algorithm can be implemented as a straightforward recursive function.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Monthly update post</title>
      <dc:creator>TryAlgebra</dc:creator>
      <pubDate>Sun, 27 Sep 2026 21:04:51 +0000</pubDate>
      <link>https://dev.to/tryalgebra/monthly-update-post-nll</link>
      <guid>https://dev.to/tryalgebra/monthly-update-post-nll</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffxszsq2nzqkjnlskaa7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffxszsq2nzqkjnlskaa7g.png" alt=" " width="640" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A short monthly progress report:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Added the ability to select a folder/project before starting work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Added some of the missing mathematical elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved the mathematical element selector so that it appears next to the cursor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Added Ctrl+Z/Y support.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Added a command system for quick input.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Added a window that displays the project structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Added a scroll bar.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Made various minor UI improvements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m currently working on the formula system. The main components are already in place. The next step is to implement the project compiler, which will collect formulas, algebraic rules, and parsing rules and link them together.&lt;/p&gt;

</description>
      <category>buildinpublic</category>
      <category>showdev</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>TryAlgebra is an experimental mathematical editor and symbolic computation project</title>
      <dc:creator>TryAlgebra</dc:creator>
      <pubDate>Sun, 27 Sep 2026 21:02:41 +0000</pubDate>
      <link>https://dev.to/tryalgebra/tryalgebra-is-an-experimental-mathematical-editor-and-symbolic-computation-project-1n39</link>
      <guid>https://dev.to/tryalgebra/tryalgebra-is-an-experimental-mathematical-editor-and-symbolic-computation-project-1n39</guid>
      <description>&lt;p&gt;It is a WYSIWYG math editor with tools for defining formulas, parsing rules, and an algebraic term rewriting system.&lt;/p&gt;

&lt;p&gt;I’m developing the project from scratch and will use this blog to share progress, implementation details, design decisions, and experiments along the way.&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
