Skip to content

Commit 2c0721b

Browse files
committed
fix nits
1 parent e57cf8e commit 2c0721b

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

book/src/recursive.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ fn(Goal) -> Solution
1010
where the Goal is some [canonical goal](./canonical_queries.md) and
1111
the Solution is a result like:
1212

13-
* Provable(S): meaning the goal is provable and it is provably exactly (and only
14-
for the substitution S. S is a set of values for the inference variables that
15-
appear in the goal. So if we had a goal like `Vec<?X>: Foo`, and we returned
16-
`Provable(?X = u32)`, it would mean that only `Vec<u32>: Foo` and not any
17-
other sort of vector (e.g., `Vec<u64>: Foo` does not hold).
13+
* Provable(S): meaning the goal is provable and it is provably exactly (and
14+
only) for the substitution S. S is a set of values for the inference variables
15+
that appear in the goal. So if we had a goal like `Vec<?X>: Foo`, and we
16+
returned `Provable(?X = u32)`, it would mean that only `Vec<u32>: Foo` and not
17+
any other sort of vector (e.g., `Vec<u64>: Foo` does not hold).
1818
* Ambiguous(S): meaning that we can't prove whether or not the goal is true.
1919
This can sometimes come with a substitution S, which offers suggested values
2020
for the inference variables that might make it provable.
@@ -40,20 +40,20 @@ Implemented(u32: A)
4040
Implemented(i32: A)
4141
```
4242

43-
Now, suppose that we have a goal like `Implemented(Vec<f32>: A)`. This would
43+
First, suppose that we have a goal like `Implemented(Vec<u64>: A)`. This would
4444
proceed like so:
4545

46-
* `Solve(Implemented(Vec<f32>: A))`
47-
* `Solve(Implemented(f32: A))`
46+
* `Solve(Implemented(Vec<u64>: A))`
47+
* `Solve(Implemented(u64: A))`
4848
* returns `Error`
4949
* returns `Error`
5050

5151
In other words, the recursive solver would start by applying the first rule,
52-
which would cause us recursively try to solve `Implemented(f32: A)`. This would
52+
which would cause us recursively try to solve `Implemented(u64: A)`. This would
5353
yield an Error result, because there are no applicable rules, and that error
54-
would propagae back up, causing the entire attempt at proving things to fail.
54+
would propagate back up, causing the entire attempt at proving things to fail.
5555

56-
Now consider `Implemented(Vec<u32>: A)`. This would proceed like so:
56+
Next, consider `Implemented(Vec<u32>: A)`. This would proceed like so:
5757

5858
* `Solve(Implemented(Vec<u32>: A))`
5959
* `Solve(Implemented(u32: A))`
@@ -90,8 +90,8 @@ In the recursive solver, with a goal of `Implemented(Vec<?X>: A)`, we
9090
recursively try to prove `Implemented(?X: A)` and get ambiguity, and we get
9191
stuck there.
9292

93-
The SLG solver in contrast starts by exploring `?X = u32` and finds
93+
The [SLG solver] in contrast starts by exploring `?X = u32` and finds
9494
that it works, and then later tries to explore `?X = i32` and finds that it
9595
fails (because `i32: B` is not true).
9696

97-
[slg solver]: ./engine.md
97+
[SLG solver]: ./engine.md

book/src/recursive/inductive_cycles.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ to the same goal, S and S1. This implies two possibilities:
8080
and in fact we can just stop and return right now.
8181

8282
This technique is very similar to the traditional Prolog technique of handling
83-
cycles, which is called **tabling**. The difference between our solution and
84-
table is that we are always looking for a unique solution, whereas Prolog (like
85-
the [SLG solver]) tries to enumerate all solutions (i.e., in prolog, solving a
86-
goal is not a function but an iterator that yields solutions, and hence it would
87-
yield up S first, and then S1, and then any further answers we might get).
83+
cycles, which is called **tabling**. The difference between our approach and
84+
tabling is that we are always looking for a unique solution, whereas Prolog
85+
(like the [SLG solver]) tries to enumerate all solutions (i.e., in Prolog,
86+
solving a goal is not a function but an iterator that yields solutions, and
87+
hence it would yield up S first, and then S1, and then any further answers we
88+
might get).
8889

8990
[SLG solver]: ../engine.md
9091

book/src/recursive/search_graph.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ actually implement this? That's where the [`SearchGraph`] comes into play.
1212
[`Node`]: http://rust-lang.github.io/chalk/chalk_solve/recursive/search_graph/struct.Node.html
1313
[`stack_depth`]: http://rust-lang.github.io/chalk/chalk_solve/recursive/search_graph/struct.Node.html#structfield.stack_depth
1414

15-
The role of the [`SearchGraph`] is to store information each goal that we are
16-
currently solving. Typically, these are goals on the stack -- but other times,
17-
they are goals that are no longer on the stack, but whose results (because of a
18-
cycle) were dependent on something that is still on the stack. We'll work
19-
through some examples to make it all clear.
15+
The role of the [`SearchGraph`] is to store information about each goal that we
16+
are currently solving. Typically, these are goals on the stack -- but other
17+
times, they are goals that are no longer on the stack, but whose results
18+
(because of a cycle) were dependent on something that is still on the stack.
19+
We'll work through some examples to make it all clear.
2020

2121

2222
## Structure of the search graph

book/src/recursive/stack.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ one of the bits of information is the [`StackDepth`] of its entry on the stack
6868
(if any).
6969

7070
Therefore, when we are about to start solving some (canonical) goal G, we can
71-
detect a cycle by checking in the searh graph to see whether G has an associated
71+
detect a cycle by checking in the [search graph] to see whether G has an associated
7272
[`StackDepth`]. If so, it must be on the stack already (and we can set the
7373
[`cycle`] field to true...but I get ahead of myself, read the next chapters
7474
to learn more about that).
75+
76+
[search graph]: ./search_graph.md

0 commit comments

Comments
 (0)