https://github.com/shouya/ckini
A miniKanren implementation in Elixir
https://github.com/shouya/ckini
elixir macro minikanren
Last synced: about 1 year ago
JSON representation
A miniKanren implementation in Elixir
- Host: GitHub
- URL: https://github.com/shouya/ckini
- Owner: shouya
- License: gpl-2.0
- Created: 2021-02-06T07:12:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-02T14:11:58.000Z (over 3 years ago)
- Last Synced: 2025-04-20T08:58:23.764Z (about 1 year ago)
- Topics: elixir, macro, minikanren
- Language: Elixir
- Homepage: https://hexdocs.pm/ckini
- Size: 173 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ckini
A miniKanren implementation in Elixir.
## Usage
``` elixir
defmodule Demo do
import Ckini
alias Ckini.Var
def readme_demo do
run {x, y, z} do
# simple goal
eq(y, 1)
# a conde goal
conde do
_ -> eq(y, 2)
_ -> eq(z, 3)
_ -> eq(x, 4)
end
# you can create logic variable with fresh
fresh t do
eq(x, [y, z, t, "hello"])
end
end
end
end
test "demo in README should work correctly" do
assert [{[1, 3, :_0, "hello"], 1, 3}] == Demo.readme_demo()
end
```
API available: `run/2`, `run/3`, `eq` (`===`), `neq` (`=/=`), `cond{e,i,a,u}`, `match{e,i,a,u}`, `all`, `project`, `succ`, `fail`, `symbolo`, `absento`, `copy_termo`, `anyo`, `onceo`.
Check out the https://github.com/shouya/ckini/blob/master/test/*_test.exs for more usage examples.
## Feature highlights
- arithmetic operators (See `Ckini.Arithmetic`)
- introduction of fresh variables via `cond{e,i,a,u}`
- pattern matching with `match{e,i,a,u}` macros
- inequality (`neq`) constraint
- symbolo constraint
- absento constraint
## References
- The Reasoned Schemer by Daniel P. Friedman, et al.
- Relational Programming in miniKanren by William E. Byrd