{"id":13610737,"url":"https://github.com/codedot/lambda","last_synced_at":"2025-04-13T01:32:34.881Z","repository":{"id":57096494,"uuid":"39725405","full_name":"codedot/lambda","owner":"codedot","description":"Macro Lambda Calculus","archived":false,"fork":false,"pushed_at":"2019-03-23T17:37:22.000Z","size":530,"stargazers_count":43,"open_issues_count":3,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-25T03:42:58.443Z","etag":null,"topics":["interaction-nets","lambda-calculus"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@alexo/lambda","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codedot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-26T12:53:00.000Z","updated_at":"2024-04-18T12:50:19.000Z","dependencies_parsed_at":"2022-08-20T16:51:06.941Z","dependency_job_id":null,"html_url":"https://github.com/codedot/lambda","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/codedot%2Flambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedot%2Flambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedot%2Flambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedot%2Flambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codedot","download_url":"https://codeload.github.com/codedot/lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223558282,"owners_count":17165102,"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":["interaction-nets","lambda-calculus"],"created_at":"2024-08-01T19:01:47.521Z","updated_at":"2024-11-07T17:30:27.162Z","avatar_url":"https://github.com/codedot.png","language":"JavaScript","readme":"This package implements the lambda calculus using\ninteraction nets, providing CLI and API.\n\nIts browserified version is available as [an online demo][1].\n\n[1]: https://codedot.github.io/lambda/\n\n# Algorithms\n\nThe following encodings of the lambda calculus are included:\n\n* `abstract`, an impure solution to the problem of matching fans\nin [Lamping's abstract algorithm][7],\ndescribed in [arXiv:1710.07516][6],\nthis is the default algorithm;\n\n* `closed`, the approach of [arXiv:1304.2290][2] applied to\n[_An Interaction Net Implementation of Closed Reduction_][3]\nby Ian Mackie;\n\n* `optimal`, an implementation of\n[_Lambdascope_][5] by Vincent van Oostrom et al;\n\n* `standard`, an implementation of optimal reduction as in\n[_The Optimal Implementation of Functional Programming Languages_][8],\npp. 40-41.\n\nThe embedded read-back mechanism is described\nin Section 7 of [10.4204/EPTCS.225.7][4].\n\n[2]: https://arxiv.org/abs/1304.2290\n[3]: http://dx.doi.org/10.1007/978-3-642-24452-0_3\n[4]: http://dx.doi.org/10.4204/EPTCS.225.7\n[5]: http://www.phil.uu.nl/~oostrom/publication/pdf/lambdascope.pdf\n[6]: https://arxiv.org/abs/1710.07516\n[7]: https://doi.org/10.1145/96709.96711\n[8]: https://books.google.com/books?id=Bod5HbPh-WwC\n\n# Benchmarks\n\nThe following is output of the `test.sh` script provided in the package:\n\n```\nSAMPLE          ABSTRACT         CLOSED        OPTIMAL       STANDARD\ncounter              N/A         162/25         582/14        2322/14\nw2eta               37/7         137/16          207/7          374/7\n1021              199/55     11871/1088     1599877/55     4307803/55\n22210i            494/68       2539/254       58603/68            N/A\n3222i            1206/50       8638/819      804530/50            N/A\n1022i            4317/69     33369/3139            N/A            N/A\n2222101   2621862/327818            N/A            N/A            N/A\nfacty6nt        1112/210     80562/2436    2790152/210    3013433/210\nfacty9i         1629/287 3746232/130949            N/A            N/A\n33-fact4        3770/704      16114/912      80708/704     234075/704\nfibo16nt      24931/3042    134135/5673   5462375/3042   8959455/3042\nfact100i      28502/3752   121854/10565            N/A            N/A\n35-fact5     72944/13480   805218/16206  4702711/13480            N/A\nfibo20i       93534/6863   536843/24626   1961508/6863   4023117/6863\nfact1knt 6215039/1353692            N/A            N/A            N/A\n```\n\n`T/B` should be read as total of `T` interactions,\nof which `B` were β-reductions.\n\n# CLI\n\nThis package provides the `lambda` command with the following interface:\n\n```\nUsage: lambda [options] (\u003cterm\u003e | -f \u003cfile\u003e)\n\nOptions:\n  --algo, -a     Select algorithm         [string]\n  --debug, -d    Evaluate step by step   [boolean]\n  --exec, -e     Process m4(1) macros    [boolean]\n  --file, -f     Read term from file     [boolean]\n  --inet, -i     Show interaction net    [boolean]\n  --limit, -l    Limit interactions       [number]\n  --macros, -m   Read macros from file    [string]\n  --perf, -p     Print benchmarks        [boolean]\n  --stats, -s    Save statistics to file  [string]\n  --term, -t     Output expanded term    [boolean]\n  --help, -h     Show help               [boolean]\n  --version, -v  Show version number     [boolean]\n\n```\n\n# Combinators\n\nCLI predefines a number of commonly used combinators:\n\n```\n# Common combinators\nI = x: x;\nK = x, y: x;\nS = x, y, z: x z (y z);\nY = (a: a a) (a, f: f (a a f));\n\n# Booleans\nT = K;\nF = K I;\nNot = p, a, b: p b a;\nAnd = p, q: p q F;\nOr = p, q: p T q;\nXor = p, q: p Not I q;\n\n# Pairs/lists\n[] = K T;\n[]? = l: l (h, t: F);\nCons = h, t, x: x h t;\nHead = l: l T;\nTail = l: l F;\n\n# Church arithmetic\n+1 = n, f, x: f (n f x);\n+ = m, n, f, x: m f (n f x);\n* = m, n, f: m (n f);\n^ = m, n: n m;\n-1 = n, f, x: n (g, h: h (g f)) (K x) I;\n- = m, n: n -1 m;\n0? = n: n (K F) T;\n\n# Church numerals\n0 = f, x: x;\n1 = f, x: f x;\n2 = +1 1;\n3 = +1 2;\n4 = ^ 2 2;\n5 = + 2 3;\n6 = * 2 3;\n7 = +1 6;\n8 = ^ 2 3;\n9 = ^ 3 2;\n10 = * 2 5;\n16 = ^ 2 4;\n20 = * 2 10;\n30 = * 3 10;\n32 = ^ 2 5;\n64 = ^ 2 6;\n100 = ^ 10 2;\n128 = ^ 2 7;\n256 = ^ 2 8;\n512 = ^ 2 9;\n1k = ^ 10 3;\n1ki = ^ 2 10;\n1m = ^ 10 6;\n1mi = ^ 2 20;\n1g = ^ 10 9;\n1gi = ^ 2 30;\n\n# Recursive functions\nFactY = Y (f, n: (0? n) 1 (* (f (-1 n)) n));\nFact = n: n (f, i: * (f (+1 i)) i) (K 1) 1;\nFibo = n: n (f, a, b: f (+ a b) a) F 1 0;\n```\n\n# API\n\n`require(\"@alexo/lambda\")` returns a function of a lambda term defined\nin a variant of the lambda calculus called Macro Lambda Calculus (MLC)\nthat allows macro definitions in order to input complex expressions.\nThe last term in the input is the term whose normal form is to be found.\n\nFor developing and testing purposes, the package also exports\ntwo additional functions `.prepare(term)` and `.debug()`.\nThe `.debug()` function applies a single reduction step to\nthe interaction net compiled by the previous `.prepare()`\ncall and returns a human-readable string representation of\nthe current interaction net state.\n\n# Grammar\n\nInput consists of an optional list of macro definitions and a term:\n\n```\n%token NAME\n\n%%\n\ntext : defs term\n     ;\ndefs : /* empty */\n     | defs NAME '=' term ';'\n     ;\nterm : appl\n     | abst\n     ;\nabst : NAME ',' abst\n     | NAME ':' term\n     ;\nappl :      atom\n     | appl atom\n     ;\natom : '(' term ')'\n     |     NAME\n     ;\n```\n\n# License\n\nCopyright (c) 2017 Anton Salikhmetov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodedot%2Flambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodedot%2Flambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodedot%2Flambda/lists"}