Skip to content

Commit ad0f28a

Browse files
authored
document clear tactic (#895)
* document `clear` tactic * single backticks
1 parent 3866ec1 commit ad0f28a

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

doc/tactics/clear.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
========================================================================
2+
Tactic: `clear`
3+
========================================================================
4+
5+
The `clear` tactic can be used with any goal to remove hypotheses and
6+
variables from the context. This is useful to simplify the context by
7+
removing assumptions and variables that are no longer needed.
8+
9+
There are two variants of the `clear` tactic: an opt-in variant where
10+
specific hypotheses and variables are removed, and an opt-out variant
11+
where all hypotheses and variables except for the specified ones are removed.
12+
13+
.. admonition:: Syntax
14+
15+
`clear`
16+
17+
When given no arguments, the `clear` tactic removes all hypotheses and
18+
all variables not transitively used in the goal from the context.
19+
20+
.. admonition:: Syntax
21+
22+
`clear -{idents}`
23+
24+
Here, `{idents}` is a non-empty space separated list of identifiers of
25+
the hypotheses and variables that should *not* be cleared. The tactic
26+
removes all hypotheses and variables except for those in the list, and
27+
those used transitively in the goal *or* in the objects in the list.
28+
29+
.. admonition:: Syntax
30+
31+
`clear {idents}`
32+
33+
Here, `{idents}` is a non-empty space separated list of identifiers of
34+
the hypotheses and variables to be cleared. If one of these is transitively
35+
used in the goal, then it is not cleared and an error is raised.
36+
37+
.. ecproof::
38+
:title: Hoare logic example
39+
40+
lemma L: true.
41+
pose x:=false.
42+
(*$*) clear x.
43+
(* `x` is now unbound *)
44+
pose x:=false.
45+
pose y:=x.
46+
pose z:=y.
47+
clear -y.
48+
(* `z` is unbound, but `x` is not, since `y` depends on it *)
49+
pose z:=x.
50+
clear y.
51+
pose y:=z.
52+
clear.
53+
(* everything is unbound, since nothing is in the goal *)
54+
pose x:=true.
55+
pose y:=false.
56+
clear.
57+
(* we cannot clear `x` since it is in the goal,
58+
but `y` is not used so it becomes unbound *)
59+
pose y:= x.
60+
abort.

0 commit comments

Comments
 (0)