Skip to content

Conversation

@duesee
Copy link
Contributor

@duesee duesee commented Jan 10, 2025

I think the title says everything. I'll add a bit of explanation inline.

PS: Thanks for this library! We are looking very closely into it, because it might help us a lot!

We can then ask it to solve 2 + 3 (and find the correct answer 5):

```
```text
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes it so that README.md is used in lib.rs as Rust doc (see below) to check the code. Rust assumes code blocks to be "rust" by default, so we need to say "text" here.

We can now ask the solver to prove statements within this universe, e.g. that "there exists an X
such that X + 2 = 3". This statement is indeed true for X = 1, and indeed, the solver will provide
this answer:
// We can now ask the solver to prove statements within this universe, e.g. that "there exists an X
Copy link
Contributor Author

@duesee duesee Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The easiest way to make cargo test pass was to merge these blocks. We are trading flexibility of writing for correctness, though.

//!
//!
// Test examples from README.md.
Copy link
Contributor Author

@duesee duesee Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "trick" allows to ensure the code in the README.md is checked during cargo test w/o using additional dependencies.

r.insert(ast::forall(|[p]| {
Rule::fact(is_natural, vec![ast::app(s, vec![p.into()])])
.when(is_natural, vec![p.into()])
Rule::fact(is_natural, vec![ast::app(s, vec![p.into()])]).when(is_natural, vec![p.into()])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to rustfmt.

// Obtain an iterator that allows us to exhaustively search the solution space:
let solutions = query_dfs(
&r,
&mut r,
Copy link
Contributor Author

@duesee duesee Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the following makes cargo test pass. Not sure if it's the best way to resolve.

Copy link
Owner

@fatho fatho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for your cleanup!

And glad to hear my little hobby project could be of use :)

@fatho fatho merged commit d19b318 into fatho:main Jan 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants