Debian Codegraph @

apps/locker/README.md

raw symbols SCIP
1 # Locker
2
3 The `lock` and `mlock` commands let you lock definitions.
4
5 ## Example of `lock`
6
7 ```coq
8 lock Definition x := 3.
9 ```
10
11 is elaborated to
12
13 ```coq
14 Lemma x_key_subproof : unit. Proof. exact: tt. Qed.
15 Definition x := locked_with x_key_subproof 3.
16 Canonical x_unlock_subterm := Unlockable ...
17 ```
18
19 Here `locked_with` comes from `ssreflect.v` and protects the body of `x`
20 under a match on `x_key_subproof` which is `Qed` opaque.
21 Hence `x` is provably equal to 3, but not computationally equal to it.
22
23 Given the canonical structure registration, `rewrite unlock` will replace `x`
24 by `3`.
25
26 ## Example of `mlock`
27
28 ```coq
29 mlock Definition x := 3.
30 ```
31
32 is elaborated to
33
34 ```coq
35 Module Type x_Locked.
36 Axiom body : nat.
37 Axiom unlock : body = 3.
38 End x_Locked.
39 Module x : x_Locked. ... End x.
40 Notation x := x.body.
41 Canonical x_unlock_subterm := Unlockable x.unlock.
42 ```
43
44 Hence `x` (actually `x.body`) is a new symbol and `x.unlock` is its
45 defining equation.
46
47 Given the canonical structure registration, `rewrite unlock` will replace `x`
48 by `3`.
49
50 ## Limitations
51
52 `mlock` uses a module based locking. The body is really sealed but this
53 command cannot be used inside sections (since modules cannot be declared
54 inside sections).
55
56 `lock` uses opaque key based locking. It can be used everywhere, even inside
57 sections, but conversion (term comparison) may cross the lock (by congruence)
58 and hence compare possibly large terms.
59
60 See also the section about locking in [ssereflect.v](https://github.com/coq/coq/blob/master/theories/ssr/ssreflect.v).