{"id":31423985,"url":"https://github.com/xieyuheng/inet-forth","last_synced_at":"2025-09-30T03:10:47.994Z","repository":{"id":269904597,"uuid":"883854885","full_name":"xieyuheng/inet-forth","owner":"xieyuheng","description":"An implementation of interaction nets as a forth-like language.","archived":false,"fork":false,"pushed_at":"2025-08-08T11:00:54.000Z","size":4424,"stargazers_count":38,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-26T17:39:45.707Z","etag":null,"topics":["computation-model","concatenative","forth","forth-like","graph-processing","inet","interaction-nets","interpreter","language-design","linear-logic","scalable-c"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xieyuheng.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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-05T17:32:19.000Z","updated_at":"2025-09-10T01:37:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef7c668d-4ec7-41a6-b62e-5113fae1c34f","html_url":"https://github.com/xieyuheng/inet-forth","commit_stats":null,"previous_names":["cicada-lang/inet-forth","xieyuheng/inet-forth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xieyuheng/inet-forth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Finet-forth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Finet-forth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Finet-forth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Finet-forth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xieyuheng","download_url":"https://codeload.github.com/xieyuheng/inet-forth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Finet-forth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277623017,"owners_count":25849156,"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-09-30T02:00:09.208Z","response_time":75,"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":["computation-model","concatenative","forth","forth-like","graph-processing","inet","interaction-nets","interpreter","language-design","linear-logic","scalable-c"],"created_at":"2025-09-30T03:10:42.943Z","updated_at":"2025-09-30T03:10:47.985Z","avatar_url":"https://github.com/xieyuheng.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# inet-forth\n\nMoore's Law is broken.\n\n![Figure 6.11: MIPS/Clock-Frequency Trend for Intel CPUs](assets/images/mips-clock-frequency-trend-for-intel-cpus.png)\n\n(Figure 6.11: MIPS/Clock-Frequency Trend for Intel CPUs, from [\"Is Parallel Programming Hard, And, If So, What Can You Do About It?\"](https://www.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html), by Paul E. McKenney)\n\nThe exponential increase in single-threaded performance halted in about 2003.\nTherefore, increasing performance will increasingly require parallelism.\n\nHow do we program a machine with many cores?\n\nOne possible solution is the graph-based computation model\n-- [interaction nets](https://en.wikipedia.org/wiki/Interaction_nets) --\nwhere a program in this computation model can automatically\nmake use of any number cores in the machine.\n\nThis project is an implementation of interaction nets\nas a [forth-like language](https://en.wikipedia.org/wiki/forth_(programming_language)).\n\n## Syntax\n\n```xml\ndefine-node \u003cname\u003e \u003cinput-ports\u003e -- \u003coutput-ports\u003e end\ndefine-rule \u003cname\u003e \u003cname\u003e \u003cfunction-body\u003e end\ndefine \u003cname\u003e \u003cfunction-body\u003e end\n```\n\n## Examples\n\n### Natural Number\n\nDefine three nodes `(zero)`, `(add1)` and `(add)`:\n\n```\ndefine-node zero -- value! end\ndefine-node add1 prev -- value! end\ndefine-node add target! addend -- result end\n```\n\n```\nvalue!   value!        value\n  |        |             |\n(zero)   (add1)        (add)\n           |           /   \\\n          prev    target!  addend\n```\n\nThe rule between `(add1)` and `(add)`:\n\n```\ndefine-rule add1 add\n  ( addend result ) ( prev )\n  prev addend add\n  add1 result connect\nend\n```\n\n```\n     value             value            value\n       |                 |                |\n     (add)     =\u003e                =\u003e     (add1)\n     /   \\                 \\              |\n(add1)   addend            addend       (add)\n   |                 |                  /   \\\n prev              prev              prev   addend\n```\n\nTo apply this rule is to disconnect and delete `(add1)` and `(add)` and reconnect newly exposed wires:\n\n- `( addend result )` save the wires that were connected to `(add)` to local variable `addend` and `result`.\n- `( prev )` save the wire that was connected to `(add1)` to local variable `prev`.\n- `prev` push local variable to the stack.\n- `addend` push local variable to the stack.\n- `add` take two arguments from the stack and create a new `(add)` node.\n- `add1` take one argument from the stack and create a new `(add1)` node.\n- `result` push local variable to the stack.\n- `connect` take two wires from the stack and connect them.\n\nThe rule between `(zero)` and `(add)`:\n\n```\ndefine-rule zero add\n  ( addend result )\n  addend result connect\nend\n```\n\n```\n     value          value         value\n       |              |             |\n     (add)     =\u003e             =\u003e   |\n     /   \\              \\            \\\n(zero)   addend        addend       addend\n```\n\nTo apply this rule is to disconnect and delete `(zero)` and `(add)` and reconnect newly exposed wires:\n\n- `( addend result )` save the wires that were connected to `(add)` to local variable `addend` and `result`.\n- `addend` push local variable to the stack.\n- `result` push local variable to the stack.\n- `connect` take two wires from the stack and connect them.\n\nExample interaction:\n\n```\n       |                   |                   |              |\n     (add)               (add1)              (add1)         (add1)\n     /   \\                 |                   |              |\n(add1)    (add1)         (add)               (add1)         (add1)\n   |        |    =\u003e      /   \\       =\u003e        |        =\u003e    |\n(add1)    (add1)    (add1)    (add1)         (add)          (add1)\n   |        |          |        |            /   \\            |\n(zero)    (zero)    (zero)    (add1)    (zero)   (add1)     (add1)\n                                |                  |          |\n                              (zero)             (add1)     (zero)\n                                                   |\n                                                 (zero)\n```\n\nThe whole program with test:\n\n```\ndefine-node zero -- value! end\ndefine-node add1 prev -- value! end\ndefine-node add target! addend -- result end\n\ndefine-rule zero add\n  ( addend result )\n  addend result connect\nend\n\ndefine-rule add1 add\n  ( addend result ) ( prev )\n  prev addend add\n  add1 result connect\nend\n\ndefine two\n  zero add1 add1\nend\n\ntwo two add\n\ninspect-run\n```\n\n### List\n\n```\ndefine-node null -- value! end\ndefine-node cons tail head -- value! end\ndefine-node append target! rest -- result end\n\ndefine-rule null append\n  ( rest result )\n  rest result connect\nend\n\ndefine-rule cons append\n  ( rest result ) ( tail head )\n  tail rest append\n  head cons result connect\nend\n\ndefine-node sole -- value! end\n\nnull sole cons sole cons sole cons\nnull sole cons sole cons sole cons\nappend\n\ninspect-run\n```\n\n### More\n\nFor more examples, please see the [examples/](examples/) directory.\n\n## Docs\n\n- [Programming with Interaction Nets](docs/articles/programming-with-interaction-nets.md)\n- [反应网编程](docs/articles/反应网编程.md)\n\n## Community\n\n- [Discord / concatenative #inet](https://discord.gg/EcUfwRkbdx)\n\n## Install\n\nCompile:\n\n```\ngit clone https://github.com/xieyuheng/inet-forth\ncd inet-forth\nmake -j\nmake test\n```\n\nThe compiled binary `./bin/inet-forth` is the command-line program.\n\n```sh\n$ ./bin/inet-forth\ninet-forth 0.1.0\n\ncommands:\n  run -- run files\n  info -- print system info\n  test-self -- run self test\n  test-packages -- run test for modules\n  version -- print version\n  help -- print help message\n```\n\nFor examples:\n\n```sh\n./bin/inet-forth run examples/readme/nat.fth\n```\n\n## Development\n\n```shell\nmake -j       # compile src/ files to lib/ and bin/\nmake run      # compile and run the command-line program\nmake test     # compile and run test\nmake clean    # clean up compiled files\n```\n\n## Implementations\n\n- [inet-cute](https://github.com/xieyuheng/inet-cute)\n- [inet-js](https://github.com/xieyuheng/inet-js)\n- [inet-forth](https://github.com/xieyuheng/inet-forth)\n- [inet-lisp-st](https://github.com/xieyuheng/inet-lisp-st)\n- [inet-lisp](https://github.com/xieyuheng/inet-lisp)\n\n## References\n\n**Papers**:\n\n- [1990-interaction-nets](./docs/references/1990-interaction-nets.pdf)\n- [1997-interaction-combinators](./docs/references/1997-interaction-combinators.pdf)\n\n**Books**:\n\n- [scalable c](https://github.com/booksbyus/scalable-c)\n\n**Languages**:\n\n- [forth](https://en.wikipedia.org/wiki/Forth_(programming_language))\n\n## License\n\n[GPLv3](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieyuheng%2Finet-forth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxieyuheng%2Finet-forth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieyuheng%2Finet-forth/lists"}