{"id":23143716,"url":"https://github.com/xieyuheng/logic-db","last_synced_at":"2025-07-28T11:07:15.054Z","repository":{"id":36803044,"uuid":"161491244","full_name":"xieyuheng/logic-db","owner":"xieyuheng","description":"Embedding a Prolog-like logic programming language in JavasScript and TypeScript.","archived":false,"fork":false,"pushed_at":"2023-07-11T01:01:51.000Z","size":563,"stargazers_count":18,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T02:53:18.810Z","etag":null,"topics":["logic-programming","prolog","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-12T13:19:28.000Z","updated_at":"2024-12-12T17:07:37.000Z","dependencies_parsed_at":"2023-01-17T04:56:43.159Z","dependency_job_id":null,"html_url":"https://github.com/xieyuheng/logic-db","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/xieyuheng/logic-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Flogic-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Flogic-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Flogic-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Flogic-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xieyuheng","download_url":"https://codeload.github.com/xieyuheng/logic-db/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuheng%2Flogic-db/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267505099,"owners_count":24098346,"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-07-28T02:00:09.689Z","response_time":68,"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":["logic-programming","prolog","typescript"],"created_at":"2024-12-17T15:14:05.349Z","updated_at":"2025-07-28T11:07:15.003Z","avatar_url":"https://github.com/xieyuheng.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LogicDB\n\nEmbedding a Prolog-like logic programming language in JavasScript and TypeScript.\n\n- Combining logic programming and database management.\n- Can declare relations between JSON documents.\n- Well typed relation in TypeScript.\n- Practical and simple API.\n\n## Install\n\n``` bash\nnpm i logic-db\n```\n\n## Usage\n\n``` typescript\nimport Logic, { v, ne, ty } from \"logic-db\"\n\n// NOTE Drinking Pairs -- example from \"Clause and Effect\"\n\nconst drinks = new Logic.Table({\n  name: \"drinks\",\n  schema: ty.object({\n    person: ty.string(),\n    alcohol: ty.string(),\n  }),\n})\n\ndrinks.i({ person: \"john\", alcohol: \"martini\" })\ndrinks.i({ person: \"mary\", alcohol: \"gin\" })\ndrinks.i({ person: \"susan\", alcohol: \"vodka\" })\ndrinks.i({ person: \"john\", alcohol: \"gin\" })\ndrinks.i({ person: \"fred\", alcohol: \"gin\" })\ndrinks.i({ person: \"fred\", alcohol: \"vodka\" })\n\nconst pair = new Logic.Table({\n  name: \"pair\",\n  schema: ty.object({\n    p1: ty.string(),\n    p2: ty.string(),\n    alcohol: ty.string(),\n  }),\n})\n\npair.i({ p1: v`p1`, p2: v`p2`, alcohol: v`alcohol` }, (v) =\u003e [\n  drinks.o({ person: v`p1`, alcohol: v`alcohol` }),\n  drinks.o({ person: v`p2`, alcohol: v`alcohol` }),\n  ne(v`p1`, v`p2`),\n])\n\nconsole.log(pair.query({ p1: v`x`, p2: \"mary\", alcohol: \"gin\" }))\nconsole.log(pair.query({ p1: v`x`, p2: v`y`, alcohol: \"gin\" }))\nconsole.log(pair.query({ p1: v`x`, p2: v`y`, alcohol: v`alcohol` }))\n```\n\n## Examples\n\n[**Clause and Effect**](src/examples/clause-and-effect)\n- By William F. Clocksin.\n\n[**Structure and Interpretation of Computer Programs (SICP)**](src/examples/sicp)\n- By Harold Abelson and Gerald Jay Sussman.\n- It has one section about logic programming:\n  - [sarabander-sicp](http://sarabander.github.io/sicp/html/4_002e4.xhtml#g_t4_002e4)\n  - [official](http://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-29.html#%_sec_4.4)\n\n[**The Power of Prolog**](src/examples/the-power-of-prolog)\n- [An excellent modern teaching of Prolog](https://www.metalevel.at/prolog), by Markus Triska.\n\n## API Docs\n\nTODO\n\n## Contributions\n\n\u003e Be polite, do not bring negative emotion to others.\n\n- [TODO.md](TODO.md)\n- [STYLE-GUIDE.md](STYLE-GUIDE.md)\n- [CODE-OF-CONDUCT.md](CODE-OF-CONDUCT.md)\n- When contributing, add yourself to [AUTHORS](AUTHORS)\n\n## License\n\n- [GPLv3](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieyuheng%2Flogic-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxieyuheng%2Flogic-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieyuheng%2Flogic-db/lists"}