Skip to content

Commit

Permalink
feat: add a by? macro (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjbest committed May 24, 2023
1 parent 2f23536 commit 60f19be
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Std/Data/List/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ rotate [0, 1, 2, 3, 4, 5] 2 = [2, 3, 4, 5, 0, 1]
let (l₁, l₂) := List.splitAt (n % l.length) l
l₂ ++ l₁

/-- rotate' is the same as `rotate`, but slower. Used for proofs about `rotate` -/
/-- `rotate'` is the same as `rotate`, but slower. Used for proofs about `rotate` -/
@[simp] def rotate' : List α → Nat → List α
| [], _ => []
| l, 0 => l
Expand Down
4 changes: 2 additions & 2 deletions Std/Tactic/Lint/Frontend.lean
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ default ones. e.g. `#lint doc_blame_thm` will run all default tests and `doc_bla
You can append `only name1 name2 ...` to any command to run a subset of linters, e.g.
`#lint only unused_arguments in Std`
You can add custom linters by defining a term of type `Linter` with the `@[std_linter]` namespace.
You can add custom linters by defining a term of type `Linter` with the `@[std_linter]` attribute.
A linter defined with the name `Std.Tactic.Lint.myNewCheck` can be run with `#lint myNewCheck`
or `#lint only myNewCheck`.
If you add the attribute `@[std_linter disabled]` to `linter.myNewCheck` it will be registered,
Expand Down Expand Up @@ -64,7 +64,7 @@ inductive LintVerbosity
/-- `getChecks slow extra use_only` produces a list of linters.
`extras` is a list of names that should resolve to declarations with type `linter`.
If `useOnly` is true, it only uses the linters in `extra`.
Otherwise, it uses all linters in the environment tagged with `@[linter]`.
Otherwise, it uses all linters in the environment tagged with `@[std_linter]`.
If `slow` is false, it only uses the fast default tests. -/
def getChecks (slow : Bool) (useOnly : Bool) : CoreM (Array NamedLinter) := do
let mut result := #[]
Expand Down
2 changes: 1 addition & 1 deletion Std/Tactic/Lint/Misc.lean
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ has been used. -/
| false, true => pure "is a def, should be lemma/theorem"
| _, _ => return none

/-- A linter for missing checking whether statements of declarations are well-typed. -/
/-- A linter for checking whether statements of declarations are well-typed. -/
@[std_linter] def checkType : Linter where
noErrorsFound :=
"The statements of all declarations type-check with default reducibility settings."
Expand Down
9 changes: 9 additions & 0 deletions Std/Tactic/ShowTerm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ elab (name := showTerm) tk:"show_term " t:term : term <= ty => do
Term.synthesizeSyntheticMVarsNoPostponing
addTermSuggestion tk (← instantiateMVars e).headBeta (origSpan? := ← getRef)
pure e

/--
The command `by?` will print a suggestion for replacing the proof block with a proof term
using `show_term`.
-/
syntax (name := by?) "by?" tacticSeq : term
macro_rules
| `(term| by?%$tk $t) => `(show_term%$tk by%$tk $t)

0 comments on commit 60f19be

Please sign in to comment.