Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix code in README.md + (auto)align version in repl + minor improvements (typos, etc.) #36

Merged
merged 2 commits into from
Jan 20, 2025

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!

@@ -37,7 +37,7 @@ Loaded!

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.

@@ -147,6 +147,11 @@
//!
//!

// 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.

@@ -131,8 +139,7 @@ r.insert(Rule::fact(is_natural, vec![z.into()]));
// Define the rule `is_natural(s(P)) :- is_natural(P)`, i.e. that
// the successor of P is a natural number if P is also a natural number.
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