Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/terohuttunen/proto-vulcan
A relational logic programming language embedded in Rust.
https://github.com/terohuttunen/proto-vulcan
logic-programming rust
Last synced: 3 months ago
JSON representation
A relational logic programming language embedded in Rust.
- Host: GitHub
- URL: https://github.com/terohuttunen/proto-vulcan
- Owner: terohuttunen
- License: other
- Created: 2020-09-04T07:52:56.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-17T10:25:38.000Z (over 2 years ago)
- Last Synced: 2024-05-22T22:30:53.359Z (6 months ago)
- Topics: logic-programming, rust
- Language: Rust
- Homepage:
- Size: 614 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - proto-vulcan - vulcan)[:package:](https://crates.io/crates/proto-vulcan-macros) - miniKanren-family relational logic programming language. (Programming Language / Libraries)
README
# proto-vulcan
A relational logic programming language embedded in Rust. It started as a yet another
[`miniKanren`](http://minikanren.org), but has already evolved into its own language with miniKanren at its core.In addition to core miniKanren language, proto-vulcan currently provides support for:
* miniKanren-like breadth-first and Prolog-like depth-first search.
* Compound types ([Example](examples/tree-nodes.rs))
* Disequality constraints CLP(Tree)
* Finite-domain constraints CLP(FD)
* Various operators: anyo, conda, condu, onceo, project
* Pattern matching: match, matche, matcha, matchu
* Writing goals in Rust embedded inline within proto-vulcan
* User extension interfaceThe language is embedded into Rust with macros which parse the language syntax and convert it
into Rust. The language looks a lot like Rust, but isn't. For example, fresh variables are
presented with Rust closure syntax, and pattern matching looks like Rust match.# Example
```rust
extern crate proto_vulcan;
use proto_vulcan::prelude::*;fn main() {
let query = proto_vulcan_query!(|q| {
conde {
q == 1,
q == 2,
q == 3,
}
});for result in query.run() {
println!("q = {}", result.q);
}
}
```
The example program produces three solutions:
```text
q = 1
q = 2
q = 3
```## Embedding in Rust
To embed proto-vulcan in Rust, four macros are used: `proto_vulcan!`, `proto_vulcan_closure!`,
`proto_vulcan_query!`, and `lterm!`.* `proto_vulcan!()` declares a Proto-vulcan goal, and returns a Rust
variable of type `Goal`.
* `proto_vulcan_closure!()` declares a Proto-vulcan goal, and returns a Rust
variable of type `Goal`. The goal expression is evaluated lazily when the goal
is evaluated. The closure takes ownership of all variables referenced within the closure.
* `proto_vulcan_query!(|a, b, c| { })` defines a Proto-vulcan query with query-variables
`a`, `b` and `c`. The returned value is a `Query`-struct, that when `run`, produces an
iterator that can be used to iterate over valid solutions to the logic program. The iterator
returns a struct with fields named after the query variables.
* `lterm!()` declares a logic tree-term in Rust code, which can be passed to
proto-vulcan program within proto_vulcan! or proto_vulcan_query!, or compared with results.## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or )
* MIT license
([LICENSE-MIT](LICENSE-MIT) or )at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.