Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rust-lang/chalk
An implementation and definition of the Rust trait system using a PROLOG-like logic solver
https://github.com/rust-lang/chalk
Last synced: 29 days ago
JSON representation
An implementation and definition of the Rust trait system using a PROLOG-like logic solver
- Host: GitHub
- URL: https://github.com/rust-lang/chalk
- Owner: rust-lang
- License: other
- Created: 2015-07-26T10:13:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-07T00:26:38.000Z (7 months ago)
- Last Synced: 2024-05-18T20:36:23.495Z (6 months ago)
- Language: Rust
- Homepage: https://rust-lang.github.io/chalk/book/
- Size: 12.9 MB
- Stars: 1,770
- Watchers: 67
- Forks: 173
- Open Issues: 42
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - Chalk - solve)[:package:](https://crates.io/crates/chalk-derive)[:package:](https://crates.io/crates/chalk-engine)[:package:](https://crates.io/crates/chalk-ir)[:package:](https://crates.io/crates/chalk-macros)[:package:](https://crates.io/crates/chalk-recursive)[:package:](https://crates.io/crates/chalk-rust-ir):star: - implements the Rust trait system, based on Prolog-ish logic rules. (Projects / Verification)
README
[![Build Status](https://github.com/rust-lang/chalk/workflows/CI/badge.svg)](https://github.com/rust-lang/chalk/actions?workflow=CI)
[![Chalk Book](https://img.shields.io/badge/book-chalk-blue.svg)](https://rust-lang.github.io/chalk/book/)
[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://rust-lang.github.io/chalk/chalk/)# chalk
Chalk is a library that implements the Rust trait system, based on [Prolog-ish][Prolog] logic rules.
See the [Chalk book](https://rust-lang.github.io/chalk/book/) for more information.
## FAQ
**How does chalk relate to rustc?** The plan is to have rustc use the
`chalk-solve` crate (in this repo) to answer questions about Rust programs, for
example, "Does `Vec` implement `Debug`?". Internally, chalk converts
Rust-specific information into logic and uses a logic engine to find the answer
to the original query. For more details, see
[this explanation in the chalk book][chalk-lowering-details].**Where does the name come from?** `chalk` is named after [Chalkidiki], the area where [Aristotle] was
born. Since Prolog is a logic programming language, this seemed a
suitable reference.[Prolog]: https://en.wikipedia.org/wiki/Prolog
[Chalkidiki]: https://en.wikipedia.org/wiki/Chalkidiki
[Aristotle]: https://en.wikipedia.org/wiki/Aristotle
[chalk-lowering-details]: https://rust-lang.github.io/chalk/book/#chalk-works-by-converting-rust-goals-into-logical-inference-rules## Blog posts
[blog-posts]: #blog-posts
Here are some blog posts talking about chalk:- [Lowering Rust Traits to Logic](https://smallcultfollowing.com/babysteps/blog/2017/01/26/lowering-rust-traits-to-logic/)
- Explains the basic concepts at play
- [Unification in Chalk, Part 1](https://smallcultfollowing.com/babysteps/blog/2017/03/25/unification-in-chalk-part-1/)
- An introduction to unification
- [Unification in Chalk, Part 2](https://smallcultfollowing.com/babysteps/blog/2017/04/23/unification-in-chalk-part-2/)
- Extending the system for associated types
- [Negative reasoning in Chalk](https://aturon.github.io/blog/2017/04/24/negative-chalk/)
- How to prove that something is not true
- [Query structure in chalk](https://smallcultfollowing.com/babysteps/blog/2017/05/25/query-structure-in-chalk/)
- The basic chalk query structure, with pointers into the chalk implementation
- [Cyclic queries in chalk](https://smallcultfollowing.com/babysteps/blog/2017/09/12/tabling-handling-cyclic-queries-in-chalk/)
- Handling cyclic relations and enabling the implementation of implied bounds and other long-desired features in an elegant way## REPL
There is a repl mainly for debugging purposes which can be run by `cargo run`. Some basic examples are in [libstd.chalk](libstd.chalk):
```bash
$ cargo run
?- load libstd.chalk
?- Vec>: Clone
Unique; substitution [], lifetime constraints []
```## Contributing
If you'd like to contribute, consider joining the [Traits Working Group][working-group].
We hang out on the [rust-lang zulip][rust-lang-zulip] in the [#wg-traits][wg-traits-stream] stream.See [the contributing chapter][contributing] in the chalk book for more info.
[working-group]: https://rust-lang.github.io/compiler-team/working-groups/traits/
[rust-lang-zulip]:https://rust-lang.zulipchat.com
[wg-traits-stream]: https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits
[contributing]: https://rust-lang.github.io/chalk/book/contribution_guide.html