statement stringlengths 1 2.93k | proof stringlengths 0 19.2k | type stringclasses 13
values | symbolic_name stringlengths 1 131 | library stringlengths 4 62 | filename stringlengths 20 95 | imports listlengths 0 10 | deps listlengths 0 64 | docstring stringlengths 0 4.95k | source_url stringclasses 1
value | commit stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|
synthesizeUsing {u : Level} (type : Q(Sort u)) (tac : TacticM Unit) :
MetaM (List MVarId × Q($type)) | do
let m ← mkFreshExprMVar type
let goals ← (Term.withoutErrToSorry <| run m.mvarId! tac).run'
return (goals, ← instantiateMVars m) | def | synthesizeUsing | Util | Mathlib/Util/SynthesizeUsing.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
synthesizeUsing' {u : Level} (type : Q(Sort u)) (tac : TacticM Unit) : MetaM Q($type) | do
let (goals, e) ← synthesizeUsing type tac
-- Note: does not use `tac *> Tactic.done` since that just adds a message
-- rather than raising an error.
unless goals.isEmpty do
throwError m!"synthesizeUsing': unsolved goals\n{goalsToMessageData goals}"
return e | def | synthesizeUsing' | Util | Mathlib/Util/SynthesizeUsing.lean | [] | [
"synthesizeUsing"
] | `synthesizeUsing type tac` synthesizes an element of type `type` using tactic `tac`.
The tactic must solve for all goals, in contrast to `synthesizeUsing`. | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
synthesizeUsingTactic {u : Level} (type : Q(Sort u)) (tac : Syntax) :
MetaM (List MVarId × Q($type)) | do
synthesizeUsing type (do evalTactic tac) | def | synthesizeUsingTactic | Util | Mathlib/Util/SynthesizeUsing.lean | [] | [
"synthesizeUsing"
] | `synthesizeUsing type tacticSyntax` synthesizes an element of type `type` by evaluating the
given tactic syntax.
Example:
```lean
let (gs, e) ← synthesizeUsingTactic ty (← `(tactic| congr!))
```
The tactic `tac` is allowed to leave goals open, and these remain as metavariables in the
returned expression. | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
synthesizeUsingTactic' {u : Level} (type : Q(Sort u)) (tac : Syntax) : MetaM Q($type) | do
synthesizeUsing' type (do evalTactic tac) | def | synthesizeUsingTactic' | Util | Mathlib/Util/SynthesizeUsing.lean | [] | [
"synthesizeUsing'"
] | `synthesizeUsing' type tacticSyntax` synthesizes an element of type `type` by evaluating the
given tactic syntax.
Example:
```lean
let e ← synthesizeUsingTactic' ty (← `(tactic| norm_num))
```
The tactic must solve for all goals, in contrast to `synthesizeUsingTactic`.
If you need to insert expressions into a tactic... | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
modifyMetavarDecl [MonadMCtx m] (mvarId : MVarId)
(f : MetavarDecl → MetavarDecl) : m Unit | modifyMCtx fun mctx ↦
match mctx.decls.find? mvarId with
| none => mctx
| some mdecl => { mctx with decls := mctx.decls.insert mvarId (f mdecl) } | def | Mathlib.Tactic.modifyMetavarDecl | Util | Mathlib/Util/Tactic.lean | [] | [] | `modifyMetavarDecl mvarId f` updates the `MetavarDecl` for `mvarId` with `f`.
Conditions on `f`:
- The target of `f mdecl` is defeq to the target of `mdecl`.
- The local context of `f mdecl` must contain the same fvars as the local
context of `mdecl`. For each fvar in the local context of `f mdecl`, the type
(and ... | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
modifyTarget [MonadMCtx m] (mvarId : MVarId) (f : Expr → Expr) : m Unit | modifyMetavarDecl mvarId fun mdecl ↦
{ mdecl with type := f mdecl.type } | def | Mathlib.Tactic.modifyTarget | Util | Mathlib/Util/Tactic.lean | [] | [] | `modifyTarget mvarId f` updates the target of the metavariable `mvarId` with
`f`. For any `e`, `f e` must be defeq to `e`. If `mvarId` does not refer to
a declared metavariable, nothing happens. | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
modifyLocalContext [MonadMCtx m] (mvarId : MVarId)
(f : LocalContext → LocalContext) : m Unit | modifyMetavarDecl mvarId fun mdecl ↦
{ mdecl with lctx := f mdecl.lctx } | def | Mathlib.Tactic.modifyLocalContext | Util | Mathlib/Util/Tactic.lean | [] | [] | `modifyLocalContext mvarId f` updates the local context of the metavariable
`mvarId` with `f`. The new local context must contain the same fvars as the old
local context and the types (and values, if any) of the fvars in the new local
context must be defeq to their equivalents in the old local context.
If `mvarId` doe... | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
modifyLocalDecl [MonadMCtx m] (mvarId : MVarId) (fvarId : FVarId)
(f : LocalDecl → LocalDecl) : m Unit | modifyLocalContext mvarId fun lctx ↦ lctx.modifyLocalDecl fvarId f | def | Mathlib.Tactic.modifyLocalDecl | Util | Mathlib/Util/Tactic.lean | [] | [] | `modifyLocalDecl mvarId fvarId f` updates the local decl `fvarId` in the local
context of `mvarId` with `f`. `f` must leave the `fvarId` and `index` of the
`LocalDecl` unchanged. The type of the new `LocalDecl` must be defeq to the type
of the old `LocalDecl` (and the same applies to the value of the `LocalDecl`, if
an... | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
elabBeta : TermElab | fun stx expectedType? =>
match stx with
| `(beta% $t) => do
let e ← elabTerm t expectedType?
return (← instantiateMVars e).headBeta
| _ => throwUnsupportedSyntax | def | Mathlib.Util.TermReduce.elabBeta | Util | Mathlib/Util/TermReduce.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
elabDelta : TermElab | fun stx expectedType? =>
match stx with
| `(delta% $t) => do
let t ← withSynthesize (postpone := .partial) do
elabTerm t expectedType?
synthesizeSyntheticMVars
let t ← instantiateMVars t
let some t ← withoutExporting do delta? t | throwError "cannot delta reduce {t}"
pure t
| _ => throwU... | def | Mathlib.Util.TermReduce.elabDelta | Util | Mathlib/Util/TermReduce.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
elabZeta : TermElab | fun stx expectedType? =>
match stx with
| `(zeta% $t) => do
let t ← withSynthesize (postpone := .partial) do
elabTerm t expectedType?
synthesizeSyntheticMVars
let t ← instantiateMVars t
let t ← zetaReduce t
pure t
| _ => throwUnsupportedSyntax | def | Mathlib.Util.TermReduce.elabZeta | Util | Mathlib/Util/TermReduce.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
elabReduceProj : TermElab | fun stx expectedType? =>
match stx with
| `(reduceProj% $t) => do
let t ← withSynthesize (postpone := .partial) do
elabTerm t expectedType?
synthesizeSyntheticMVars
let t ← instantiateMVars t
let t ← Lean.Core.transform t (post := fun e ↦ do
return .continue (← Expr.reduceProjStruct? e))... | def | Mathlib.Util.TermReduce.elabReduceProj | Util | Mathlib/Util/TermReduce.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
throwUnknownId (id : Name) : CommandElabM Unit | throwError "unknown identifier '{mkConst id}'" | def | Mathlib.WhatsNew.throwUnknownId | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
levelParamsToMessageData (levelParams : List Name) : MessageData | match levelParams with
| [] => ""
| u::us => Id.run do
let mut m := m!".\{{u}"
for u in us do
m := m ++ ", " ++ toMessageData u
return m ++ "}" | def | Mathlib.WhatsNew.levelParamsToMessageData | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
mkHeader (kind : String) (id : Name) (levelParams : List Name) (type : Expr)
(safety : DefinitionSafety) : CoreM MessageData | do
let m : MessageData :=
match safety with
| DefinitionSafety.unsafe => "unsafe "
| DefinitionSafety.partial => "partial "
| DefinitionSafety.safe => ""
let m := if isProtected (← getEnv) id then m ++ "protected " else m
let (m, id) := match privateToUserName? id with
| some id => (m ++ "... | def | Mathlib.WhatsNew.mkHeader | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
mkHeader' (kind : String) (id : Name) (levelParams : List Name) (type : Expr)
(isUnsafe : Bool) : CoreM MessageData | mkHeader kind id levelParams type
(if isUnsafe then DefinitionSafety.unsafe else DefinitionSafety.safe) | def | Mathlib.WhatsNew.mkHeader' | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
printDefLike (kind : String) (id : Name) (levelParams : List Name) (type : Expr)
(value : Expr) (safety := DefinitionSafety.safe) : CoreM MessageData | return (← mkHeader kind id levelParams type safety) ++ " :=" ++ Format.line ++ value | def | Mathlib.WhatsNew.printDefLike | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
printInduct (id : Name) (levelParams : List Name) (_numParams : Nat) (_numIndices : Nat)
(type : Expr) (ctors : List Name) (isUnsafe : Bool) : CoreM MessageData | do
let mut m ← mkHeader' "inductive" id levelParams type isUnsafe
m := m ++ Format.line ++ "constructors:"
for ctor in ctors do
let cinfo ← getConstInfo ctor
m := m ++ Format.line ++ ctor ++ " : " ++ cinfo.type
pure m | def | Mathlib.WhatsNew.printInduct | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
printIdCore (id : Name) : ConstantInfo → CoreM MessageData | | ConstantInfo.axiomInfo { levelParams := us, type := t, isUnsafe := u, .. } =>
mkHeader' "axiom" id us t u
| ConstantInfo.defnInfo { levelParams := us, type := t, value := v, safety := s, .. } =>
printDefLike "def" id us t v s
| ConstantInfo.thmInfo { levelParams := us, type := t, value := v, .. } =>
p... | def | Mathlib.WhatsNew.printIdCore | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
diffExtension (old new : Environment)
(ext : PersistentEnvExtension EnvExtensionEntry EnvExtensionEntry EnvExtensionState) :
CoreM (Option MessageData) | unsafe do
let mut asyncMode := ext.toEnvExtension.asyncMode
if asyncMode matches .async .. then
-- allow for diffing async extensions by bumping mode to sync
asyncMode := .sync
let oldSt := ext.toEnvExtension.getState (asyncMode := asyncMode) old
let newSt := ext.toEnvExtension.getState (asyncMode := as... | def | Mathlib.WhatsNew.diffExtension | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
whatsNew (old new : Environment) : CoreM MessageData | do
let mut diffs := #[]
for (c, i) in new.constants.map₂.toList do
unless old.constants.map₂.contains c do
diffs := diffs.push (← printIdCore c i)
for ext in ← persistentEnvExtensionsRef.get do
if let some diff := ← diffExtension old new ext then
diffs := diffs.push diff
if diffs.isEmpty ... | def | Mathlib.WhatsNew.whatsNew | Util | Mathlib/Util/WhatsNew.lean | [] | [] | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
"whatsnew " "in" ppLine cmd:command : command => do
let oldEnv ← getEnv
try
elabCommand cmd
finally
let newEnv ← getEnv
logInfo (← liftCoreM <| whatsNew oldEnv newEnv) | elab | whatsnew | Util | Mathlib/Util/WhatsNew.lean | [] | [] | `whatsnew in $command` executes the command and then prints the
declarations that were added to the environment. | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
resolveNamespace (ns : Name) : Name → Name | | `_root_ => Name.anonymous
| Name.str n s .. => Name.mkStr (resolveNamespace ns n) s
| Name.num n i .. => Name.mkNum (resolveNamespace ns n) i
| Name.anonymous => ns | def | Lean.Elab.Command.resolveNamespace | Util | Mathlib/Util/WithWeakNamespace.lean | [] | [] | Adds the name to the namespace, `_root_`-aware.
```
resolveNamespace `A `B.b == `A.B.b
resolveNamespace `A `_root_.B.c == `B.c
``` | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
withWeakNamespace {α : Type} (ns : Name) (m : CommandElabM α) : CommandElabM α | do
let old ← getCurrNamespace
let ns := resolveNamespace old ns
modify fun s ↦ { s with env := s.env.registerNamespace ns }
modifyScope ({ · with currNamespace := ns })
try m finally modifyScope ({ · with currNamespace := old }) | def | Lean.Elab.Command.withWeakNamespace | Util | Mathlib/Util/WithWeakNamespace.lean | [] | [] | Changes the current namespace without causing scoped things to go out of scope | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
"with_weak_namespace " ns:ident cmd:command : command =>
withWeakNamespace ns.getId (elabCommand cmd) | elab | with_weak_namespace | Util | Mathlib/Util/WithWeakNamespace.lean | [] | [] | Changes the current namespace without causing scoped things to go out of scope | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
Recurse.Config where
/-- the reducibility setting to use when comparing atoms for defeq -/
red | TransparencyMode.reducible
/-- if true, local let variables can be unfolded -/
zetaDelta := false
/-- if true, implication hypotheses are added to the local context of the discharger -/
contextual := false
deriving Inhabited, BEq, Repr | structure | Mathlib.Tactic.AtomM.Recurse.Config | Util.AtomM | Mathlib/Util/AtomM/Recurse.lean | [] | [] | Configuration for `AtomM.Recurse`. | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
Recurse.Context where
/-- A basically empty simp context, passed to the `simp` traversal in `AtomM.onSubexpressions`.
-/
ctx : Simp.Context
/-- A cleanup routine, which simplifies evaluation results to a more human-friendly format. -/
simp : Simp.Result → MetaM Simp.Result | structure | Mathlib.Tactic.AtomM.Recurse.Context | Util.AtomM | Mathlib/Util/AtomM/Recurse.lean | [] | [] | The read-only state of the `AtomM.Recurse` monad. | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 | |
RecurseM | ReaderT Recurse.Context AtomM | abbrev | Mathlib.Tactic.AtomM.RecurseM | Util.AtomM | Mathlib/Util/AtomM/Recurse.lean | [] | [] | The monad for `AtomM.Recurse` contains, in addition to the `AtomM` state,
a simp context for the main traversal and a cleanup function to simplify evaluation results. | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
onSubexpressions (eval : Expr → AtomM Simp.Result) (parent : Expr)
(wellBehavedDischarge : Bool) (root := true) :
RecurseM Simp.Result | fun nctx rctx s ↦ do
let pre : Simp.Simproc := fun e =>
try
guard <| root || parent != e -- recursion guard
let r' ← eval e rctx s
let r ← nctx.simp r'
if ← withReducible <| isDefEq r.expr e then return .done { expr := r.expr }
pure (.done r)
catch _ => pure <| .c... | def | Mathlib.Tactic.AtomM.onSubexpressions | Util.AtomM | Mathlib/Util/AtomM/Recurse.lean | [] | [] | A tactic in the `AtomM.RecurseM` monad which will simplify expression `parent` to a normal form, by
running a core operation `eval` (in the `AtomM` monad) on the maximal subexpression(s) on which
`eval` does not fail.
There is also a subsequent clean-up operation, governed by the context from the `AtomM.RecurseM`
mona... | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
RecurseM.run
{α : Type} (s : IO.Ref State) (cfg : Recurse.Config) (wellBehavedDischarge : Bool)
(eval : Expr → AtomM Simp.Result) (simp : Simp.Result → MetaM Simp.Result) (x : RecurseM α) :
MetaM α | do
let ctx ← Simp.mkContext
{ zetaDelta := cfg.zetaDelta, singlePass := true, contextual := cfg.contextual }
(simpTheorems := #[← Elab.Tactic.simpOnlyBuiltins.foldlM (·.addConst ·) {}])
(congrTheorems := ← getSimpCongrTheorems)
let nctx := { ctx, simp }
let rec
/-- The recursive context. -/
rc... | def | Mathlib.Tactic.AtomM.RecurseM.run | Util.AtomM | Mathlib/Util/AtomM/Recurse.lean | [] | [] | Runs a tactic in the `AtomM.RecurseM` monad, given initial data:
* `s`: a reference to the mutable `AtomM` state, for persisting across calls.
This ensures that atom ordering is used consistently.
* `cfg`: the configuration options
* `wellBehavedDischarge` : MUST be set to `false` IF `eval` accesses local declaratio... | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
recurse (s : IO.Ref State) (cfg : Recurse.Config) (wellBehavedDischarge : Bool)
(eval : Expr → AtomM Simp.Result)
(simp : Simp.Result → MetaM Simp.Result) (tgt : Expr) :
MetaM Simp.Result | do
RecurseM.run s cfg wellBehavedDischarge eval simp
<| onSubexpressions eval tgt wellBehavedDischarge | def | Mathlib.Tactic.AtomM.recurse | Util.AtomM | Mathlib/Util/AtomM/Recurse.lean | [] | [] | Normalizes an expression, given initial data:
* `s`: a reference to the mutable `AtomM` state, for persisting across calls.
This ensures that atom ordering is used consistently.
* `cfg`: the configuration options
* `wellBehavedDischarge` : MUST be set to `false` IF `eval` accesses local declarations with
index >= ... | https://github.com/leanprover-community/mathlib4 | b9f14353520df73472ae3825fb53f86559a01319 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.