Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kulibali/rslogic
A logic programming library (inspired by uKanren) in Rust.
https://github.com/kulibali/rslogic
Last synced: 2 months ago
JSON representation
A logic programming library (inspired by uKanren) in Rust.
- Host: GitHub
- URL: https://github.com/kulibali/rslogic
- Owner: chalcolith
- License: mit
- Created: 2016-01-31T05:12:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-06T06:37:29.000Z (over 8 years ago)
- Last Synced: 2024-05-22T22:31:42.801Z (6 months ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - rslogic - logic programming framework for Rust inspired by µKanren. (Kanren / Libraries)
README
# rslogic ![Build Status](https://travis-ci.org/kulibali/rslogic.svg?branch=master)
**[rslogic](https://github.com/kulibali/rslogic)** is a logic programming framework
for Rust inspired by [µKanren](https://github.com/jasonhemann/microKanren).[API Documentation](https://kulibali.github.io/rslogic)
A logical statement is built from **variables**, **states**, and **goals**.
Create an initial state, then obtain some variables (and resulting state) from it.
Construct a goal consisting of variable bindings, logical operations (AND, OR), or
predicates. Then evaluate the goal using the state resulting from making the variables.
Evaluating a goal returns all possible solutions to the statement, in the form of
a number of states containing variable bindings.```
use rslogic::state;
use rslogic::state::{Unif, State, PossibleStates};
use rslogic::goal;
use rslogic::goal::{Goal, fail, unify_val, unify_vars, conj, disj, pred};let s = state::State::::empty();
let (v1, s) = s.make_var();
let (v2, s) = s.make_var();let n = 123;
let g = goal::conj(goal::unify_vars(&v1, &v2), goal::unify_val(&v2, n));let results = g.eval(&s);
assert_eq!(results.len(), 1);
let bound_value = results[0].get(&v1).unwrap();
assert_eq!(bound_value, &n);
```This example creates two variables, `v1` and `v2`, and then assembles a logical expression
equivalent to `(v1 = v2) && (v2 = 123)`. When evaluated, the resulting state binds `123` to
both `v1` and `v2`.