{"id":16613144,"url":"https://github.com/c-cube/stimsym","last_synced_at":"2025-10-04T06:59:53.837Z","repository":{"id":144717423,"uuid":"75125975","full_name":"c-cube/stimsym","owner":"c-cube","description":"[toy] A rewriting language similar to the core of Mathematica","archived":false,"fork":false,"pushed_at":"2022-04-19T04:21:14.000Z","size":510,"stargazers_count":54,"open_issues_count":5,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-04T06:59:52.112Z","etag":null,"topics":["jupyter","mathematica","pattern-matching","rewriting"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c-cube.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-29T21:59:37.000Z","updated_at":"2024-11-05T00:34:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"7aa4ee3e-6b0d-43f3-bd7a-f8ae6b356760","html_url":"https://github.com/c-cube/stimsym","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/c-cube/stimsym","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fstimsym","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fstimsym/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fstimsym/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fstimsym/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-cube","download_url":"https://codeload.github.com/c-cube/stimsym/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fstimsym/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278277871,"owners_count":25960430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jupyter","mathematica","pattern-matching","rewriting"],"created_at":"2024-10-12T01:46:06.150Z","updated_at":"2025-10-04T06:59:53.808Z","avatar_url":"https://github.com/c-cube.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stimsym [![build status](https://travis-ci.org/c-cube/stimsym.svg?branch=master)](https://travis-ci.org/c-cube/stimsym)\n\nRewrite system designed for symbolic manipulations and maximal expressiveness.\n\nWhy?! Well, I see that Mathematica as a symbolic language has a lot of\nnice features, and is rooted in term rewriting. However, because of\nits price and closedness, I started this small project. The goal is certainly\nnot to reimplement all the complex mathematical primitives of Mathematica;\ninstead, I just want a terse, powerful language in a sandbox (here, a Jupyter\nnotebook or a CLI interface).\n\nI drew a lot of inspiration from https://github.com/jyh1/mmaclone/, which\nwas also my reference for operator priorities for the expression parser.\nStimsym is not yet feature complete (it lacks AC matching, among others,\nfor now), but it has a Jupyter interface and I believe the architecture might\nscale a bit better if lots of primitives were added. Most of the code\nfor the Jupyter frontend is adapted from\n[IOCaml](https://github.com/andrewray/iocaml)\nso as to use `lwt-zmq` and work with Jupyter 4.\n\n## Build\n\nI recommend using [opam](https://opam.ocaml.org). The following will\nclone this repository, and use opam to install the dependencies and\nthe program itself\n\n```\ngit clone https://github.com/c-cube/stimsym.git\ncd stimsym\nopam pin add -k git -n stimsym\nopam install stimsym\n```\n\nFor the jupyter frontend, some more dependencies are needed (see 'opam' to\nsee which one exactly, but it should be something along:\n`opam install zmq atdgen yojson uuidm lwt lwt-zmq`).\n\n## Usage\n\nOnce installed, you can either use the simple command line interface:\n\n```mathematica\n$ stimsym_cli\n\u003e 1+1\n2\n\u003e f[1,2,g[3],4,5] //. f[l1__,l2__,g[x_],r__] :\u003e h[r,x,l2,l1]\nh[4,5,3,2,1]\n\u003e {f[a],f[b],f[c],f[d]} //. f[x_] /; ((x===a)||(x===c)) :\u003e g[x]\nList[g[a],f[b],g[c],f[d]]\n```\n\n### Some Examples\n\nSee [the list of commented examples](doc/examples.adoc) to\nget an idea of how to use Stimsym.\nThe file 'tests/run_tests.ml' also contains a lot of small test cases.\n\nSome notebooks can be found on\nthe [gallery branch](https://github.com/c-cube/stimsym/tree/gallery),\nincluding [an improved version of the examples](https://github.com/c-cube/stimsym/blob/gallery/data/notebook_examples.ipynb).\n\n### Jupyter Interface\n\nUse the (experimental) library\n[jupyter-kernel](https://github.com/ocaml-jupyter/jupyter-kernel).\nRecommended way is\n`jupyter kernelspec install data/ --name=stimsym --user --replace`\nYou can also copy manually 'data/kernel.json' into the directory\n`~/.local/share/jupyter/kernels/stimsym`.\n\n```\nmkdir -p ~/.local/share/jupyter/kernels/stimsym\ncp data/kernel.json ~/.local/share/jupyter/kernels/stimsym/\n\nopam pin add -k git jupyter-kernel https://github.com/ocaml-jupyter/jupyter-kernel.git\n```\n\nStart the jupyter notebook with `jupyter-notebook`;\nyou can find a sample notebook in 'data/notebook1.ipynb'. The `make jupyter`\ntarget will open the sample notebook.\n\n## License\n\nBSD license, you can modify as you like. Contributions are welcome.\n\n## Hacking\n\nAlmost everything in the language itself can be found in `src/core/Expr.ml`,\n`src/core/Eval.ml{,i}` and `src/core/Pattern.ml{,i}`;\nthe primitives are in `src/core/Builtins.ml`.\nThe rest is about parsing, CLI, jupyter frontend, etc. The code is relatively\nnaive and will certainly not perform well, and there is a lot of room for\nalgorithmic improvement.\n\nIf (who knows?) you are interested in hacking on this in any way, do not\nhesitate to contact me or just say \"hi\" on IRC. I'd be interested in\ndiscussing or helping.\n\n## Why the name?\n\nIt is a reference to Dan Simmons' _Hyperion_ series of books, with the\nsuffix \"sym\" altered because, hey, we're doing _symbolic_ stuff around here!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-cube%2Fstimsym","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-cube%2Fstimsym","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-cube%2Fstimsym/lists"}