|
2 | 2 |
|
3 | 3 | This is a glossary of terminology (possibly) used in the chalk crate.
|
4 | 4 |
|
| 5 | +## Notation |
| 6 | + |
| 7 | +### Basic notation |
| 8 | + |
| 9 | +| Notation | Meaning | |
| 10 | +|--------------|----------------------------------| |
| 11 | +| `?0` | [Type inference variable] | |
| 12 | +| `^0`, `^1.0` | [Bound variable] | |
| 13 | +| `!0` | [Placeholder] | |
| 14 | +| `A :- B` | [Clause]; A is true if B is true | |
| 15 | + |
| 16 | +### Rules |
| 17 | + |
| 18 | +- `forall<T> { (Vec<T>: Clone) :- (T: Clone)`: for every `T`, `Vec<T>` |
| 19 | + implements `Clone` if `T` implements `Clone` |
| 20 | + |
| 21 | +### Queries |
| 22 | + |
| 23 | +- `Vec<i32>: Clone`: does `Vec<i32>` implement `Clone`? |
| 24 | +- `exists<T> { Vec<T>: Clone }`: does there exist a `T` such that `Vec<T>` |
| 25 | + implements `Clone`? |
| 26 | + |
| 27 | +[Type inference variable]: ../types/rust_types.md#inference-variables |
| 28 | +[Bound variable]: ../types/rust_types.md#bound-variables |
| 29 | +[Placeholder]: ../types/rust_types.md#placeholders |
| 30 | +[Clause]: ../clauses/goals_and_clauses.md |
| 31 | + |
5 | 32 | ## Binary connective
|
6 | 33 | There are sixteen logical connectives on two boolean variables. The most
|
7 | 34 | interesting in this context are listed below. There is also a truth table given
|
@@ -50,15 +77,15 @@ the optional positive literal. Due to the equivalence `(P => Q) <=> (!P || Q)`
|
50 | 77 | the clause can be expressed as `B && C && ... => A` which means that A is true
|
51 | 78 | if `B`, `C`, etc. are all true. All rules in chalk are in this form. For example
|
52 | 79 |
|
53 |
| -```notrust |
| 80 | +```rust,ignore |
54 | 81 | struct A<T> {}
|
55 | 82 | impl<T> B for A<T> where T: C + D {}
|
56 | 83 | ```
|
57 | 84 |
|
58 | 85 | is expressed as the *Horn clause* `(T: C) && (T: D) => (A<T>: B)`. This formula
|
59 | 86 | has to hold for all values of `T`. The second example
|
60 | 87 |
|
61 |
| -```notrust |
| 88 | +```rust,ignore |
62 | 89 | struct A {}
|
63 | 90 | impl B for A {}
|
64 | 91 | impl C for A {}
|
@@ -149,7 +176,7 @@ syntactic rules.
|
149 | 176 | In the context of the Rust type system this means that basic rules for type
|
150 | 177 | construction have to be met. Two examples: 1) Given a struct definition
|
151 | 178 |
|
152 |
| -```notrust |
| 179 | +```rust,ignore |
153 | 180 | struct HashSet<T: Hash>
|
154 | 181 | ```
|
155 | 182 | then a type `HashSet<i32>` is well-formed since `i32` implements `Hash`. A type
|
|
0 commit comments