npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tree-term-rewriting

v0.0.1

Published

This is a work in progress library written in TypeScript for term rewriting using trees. The library is still a work in progress, things need to be more organized, more tests need to be written and so on.

Downloads

4

Readme

Tree Term Rewriting

This is a work in progress library written in TypeScript for term rewriting using trees. The library is still a work in progress, things need to be more organized, more tests need to be written and so on.

Features

Term Rewriting on Trees

The functions applyRules() and rewrite() can be used to rewrite a tree given a rewrite rule containing a pattern and a replacement.

Example (the expressions would be represented as trees in the library):

  • Input: a + b + -b
  • Rewrite rule from: $x + -$x
  • Rewrite rule to: 0
  • Output: a + 0

Expression parsing

The library provides a function to parse expressions into trees. The grammar is contained in the grammars folder.

There are two representations for trees. The first one is the obvious one with nodes (type TreeNode) where each node stores its own value, a unique index as well as a list of child nodes. The second one stores the tree using an Euler Tour. This representation makes tree matching and substitution easier. There are functions to convert between the two representations (makeEulerTree(), treeFromEulerTree()).

Knuth-Bendix Completion

Knuth-Bendix completion finds a confluent term rewriting system given a couple of basic rewrite rules and an ordering on functions. Basically it will find more rewrite rules such that applying the rules to equal but different terms will eventually result in the same term (eg. a + b - b and a * 3 / 3 are the same, and eventually would simplify to a).

Visualization / DOT

There are functions to convert trees to the DOT format which can be visualized by many different softwares. There are also functions to directly convert them to urls that visualize them with using https://dreampuf.github.io/GraphvizOnline.

Building

The library can be built by running yarn run build which will create the dist folder containing the javascript code, the definitions and the source map.

Run tests

  • Run all tests (unit tests and integration tests): yarn run test
  • Run only specific tests: yarn run test -g <string|regexp> (eg. to run integration tests yarn run test -g integration)

Examples

The examples can be run by first building the library and then running them in the dist folder (eg. node dist/examples/ga.js).

References

These are references that I found useful for learning about tree rewriting and Knuth-Bendix completion