-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
44 additions
and
34 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
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,28 @@ | ||
import Mathlib.Tactic.Lemma | ||
import Verbose.Infrastructure.Multilingual | ||
|
||
open Lean Meta Elab Command Parser Tactic | ||
|
||
open Lean.Parser.Term (bracketedBinder) | ||
|
||
endpoint mkProof (prf : TSyntax ``tacticSeq) : CoreM (TSyntax `tactic) | ||
|
||
def mkExercise (name? : Option Ident) (objs hyps : TSyntaxArray ``bracketedBinder) (concl: Term) | ||
(prf?: Option (TSyntax ``tacticSeq)) (tkp tkq : Syntax) : CommandElabM Unit := do | ||
let ref := mkNullNode #[tkp, tkq] | ||
let prf ← prf?.getDM <| withRef ref `(tacticSeq| skip) | ||
let term ← withRef tkq `(by%$ref | ||
skip%$ref | ||
($prf) | ||
skip%$ref) | ||
if (← getOptions).getBool `verbose.suggestion_widget then | ||
let tac : TSyntax `tactic ← liftCoreM <| mkProof prf | ||
if let some name := name? then | ||
elabCommand (← `(command|lemma $name $(objs ++ hyps):bracketedBinder* : $concl := by {$tac})) | ||
else | ||
elabCommand (← `(command|example $(objs ++ hyps):bracketedBinder* : $concl := by {$tac})) | ||
else | ||
if let some name := name? then | ||
elabCommand (← `(command|lemma $name $(objs ++ hyps):bracketedBinder* : $concl := $term)) | ||
else | ||
elabCommand (← `(command|example $(objs ++ hyps):bracketedBinder* : $concl := $term)) |