|
|
# Iris proof style
|
|
|
|
|
|
**Warning:** this document is still in development and should not be taken
|
|
|
seriously. If you run across a question of style (for example, something comes
|
|
|
up in an MR) and it's not on this list, please do reach out to Tej on Mattermost
|
|
|
(@tchajed) so he can add it.
|
|
|
|
|
|
## Basic syntax
|
|
|
|
|
|
### Binders
|
|
|
|
|
|
**Good:** `(a : B)`
|
|
|
**Bad:** `(a:B)`, `(a: B)`
|
|
|
|
|
|
**TODO**: Prefer `(a : B)` to `a : B`
|
|
|
|
|
|
This applies to Context, Implicit Types, and definitions
|
|
|
|
|
|
### Unicode
|
|
|
|
|
|
Always use Unicode variants of forall, exists, ->, <=, >=
|
|
|
|
|
|
**Good:** `∀ ∃ → ≤ ≥`
|
|
|
**Bad:** `forall exists -> <= >=`
|
|
|
|
|
|
### Equivalent vernacular commands
|
|
|
|
|
|
Use `Context`, never `Variable`
|
|
|
|
|
|
**TODO::** Use `Implicit Types`, never `Implicit Type`
|
|
|
|
|
|
Use `Lemma`, not `Theorem` (or the other variants: `Fact`, `Corollary`,
|
|
|
`Remark`)
|
|
|
|
|
|
Tests may use `Example` for theorems.
|
|
|
|
|
|
### Uncategorized
|
|
|
|
|
|
Indent the body of a match by one space:
|
|
|
|
|
|
**Good:**
|
|
|
```coq
|
|
|
match foo with
|
|
|
| Some x =>
|
|
|
long line here using
|
|
|
```
|
|
|
|
|
|
Avoid using the extra square brackets around an Ltac match:
|
|
|
|
|
|
**Good:**
|
|
|
```coq
|
|
|
match goal with
|
|
|
| |- ?g => idtac g
|
|
|
|
|
|
```
|
|
|
|
|
|
**Bad:**
|
|
|
```coq
|
|
|
match goal with
|
|
|
| [ |- ?g ] => idtac g
|
|
|
|
|
|
```
|
|
|
|
|
|
Use coqdoc syntax in comments for Coq identifiers and inline code, eg `[cmraT]`
|
|
|
|
|
|
Put proofs either all on one line (`Proof. reflexivity. Qed.`) or split up the usual way with indentation.
|
|
|
|
|
|
**Bad:**
|
|
|
|
|
|
```coq
|
|
|
Lemma foo : 2 + 2 = 4 ∧ 1 + 2 = 3.
|
|
|
Proof. split.
|
|
|
- reflexivity.
|
|
|
- done.
|
|
|
Qed.
|
|
|
```
|
|
|
|
|
|
Put the entire theorem statement on one line or one premise per line.
|
|
|
|
|
|
**Bad:**
|
|
|
|
|
|
```coq
|
|
|
Lemma foo x y z :
|
|
|
x < y → y < z →
|
|
|
x < z.
|
|
|
```
|
|
|
|
|
|
**Good:**
|
|
|
|
|
|
```coq
|
|
|
Lemma foo x y z : x < y → y < z → x < z.
|
|
|
```
|
|
|
|
|
|
**Good:** (particularly if premises are longer)
|
|
|
|
|
|
```coq
|
|
|
Lemma foo x y z :
|
|
|
x < y →
|
|
|
y < z →
|
|
|
x < z.
|
|
|
```
|
|
|
|
|
|
**TODO:** Use `"[H1 H2]"` when possible otherwise do `"(H1&H2&H3)"`
|
|
|
|
|
|
For tests with output put `Check "theorem name in a string"` before it so that the output from different tests is separated.
|
|
|
|
|
|
For long `t; [t1 | t2 | t3]` split them like this:
|
|
|
|
|
|
**Good:**
|
|
|
```coq
|
|
|
t;
|
|
|
[t1
|
|
|
|t2
|
|
|
|t3].
|
|
|
```
|
|
|
|
|
|
|
|
|
## File organization
|
|
|
theories/algebra is for primitive ofe/RA/CMRA constructions
|
|
|
theories/algebra/lib is for derived constructions
|
|
|
theories/base_logic/lib is for constructions in the base logic (using own)
|
|
|
|
|
|
## Naming
|
|
|
* `*_ctx` for persistent facts (often an invariant) needed by everything in a library
|
|
|
* `*_interp` for a function from some representation to iProp
|
|
|
* If you have lemma `foo` which is an iff and you want single direction versions, name them `foo_1` (forward) and `foo_2` (backward)
|
|
|
* If you have a lemma `foo` parametrized by a relation, you might want a version specialized to Leibniz equality for better rewrite support; name that version `foo_L` and state it with plain equality (eg, `dom_empty_L` in stdpp). You might take an assumption `LeibnizEquiv A` if the original version took an equivalence (say the OFE equivalence) to assume that the provided equivalence is plain equality.
|
|
|
* Lower-case theorem names, lower-case types, upper-case constructors
|
|
|
* **TODO:** how should `f (g x) = f' (g' x)` be named?
|
|
|
* `list_lookup_insert` is named by context (the type involved), then the two functions outside-in on the left-hand-side, so it has the type `lookup (insert …) = …` where the `insert` is on a list. Notations mean it doesn’t actually look like this and the insert is textually first.
|
|
|
* Injectivity theorems are instances of `Inj` and then are used with `inj`
|
|
|
* Suffixes `_l` and `_r` when we have binary `op x y` and a theorem related to the left or right. For example, `sep_mono_l` says bi_sep is monotonic in its left argument (holding the right constant)
|
|
|
* Entailments at the top level are typically written P -* Q, which is notation for P ⊢ Q. If we have a theorem which has no premises you use ⊢ P explicitly (for example, common to have ⊢ |==> ∃ γ, … for an allocation theorem)
|
|
|
* Suffix `'` (prime) is used when `foo'` is a corollary of `foo`. Try to avoid
|
|
|
these since the name doesn't convey how `foo'` is related to `foo`.
|
|
|
|
|
|
### Naming algebra libraries
|
|
|
|
|
|
**TODO:** describe any conclusions we came to with the `mono_nat` library
|
|
|
|
|
|
## Metavariables
|
|
|
**TODO:** move these to the right place
|
|
|
|
|
|
* `P` `Q` for bi:PROP (or specifically `iProp Σ`)
|
|
|
* `Φ` and `Ψ` for (?A -> iProp), like postconditions
|
|
|
* `φ` and `ψ` for `Prop`
|
|
|
* `A` `B` for types, ofeT, or cmraT
|
|
|
|
|
|
Suffixes like O, R, UR (already documented) |