-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1089 from lean-ja/Seasawher/issue1006
`linter.style.multiGoal` を紹介する
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/- # linter.style.multiGoal | ||
`linter.style.multiGoal` は、よくない証明の書き方を指摘するリンターの一つです。 | ||
Lean では、複数のサブゴールがあるときにタクティクを実行すると最初のゴールに対して実行されるのですが、証明を構造化するという観点からは、ゴールの一つにフォーカスする(infoview に一つしかゴールが表示されないようにする)べきです。 | ||
このリンタはそのような問題を指摘します。 | ||
-/ | ||
import Mathlib.Tactic.Linter.Multigoal | ||
|
||
set_option linter.style.multiGoal true | ||
|
||
/-- | ||
warning: There are 2 unclosed goals before 'exact hP' and at least one remaining goal afterwards. | ||
Please focus on the current goal, for instance using `·` (typed as "\."). | ||
note: this linter can be disabled with `set_option linter.style.multiGoal false` | ||
-/ | ||
#guard_msgs in | ||
example {P Q : Prop} (hP : P) (hQ : Q) : P ∧ Q := by | ||
-- ゴールが2つ生成される | ||
constructor | ||
|
||
-- この時点でサブゴールが2つあるのに、 | ||
-- フォーカスせずにタクティクを実行しているので警告が出る | ||
exact hP | ||
exact hQ | ||
|
||
-- 良い証明の例 | ||
example {P Q : Prop} (hP : P) (hQ : Q) : P ∧ Q := by | ||
constructor | ||
· exact hP | ||
· exact hQ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters