{"id":22195249,"url":"https://github.com/sano-jin/lambda-gt-alpha","last_synced_at":"2025-03-24T21:33:26.365Z","repository":{"id":55800809,"uuid":"523233592","full_name":"sano-jin/lambda-gt-alpha","owner":"sano-jin","description":"A reference interpreter of λGT","archived":false,"fork":false,"pushed_at":"2023-08-12T06:18:33.000Z","size":528,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T01:44:05.518Z","etag":null,"topics":["interpreter","ocaml","programming-language"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sano-jin.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}},"created_at":"2022-08-10T06:51:03.000Z","updated_at":"2024-12-05T17:58:32.000Z","dependencies_parsed_at":"2023-02-10T14:30:55.289Z","dependency_job_id":null,"html_url":"https://github.com/sano-jin/lambda-gt-alpha","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sano-jin%2Flambda-gt-alpha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sano-jin%2Flambda-gt-alpha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sano-jin%2Flambda-gt-alpha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sano-jin%2Flambda-gt-alpha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sano-jin","download_url":"https://codeload.github.com/sano-jin/lambda-gt-alpha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245355631,"owners_count":20601764,"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","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":["interpreter","ocaml","programming-language"],"created_at":"2024-12-02T13:17:27.821Z","updated_at":"2025-03-24T21:33:26.314Z","avatar_url":"https://github.com/sano-jin.png","language":"OCaml","readme":"# A Reference Interpreter of the Lambda GT Language\n\n[![License](https://img.shields.io/badge/license-MIT-yellow?style=flat-square)](#license)\n[![Twitter](https://img.shields.io/badge/twitter-%40sano_jn-blue?style=flat-square)](https://twitter.com/sano_jn)\n\nWe designed a new purely functional language, λGT,\nthat handles graphs as immutable, first-class data structures with\na pattern matching mechanism based on graph transformation.\nHere, we implemented a reference interpreter of the language.\nThe interpreter is written in only about 500 lines of OCaml code.\n\nWe also have [a visualiser that runs on a browser](https://sano-jin.github.io/lambda-gt-playground/).\n\n## Getting Started\n\n### Prerequisites\n\n- [opam](https://opam.ocaml.org/)\n\n### Installation\n\n```bash\ngit clone https://github.com/sano-jin/lambda-gt-alpha.git\ncd lambda-gt-alpha\nopam install .\ndune build\n```\n\n## Usage\n\n```bash\n./run example/dlist.lgt\n```\n\nwhich will result in `{_Y \u003e\u003c _X}`.\n\nSee [/example](example) for more examples.\n\n## Syntax\n\n```\nExpression     e ::= { T }                                     // Graph\n                  |  e1 e2                                     // Application\n                  |  case e1 of { T } -\u003e e2 | otherwise -\u003e e3  // Case Expression\n                  |  e1 + e2\n                  |  e1 * e2\n                  |  e1 - e2\n\n                  // Definition (n \u003e= 0)\n                  |  let x[_X1, ..., _Xm] x_1[_X1_1, ..., _X1_m] ... x_n[_Xn_m, ..., _Xn_m] = e1 in e2\n\n                  // Recursive Definition (n \u003e= 1)\n                  |  let rec x[_X1, ..., _Xm] x_1[_X1_1, ..., _X1_m] ... x_n[_Xn_m, ..., _Xn_m] = e1 in e2\n\n\nGraph Template T ::= v (_X1, ..., _Xn)                      // Atom\n                  |  _X \u003e\u003c _Y                               // Fusion\n                  |  x[_X1, ..., _Xn]                       // Graph Context\n                  |  (T, T)                                 // Molecule\n                  |  nu _X. T                               // Link Creation\n\nAtom Name      v ::= Constr                                 // Constructor Name\n                  |  (\\x[_X1, ..., _Xn]. e)                 // Lambda Abstraction\n```\n\nFor the semantics, please see\n\u003chttps://doi.org/10.2197/ipsjjip.31.112\u003e.\n\nWe have enabled logging.\n`{Log} exp` evaluates `exp`, prints the value, and returns the value; i.e., an identity function.\n\n## Development\n\n![dependency graph](docs/dependency.svg)\n\nPlease give me issues or pull requests if you find any bugs or solutions for them.\n\nWe aim to build the simplest implementation.\nThus, we may not accept a request for an enhancement.\nHowever, we appreciate it because it will be helpful in the design and implementation\nof the full-fledged language based on this PoC.\n\n### Testing\n\n```bash\ndune runtest\n```\n\nSee [test/test.ml](test/test.ml) for more information.\n\n- Configure tests with the file.\n\n### Directory Structures\n\n[/bin](bin):\nentry point\n\n| File                   | Description                          |\n| ---------------------- | ------------------------------------ |\n| [main.ml](bin/main.ml) | Read a file and execute the program. |\n\n[/eval](eval):\nevaluator\n\n| File                                  | Description                                                                                    |\n| ------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| [syntax.ml](eval/syntax.ml)           | Syntax of atoms as an list.                                                                    |\n| [preprocess.ml](eval/preprocess.ml)   | Transform an AST graph to a list of atoms. Alpha convert link names.                           |\n| [eval.ml](eval/eval.ml)               | The evaluator.                                                                                 |\n| [match.ml](eval/match.ml)             | Matches atoms and graph contexts and returns the obtained graph substitutions.                 |\n| [match_atoms.ml](eval/match_atoms.ml) | Matches atoms and returns the link mappings and the rest graph.                                |\n| [postprocess.ml](eval/postprocess.ml) | Transform the link names in the rest graphs and supply fusions according to the link mappings. |\n| [match_ctxs.ml](eval/match.ml)        | Matches graph contexts and returns the obtained graph substitutions.                           |\n| [pushout.ml](eval/pushout.ml)         | Substitute graph contexts with the given graph substitution (rewriting after matching).        |\n\n[/parser](parser):\nlexical/syntactical analyzer\n\n| File                            | Description                   |\n| ------------------------------- | ----------------------------- |\n| [syntax.ml](parser/syntax.ml)   | AST definition                |\n| [lexer.mll](parser/lexer.mll)   | Defines a token for lexing    |\n| [parser.mly](parser/parser.mly) | Defines a grammar for parsing |\n| [parse.ml](parser/parse.ml)     | Parser                        |\n\n## Contact\n\nPlease feel free to contact me (ask me any questions about this).\n\n- [twitter@sano_jn](https://twitter.com/sano_jn)\n- [homepage](https://www.ueda.info.waseda.ac.jp/~sano/)\n\n## License\n\nMIT\n\n[repo]: https://github.com/sano-jin/lambda-gt-alpha/tree/icgt2023/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsano-jin%2Flambda-gt-alpha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsano-jin%2Flambda-gt-alpha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsano-jin%2Flambda-gt-alpha/lists"}