{"id":15629461,"url":"https://github.com/mdiep/logician","last_synced_at":"2025-07-03T13:35:19.538Z","repository":{"id":66404836,"uuid":"67143428","full_name":"mdiep/Logician","owner":"mdiep","description":"Logic programming in Swift","archived":false,"fork":false,"pushed_at":"2020-05-17T07:04:35.000Z","size":89,"stargazers_count":197,"open_issues_count":6,"forks_count":10,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-06-27T18:56:14.415Z","etag":null,"topics":["constraints","kanren","logic-programming","solver","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/mdiep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-09-01T15:27:27.000Z","updated_at":"2025-06-05T07:45:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"e529e0b4-28e3-4a0f-9804-4b3ec011c542","html_url":"https://github.com/mdiep/Logician","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mdiep/Logician","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdiep%2FLogician","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdiep%2FLogician/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdiep%2FLogician/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdiep%2FLogician/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdiep","download_url":"https://codeload.github.com/mdiep/Logician/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdiep%2FLogician/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263335795,"owners_count":23450931,"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":["constraints","kanren","logic-programming","solver","swift"],"created_at":"2024-10-03T10:27:17.194Z","updated_at":"2025-07-03T13:35:19.513Z","avatar_url":"https://github.com/mdiep.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logician\n[![SPM Compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/)\n\nLogic programming in Swift\n\n## Logic Programming\nLogic programming is a _declarative_ style of programming that uses _constraints_ to describe problems. Instead of writing a solution to the problem, you describe the characteristics of the solution and let the computer solve it for you.\n\nHere are some example problems that are a good fit for logic programming:\n\n - Coloring a map/graph so adjacent regions don’t use the same color\n - Resolving dependencies in a package manager\n - Solving puzzles like [sudoku][], [n-queens][], etc.\n\n[sudoku]: Playgrounds/Sudoku.playground/Contents.swift\n[n-queens]: Playgrounds/N%20Queens.playground/Contents.swift\n\nDifferent logic programming implementations contain different types of constraints.\n\n## Installation\nLogician is compatible with Swift Package Manager. Add the following line into your `Package.swift` dependencies:\n```.package(url: \"https://github.com/mdiep/Logician.git\", .branch(\"master\")```\n\n## Using Logician\nIn order to use Logician, you need to be familiar with 3 concepts:\n\n1. `Variable`\n\n    A variable describes an unknown value in a logic problem, much like variables in algebra. Logician variables are generic over a value type.\n\n1. `Goal`\n\n    A goal represents some condition that should be true in the solved state. It’s currently implemented as a `(State) -\u003e Generator\u003cState\u003e`. A goal can diverge and return multiple possible states or terminate, signaling that a constraint was violated.\n\n    Logician provides a number of built-in goals—like `==`, `!=`, `distinct`, `\u0026\u0026`, `||`, `all`, and `any`—that should provide a good start in most cases.\n\n1. `solve`\n\n    This function is the interface to Logician’s solver. Its block takes `Variable`s to solve as input and returns `Goal`s to solve for.\n\nLogician is still in its early stages. Its current implementation is based on the miniKanren approach of using functions that return generators. This is likely to change in the future in order to enable optimizations.\n\n## Examples\nLogician includes playgrounds with a [sudoku][] solver and an [n-queens][] solver that demonstrate usage of the library.\n\n## License\nLogician is available under the [MIT License](LICENSE.md)\n\n## Learn More\nThe following are good resources for learning more about logic programming:\n\n- [Logic Programming in Swift](http://matt.diephouse.com/2016/12/logic-programming-in-swift/)\n\n    An explanation of how logic programming works in Swift.\n\n- [μKanren: A Minimal Functional Core for Relational Programming (pdf)](http://webyrd.net/scheme-2013/papers/HemannMuKanren2013.pdf) by Jason Hemann and Daniel P. Friedman\n\n    This paper explores what forms the minimal logic programming language in Scheme. It strips away the complexity of more capable solvers to expose the core idea.\n\n- [Kanren.swift](https://github.com/mdiep/Kanren.swift)\n\n    Swift playgrounds with implementations of various Kanrens.\n\n- [Hello, declarative world](http://codon.com/hello-declarative-world) by **[@tomstuart](https://github.com/tomstuart/)**\n\n    A brief explanation of logic programming and a minimal language in Ruby.\n\n- [The Reasoned Schemer](https://www.amazon.com/gp/product/0262562146/ref=as_li_tl?ie=UTF8\u0026camp=1789\u0026creative=9325\u0026creativeASIN=0262562146\u0026linkCode=as2\u0026tag=mattdiephouse-20\u0026linkId=40c4bb4569bbbfdf6c3a99f4e66490f4\n) by Daniel P. Friedman, William E. Byrd and Oleg Kiselyov\n\n    An unorthodox book, in the style of _The Little Schemer_, that has pages of exercises that demonstrate how a kanren-style logic programming works.\n\n- [Constraint Processing](https://www.amazon.com/gp/product/1558608907/ref=as_li_tl?ie=UTF8\u0026camp=1789\u0026creative=9325\u0026creativeASIN=1558608907\u0026linkCode=as2\u0026tag=mattdiephouse-20\u0026linkId=d518f0b1d4ccb6a9a8c6d772cec8c8ec) by Rina Dechter\n\n    An in-depth look at constraints, algorithms, and optimizations. This book explains all you need to know to write a complex solver.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdiep%2Flogician","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdiep%2Flogician","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdiep%2Flogician/lists"}