Skip to content

Commit 6780706

Browse files
committed
doc(Tactic): improve tfae_have/tfae_finish tactic docstring (leanprover-community#33997)
This PR rewrites the docstring for the `tfae` family of tactics to consistently match the [official style guide](https://github.com/leanprover/lean4/blob/master/doc/style.md#tactics), to make sure it is complete while not getting too long. Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
1 parent 5128da2 commit 6780706

1 file changed

Lines changed: 26 additions & 14 deletions

File tree

Mathlib/Tactic/TFAE.lean

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,33 +81,44 @@ end Parser
8181
open Parser
8282

8383
/--
84-
`tfae_have` introduces hypotheses for proving goals of the form `TFAE [P₁, P₂, ...]`. Specifically,
85-
`tfae_have i <arrow> j := ...` introduces a hypothesis of type `Pᵢ <arrow> Pⱼ` to the local
86-
context, where `<arrow>` can be `→`, `←`, or `↔`. Note that `i` and `j` are natural number indices
87-
(beginning at 1) used to specify the propositions `P₁, P₂, ...` that appear in the goal.
84+
`tfae_have i → j := t`, where the goal is `TFAE [P₁, P₂, ...]` introduces a hypothesis
85+
`tfae_i_to_j : Pᵢ → Pⱼ` and proof `t` to the local context. Note that `i` and `j` are
86+
natural number literals (beginning at 1) used as indices to specify the propositions
87+
`P₁, P₂, ...` that appear in the goal.
8888
89+
Once sufficient hypotheses have been introduced by `tfae_have`, `tfae_finish` can be used to close
90+
the goal.
91+
92+
All features of `have` are supported by `tfae_have`, including naming, matching,
93+
destructuring, and goal creation.
94+
95+
* `tfae_have i ← j := t` adds a hypothesis in the reverse direction, of type `Pⱼ → Pᵢ`.
96+
* `tfae_have i ↔ j := t` adds a hypothesis in the both directions, of type `Pᵢ ↔ Pⱼ`.
97+
* `tfae_have hij : i → j := t` names the introduced hypothesis `hij` instead of `tfae_i_to_j`.
98+
* `tfae_have i j | p₁ => t₁ | ...` matches on the assumption `p : Pᵢ`.
99+
* `tfae_have ⟨hij, hji⟩ : i ↔ j := t` destructures the bi-implication into `hij : Pᵢ → Pⱼ`
100+
and `hji : Pⱼ → Pⱼ`.
101+
* `tfae_have i → j := t ?a` creates a new goal for `?a`.
102+
103+
Examples:
89104
```lean4
90105
example (h : P → R) : TFAE [P, Q, R] := by
91106
tfae_have 1 → 3 := h
92-
...
107+
-- The resulting context now includes `tfae_1_to_3 : P → R`.
108+
sorry
93109
```
94-
The resulting context now includes `tfae_1_to_3 : P → R`.
95-
96-
Once sufficient hypotheses have been introduced by `tfae_have`, `tfae_finish` can be used to close
97-
the goal. For example,
98110
99111
```lean4
112+
-- An example of `tfae_have` and `tfae_finish`:
100113
example : TFAE [P, Q, R] := by
101114
tfae_have 1 → 2 := sorry /- proof of P → Q -/
102115
tfae_have 2 → 1 := sorry /- proof of Q → P -/
103116
tfae_have 2 ↔ 3 := sorry /- proof of Q ↔ R -/
104117
tfae_finish
105118
```
106119
107-
All features of `have` are supported by `tfae_have`, including naming, matching,
108-
destructuring, and goal creation. These are demonstrated below.
109-
110120
```lean4
121+
-- All features of `have` are supported by `tfae_have`:
111122
example : TFAE [P, Q] := by
112123
-- assert `tfae_1_to_2 : P → Q`:
113124
tfae_have 1 → 2 := sorry
@@ -124,13 +135,14 @@ example : TFAE [P, Q] := by
124135
125136
-- assert `h : P → Q`; `?a` is a new goal:
126137
tfae_have h : 1 → 2 := f ?a
127-
...
138+
139+
sorry
128140
```
129141
-/
130142
syntax (name := tfaeHave) "tfae_have " tfaeHaveDecl : tactic
131143

132144
/--
133-
`tfae_finish` is used to close goals of the form `TFAE [P₁, P₂, ...]` once a sufficient collection
145+
`tfae_finish` closes goals of the form `TFAE [P₁, P₂, ...]` once a sufficient collection
134146
of hypotheses of the form `Pᵢ → Pⱼ` or `Pᵢ ↔ Pⱼ` have been introduced to the local context.
135147
136148
`tfae_have` can be used to conveniently introduce these hypotheses; see `tfae_have`.

0 commit comments

Comments
 (0)