Built with
doc-gen4, running Lean4.
Bubbles (
) indicate interactive fragments: hover for details, tap to reveal contents.
Use
Ctrl+โCtrl+โto navigate,
Ctrl+๐ฑ๏ธto focus.
On Mac, use
Cmdinstead of
Ctrl.
/-
Copyright (c) 2022 Arthur Paulino. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Arthur Paulino, Edward Ayers, Mario Carneiro
-/
import Lean
import Mathlib.Data.Array.Defs
/--
Uses `checkColGt` to prevent
```lean
have h
exact Nat
```
From being interpreted as
```lean
have h
exact Nat
```
-/
def Lean.Parser.Term.haveIdLhs': Parser
Lean.Parser.Term.haveIdLhs' : Parser :=
optional (ppSpace >> ident >> many (ppSpace >>
checkColGt "expected to be indented": String
"expected to be indented" >>
letIdBinder)) >> optType
namespace Mathlib.Tactic
open Lean Elab.Tactic Meta
syntax "have" Parser.Term.haveIdLhs' : tactic
syntax "let " Parser.Term.haveIdLhs' : tactic
syntax "suffices" Parser.Term.haveIdLhs' : tactic
open Elab Term in
def haveLetCore (goal : MVarId) (name : Option Syntax) (bis : Array Syntax)
(t : Option Syntax) (keepTerm : Bool) : TermElabM (MVarId ร MVarId) :=
let declFn := if keepTerm then MVarId.define else MVarId.assert
goal.withContext do
let n := if let some n := name then n.getId else `this
let elabBinders k := if bis.isEmpty then k #[] else elabBinders bis k
let (goal1, t, p) โ elabBinders fun es โฆ do
let t โ match t with
| none => mkFreshTypeMVar
| some stx => withRefwithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
stxwithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
withRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
dowithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
withRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
letwithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
ewithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
โ Term.elabTermwithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
stxwithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
nonewithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
Term.synthesizeSyntheticMVarswithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
falsewithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
instantiateMVarswithRef stx do
let e โ Term.elabTerm stx none
Term.synthesizeSyntheticMVars false
instantiateMVars e: TermElabM (?m.966 yโ)
e
let p โ mkFreshExprMVar t MetavarKind.syntheticOpaque n
pure: {f : Type ?u.2336 โ Type ?u.2335} โ [self : Pure f] โ {ฮฑ : Type ?u.2336} โ ฮฑ โ f ฮฑ
pure (p.mvarId!, โ mkForallFVars es t, โ mkLambdaFVars es p)
let (fvar, goal2) โ (โ declFn goal n t p): ?m.2588
(โ declFn(โ declFn goal n t p): ?m.2588
goal(โ declFn goal n t p): ?m.2588
n(โ declFn goal n t p): ?m.2588
t(โ declFn goal n t p): ?m.2588
p(โ declFn goal n t p): ?m.2588
).intro1P
if let some stx := name then
goal2goal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
.withContextgoal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
goal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
dogoal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
Term.addTermInfo'goal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
(isBinder := truegoal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
) stxgoal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
(mkFVargoal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
fvargoal2.withContext do
Term.addTermInfo' (isBinder := true) stx (mkFVar fvar): TermElabM (?m.2673 yโ)
)
pure: {f : Type ?u.3202 โ Type ?u.3201} โ [self : Pure f] โ {ฮฑ : Type ?u.3202} โ ฮฑ โ f ฮฑ
pure (goal1, goal2)
elab_rules : tactic
| `(tactic| have $[$n:ident $bs*]? $[: $t:term]?) => do
let (goal1, goal2) โ haveLetCore (โ getMainGoal): ?m.9262
(โ getMainGoal(โ getMainGoal): ?m.9262
) n (bs.getD: {ฮฑ : Type ?u.9452} โ Option ฮฑ โ ฮฑ โ ฮฑ
getD #[]) t false
replaceMainGoal [goal1, goal2]
elab_rules : tactic
| `(tactic| suffices $[$n:ident $bs*]? $[: $t:term]?) => do
let (goal1, goal2) โ haveLetCore (โ getMainGoal): ?m.14079
(โ getMainGoal(โ getMainGoal): ?m.14079
) n (bs.getD: {ฮฑ : Type ?u.14269} โ Option ฮฑ โ ฮฑ โ ฮฑ
getD #[]) t false
replaceMainGoal [goal2, goal1]
elab_rules : tactic
| `(tactic| let $[$n:ident $bs*]? $[: $t:term]?) => withMainContext do
let (goal1, goal2) โ haveLetCore (โ getMainGoal): ?m.18714
(โ getMainGoal(โ getMainGoal): ?m.18714
) n (bs.getD: {ฮฑ : Type ?u.18904} โ Option ฮฑ โ ฮฑ โ ฮฑ
getD #[]) t true
replaceMainGoal [goal1, goal2]