Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

chalk

> 编程语言
Open source

An implementation and definition of the Rust trait system using a PROLOG-like logic solver

2.0K stars0 likes0 views
WebsiteGitHub

About

An implementation and definition of the Rust trait system using a PROLOG-like logic solver

[!WARNING] The Chalk project has been sunset in favor of the newer next-generation trait solver. See the following posts for more details on the development of the new trait solver:

  • https://blog.rust-lang.org/inside-rust/2023/07/17/trait-system-refactor-initiative/
  • https://blog.rust-lang.org/inside-rust/2023/12/22/trait-system-refactor-initiative/
  • https://blog.rust-lang.org/2024/06/26/types-team-update/
  • https://blog.rust-lang.org/inside-rust/2024/12/04/trait-system-refactor-initiative/

chalk

Chalk is a library that implements the Rust trait system, based on Prolog-ish logic rules.

See the Chalk book for more information.

FAQ

How does chalk relate to rustc? The plan was to have rustc use the chalk-solve crate (in this repo) to answer questions about Rust programs, for example, "Does Vec<u32> 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.

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.

Blog posts

Here are some blog posts talking about chalk:

  • Lowering Rust Traits to Logic
    • Explains the basic concepts at play
  • Unification in Chalk, Part 1
    • An introduction to unification
  • Unification in Chalk, Part 2
    • Extending the system for associated types
  • Negative reasoning in Chalk
    • How to prove that something is not true
  • Query structure in chalk
    • The basic chalk query structure, with pointers into the chalk implementation
  • 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:

$ cargo run
?- load libstd.chalk
?- Vec<Box<i32>>: Clone
Unique; substitution [], lifetime constraints []

Contributing

If you'd like to contribute, consider joining the Traits Working Group. We hang out on the rust-lang zulip in the #wg-traits stream.

See the contributing chapter in the chalk book for more info.

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •Lowering Rust Traits to Logic
  • •Explains the basic concepts at play
  • •Unification in Chalk, Part 1
  • •An introduction to unification
  • •Unification in Chalk, Part 2
  • •Extending the system for associated types
  • •Negative reasoning in Chalk
  • •How to prove that something is not true
  • •Query structure in chalk
  • •The basic chalk query structure, with pointers into the chalk implementation

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言