Dataset Viewer
Auto-converted to Parquet Duplicate
fact
stringlengths
5
7.21k
type
stringclasses
9 values
library
stringclasses
2 values
imports
listlengths
0
3
filename
stringclasses
204 values
symbolic_name
stringlengths
1
41
docstring
stringclasses
245 values
BaseM.State where /-- The rule pattern cache. -/ rulePatternCache : RulePatternCache /-- Stats collected during an Aesop call. -/ stats : Stats deriving Inhabited
structure
Aesop
[]
Aesop/BaseM.lean
BaseM.State
/-- State of the `BaseM` monad. -/
BaseM := StateRefT BaseM.State MetaM namespace BaseM /-- Run a `BaseM` action. -/
abbrev
Aesop
[]
Aesop/BaseM.lean
BaseM
/-- Aesop's base monad. Contains no interesting data, only various caches and stats. -/
run (x : BaseM α) (stats : Stats := ∅) : MetaM (α × Stats) := do let (a, s) ← StateRefT'.run x { stats, rulePatternCache := ∅ } return (a, s.stats)
def
Aesop
[]
Aesop/BaseM.lean
run
/-- Run a `BaseM` action. -/
not_intro (h : P → False) : ¬ P := h @[aesop (rule_sets := [builtin]) norm destruct]
theorem
Aesop
[]
Aesop/BuiltinRules.lean
not_intro
null
empty_false (h : Empty) : False := nomatch h @[aesop (rule_sets := [builtin]) norm destruct]
theorem
Aesop
[]
Aesop/BuiltinRules.lean
empty_false
null
pEmpty_false (h : PEmpty) : False := nomatch h attribute [aesop (rule_sets := [builtin]) norm constructors] ULift attribute [aesop (rule_sets := [builtin]) norm 0 destruct] ULift.down @[aesop (rule_sets := [builtin]) norm simp]
theorem
Aesop
[]
Aesop/BuiltinRules.lean
pEmpty_false
null
heq_iff_eq (x y : α) : x ≍ y ↔ x = y := ⟨eq_of_heq, heq_of_eq⟩
theorem
Aesop
[]
Aesop/BuiltinRules.lean
heq_iff_eq
null
Check where toOption : Lean.Option Bool namespace Check
structure
Aesop
[]
Aesop/Check.lean
Check
null
get (opts : Options) (opt : Check) : Bool := if let some val := opt.toOption.get? opts then val else Check.all.get opts
def
Aesop
[]
Aesop/Check.lean
get
null
isEnabled [Monad m] [MonadOptions m] (opt : Check) : m Bool := return opt.get (← getOptions)
def
Aesop
[]
Aesop/Check.lean
isEnabled
null
name (opt : Check) : Name := opt.toOption.name
def
Aesop
[]
Aesop/Check.lean
name
null
unificationGoalPenalty : Percent := ⟨0.8⟩
def
Aesop
[]
Aesop/Constants.lean
unificationGoalPenalty
null
postponedSafeRuleSuccessProbability : Percent := ⟨0.9⟩
def
Aesop
[]
Aesop/Constants.lean
postponedSafeRuleSuccessProbability
null
Context where parsePriorities : Bool goal : MVarId namespace Context
structure
Aesop
[]
Aesop/ElabM.lean
Context
null
forAdditionalRules (goal : MVarId) : Context where parsePriorities := true goal := goal -- HACK: Some of the elaboration functions require that we pass in the current -- goal. The goal is used exclusively to look up fvars in the lctx, so when -- we operate outside a goal, we pass in a dummy mvar with empty lctx.
def
Aesop
[]
Aesop/ElabM.lean
forAdditionalRules
null
forAdditionalGlobalRules : MetaM Context := do let mvarId := (← mkFreshExprMVarAt {} {} (.const ``True [])).mvarId! return .forAdditionalRules mvarId
def
Aesop
[]
Aesop/ElabM.lean
forAdditionalGlobalRules
null
forErasing (goal : MVarId) : Context where parsePriorities := false goal := goal -- HACK: See `forAdditionalGlobalRules`
def
Aesop
[]
Aesop/ElabM.lean
forErasing
null
forGlobalErasing : MetaM Context := do let mvarId := (← mkFreshExprMVarAt {} {} (.const ``True [])).mvarId! return .forErasing mvarId
def
Aesop
[]
Aesop/ElabM.lean
forGlobalErasing
null
ElabM := ReaderT ElabM.Context $ TermElabM -- Generate specialized pure/bind implementations so we don't need to optimise -- them on the fly at each use site.
abbrev
Aesop
[]
Aesop/ElabM.lean
ElabM
null
ElabM.run (ctx : Context) (x : ElabM α) : TermElabM α := do ReaderT.run x ctx
def
Aesop
[]
Aesop/ElabM.lean
ElabM.run
null
shouldParsePriorities : ElabM Bool := return (← read).parsePriorities
def
Aesop
[]
Aesop/ElabM.lean
shouldParsePriorities
null
getGoal : ElabM MVarId := return (← read).goal
def
Aesop
[]
Aesop/ElabM.lean
getGoal
null
EMap (α) where /-- The mappings stored in the map. Defeq expressions are identified, so for each equivalence class of defeq expressions we only store one representative. Missing values indicate expressions that were removed from the map. -/ rep : PArray (Option (Expr × α)) /-- An index for `rep`. For each expression `e` at index `i` in `rep`, `idx.getMatch` returns a list of indexes containing `i`. This is used as a pre-filter during lookups/insertions/modifications to reduce the number of defeq comparisons. -/ idx : DiscrTree Nat deriving Inhabited namespace EMap
structure
Aesop
[]
Aesop/EMap.lean
EMap
/-- A map whose keys are expressions. Keys are identified up to defeq. We use `reducible` transparency and treat metavariables as rigid (i.e., unassignable). -/
empty : EMap α where rep := .empty idx := .empty
def
Aesop
[]
Aesop/EMap.lean
empty
/-- An index for `rep`. For each expression `e` at index `i` in `rep`, `idx.getMatch` returns a list of indexes containing `i`. This is used as a pre-filter during lookups/insertions/modifications to reduce the number of defeq comparisons. -/
foldlM (init : σ) (f : σ → Expr → α → m σ) (map : EMap α) : m σ := map.rep.foldlM (init := init) fun | s, none => return s | s, some (e, a) => f s e a
def
Aesop
[]
Aesop/EMap.lean
foldlM
null
foldl (init : σ) (f : σ → Expr → α → σ) (map : EMap α) : σ := inline <| map.foldlM (m := Id) init f
def
Aesop
[]
Aesop/EMap.lean
foldl
null
getCandidates (e : Expr) (map : EMap α) : m (Array Nat) := map.idx.getMatch e @[specialize]
def
Aesop
[]
Aesop/EMap.lean
getCandidates
null
alterM (e : Expr) (f : α → m (Option α × β)) (map : EMap α) : m (EMap α × Option β) := do let lctx ← show MetaM _ from getLCtx let mut rep := map.rep for i in ← map.getCandidates e do let some (e', old) := map.rep[i]! | continue if e'.hasAnyFVar (! lctx.contains ·) then rep := rep.set i none continue if ← isDefEqReducibleRigid e' e then let (new?, b) ← f old let entry := new?.map (e', ·) return ({ map with rep := rep.set i entry }, b) return ({ map with rep }, none)
def
Aesop
[]
Aesop/EMap.lean
alterM
null
alter (e : Expr) (f : α → Option α × β) (map : EMap α) : MetaM (EMap α × Option β) := do inline <| map.alterM e fun a => return f a @[specialize]
def
Aesop
[]
Aesop/EMap.lean
alter
null
insertNew (e : Expr) (a : α) (map : EMap α) : m (EMap α) := do let i := map.rep.size let rep := map.rep.push (e, a) let idx ← map.idx.insert e i return { idx, rep } @[specialize]
def
Aesop
[]
Aesop/EMap.lean
insertNew
null
insertWithM (e : Expr) (f : Option α → m α) (map : EMap α) : m (EMap α × Option α × α) := do let (map, vals?) ← map.alterM e fun old => do let new ← f (some old) return (new, (old, new)) match vals? with | none => let new ← f none return (← map.insertNew e new, none, new) | some (old, new) => return (map, old, new)
def
Aesop
[]
Aesop/EMap.lean
insertWithM
null
insertWith (e : Expr) (f : Option α → α) (map : EMap α) : MetaM (EMap α × Option α × α) := inline <| map.insertWithM e fun a? => return f a?
def
Aesop
[]
Aesop/EMap.lean
insertWith
null
insert (e : Expr) (a : α) (map : EMap α) : MetaM (EMap α) := (·.fst) <$> inline (map.insertWithM e (fun _ => return a))
def
Aesop
[]
Aesop/EMap.lean
insert
null
singleton (e : Expr) (a : α) : m (EMap α) := EMap.empty.insertNew e a
def
Aesop
[]
Aesop/EMap.lean
singleton
null
findWithKey ? (e : Expr) (map : EMap α) : MetaM (Option (Expr × α)) := do let lctx ← getLCtx for i in ← map.getCandidates e do let some (e', a) := map.rep[i]! | continue if e'.hasAnyFVar (! lctx.contains ·) then continue if ← isDefEqReducibleRigid e e' then return some (e', a) return none
def
Aesop
[]
Aesop/EMap.lean
findWithKey
null
find ? (e : Expr) (map : EMap α) : MetaM (Option α) := do return (← inline <| map.findWithKey? e).map (·.2) @[specialize]
def
Aesop
[]
Aesop/EMap.lean
find
null
mapM (f : Expr → α → m β) (map : EMap α) : m (EMap β) := do let rep ← map.rep.mapM fun x? => x?.mapM fun (e, a) => return (e, ← f e a) return { map with rep }
def
Aesop
[]
Aesop/EMap.lean
mapM
null
map (f : Expr → α → β) (map : EMap α) : EMap β := map.mapM (m := Id) f
def
Aesop
[]
Aesop/EMap.lean
map
null
Index (α : Type) where byTarget : DiscrTree (Rule α) byHyp : DiscrTree (Rule α) unindexed : PHashSet (Rule α) deriving Inhabited namespace Index variable [BEq α] [Ord α] [Hashable α]
structure
Aesop
[]
Aesop/Index.lean
Index
null
trace [ToString (Rule α)] (ri : Index α) (traceOpt : TraceOption) : CoreM Unit := do if ! (← traceOpt.isEnabled) then return withConstAesopTraceNode traceOpt (return "Indexed by target") do traceArray ri.byTarget.values withConstAesopTraceNode traceOpt (return "Indexed by hypotheses") do traceArray ri.byHyp.values withConstAesopTraceNode traceOpt (return "Unindexed") do traceArray $ PersistentHashSet.toArray ri.unindexed where traceArray (as : Array (Rule α)) : CoreM Unit := as.map toString |>.qsortOrd.forM λ r => do aesop_trace![traceOpt] r
def
Aesop
[]
Aesop/Index.lean
trace
null
merge (ri₁ ri₂ : Index α) : Index α where byTarget := ri₁.byTarget.mergePreservingDuplicates ri₂.byTarget byHyp := ri₁.byHyp.mergePreservingDuplicates ri₂.byHyp unindexed := ri₁.unindexed.merge ri₂.unindexed @[specialize]
def
Aesop
[]
Aesop/Index.lean
merge
null
add (r : Rule α) (imode : IndexingMode) (ri : Index α) : Index α := match imode with | IndexingMode.unindexed => { ri with unindexed := ri.unindexed.insert r } | IndexingMode.target keys => { ri with byTarget := ri.byTarget.insertCore keys r } | IndexingMode.hyps keys => { ri with byHyp := ri.byHyp.insertCore keys r } | IndexingMode.or imodes => imodes.foldl (init := ri) λ ri imode => ri.add r imode
def
Aesop
[]
Aesop/Index.lean
add
null
unindex (ri : Index α) (p : Rule α → Bool) : Index α := let (byTarget, unindexed) := filterDiscrTree' ri.unindexed ri.byTarget let (byHyp, unindexed) := filterDiscrTree' unindexed ri.byHyp { byTarget, byHyp, unindexed } where @[inline, always_inline] filterDiscrTree' (unindexed : PHashSet (Rule α)) (t : DiscrTree (Rule α)) : DiscrTree (Rule α) × PHashSet (Rule α) := filterDiscrTree (not ∘ p) (λ unindexed v => unindexed.insert v) unindexed t
def
Aesop
[]
Aesop/Index.lean
unindex
null
foldM [Monad m] (ri : Index α) (f : σ → Rule α → m σ) (init : σ) : m σ := match ri with | { byHyp, byTarget, unindexed} => do let mut s := init s ← byHyp.foldValuesM (init := s) f s ← byTarget.foldValuesM (init := s) f unindexed.foldM (init := s) f @[inline]
def
Aesop
[]
Aesop/Index.lean
foldM
null
fold (ri : Index α) (f : σ → Rule α → σ) (init : σ) : σ := Id.run $ ri.foldM (init := init) f -- May return duplicate `IndexMatchLocation`s. @[inline]
def
Aesop
[]
Aesop/Index.lean
fold
null
applicableByTargetRules (ri : Index α) (goal : MVarId) (include? : Rule α → Bool) : MetaM (Array (Rule α × Array IndexMatchLocation)) := goal.withContext do let rules ← getUnify ri.byTarget (← goal.getType) let mut rs := Array.mkEmpty rules.size -- Assumption: include? is true for most rules. for r in rules do if include? r then rs := rs.push (r, #[.target]) return rs -- May return duplicate `IndexMatchLocation`s. @[inline]
def
Aesop
[]
Aesop/Index.lean
applicableByTargetRules
null
applicableByHypRules (ri : Index α) (goal : MVarId) (include? : Rule α → Bool) : MetaM (Array (Rule α × Array IndexMatchLocation)) := goal.withContext do let mut rs := #[] for localDecl in ← getLCtx do if localDecl.isImplementationDetail then continue let rules ← getUnify ri.byHyp localDecl.type for r in rules do if include? r then rs := rs.push (r, #[.hyp localDecl]) return rs -- May return duplicate `IndexMatchLocation`s. @[inline]
def
Aesop
[]
Aesop/Index.lean
applicableByHypRules
null
applicableUnindexedRules (ri : Index α) (include? : Rule α → Bool) : Array (Rule α × Array IndexMatchLocation) := ri.unindexed.fold (init := #[]) λ acc r => if include? r then acc.push (r, #[.none]) else acc -- Returns the rules in the order given by the `Ord α` instance. @[specialize]
def
Aesop
[]
Aesop/Index.lean
applicableUnindexedRules
null
applicableRules (ri : Index α) (goal : MVarId) (patSubstMap : RulePatternSubstMap) (additionalRules : Array (IndexMatchResult (Rule α))) (include? : Rule α → Bool) : MetaM (Array (IndexMatchResult (Rule α))) := do withConstAesopTraceNode .debug (return "rule selection") do goal.instantiateMVars let result ← addRules additionalRules #[ (← applicableByTargetRules ri goal include?), (← applicableByHypRules ri goal include?), (applicableUnindexedRules ri include?) ] let result := result.qsort λ x y => x.rule.compareByPriorityThenName y.rule |>.isLT aesop_trace[debug] "selected rules:{.joinSep (result.map (m!"{·.rule.name}") |>.toList) "\n"}" return result where addRules (acc : Array (IndexMatchResult (Rule α))) (ruless : Array (Array (Rule α × Array IndexMatchLocation))) : MetaM (Array (IndexMatchResult (Rule α))) := do let mut locMap : Std.HashMap (Rule α) (Array IndexMatchLocation) := ∅ for rules in ruless do for (rule, locs) in rules do if let some locs' := locMap[rule]? then locMap := locMap.insert rule (locs' ++ locs) else locMap := locMap.insert rule locs let mut result := acc for (rule, locations) in locMap do if rule.pattern?.isSome then if let some patternSubsts := patSubstMap[rule.name]? then result := result.push { locations := locations.qsortOrd |>.dedupSorted patternSubsts? := some <| patternSubsts.toArray rule } else result := result.push { locations := locations.qsortOrd |>.dedupSorted patternSubsts? := none rule } return result
def
Aesop
[]
Aesop/Index.lean
applicableRules
null
Nanos where nanos : Nat deriving Inhabited, BEq, Ord namespace Nanos
structure
Aesop
[]
Aesop/Nanos.lean
Nanos
null
printAsMillis (n : Nanos) : String := let str := toString (n.nanos.toFloat / 1000000) match str.splitToList λ c => c == '.' with | [beforePoint] => beforePoint ++ "ms" | [beforePoint, afterPoint] => beforePoint ++ "." ++ afterPoint.take 1 ++ "ms" | _ => unreachable!
def
Aesop
[]
Aesop/Nanos.lean
printAsMillis
null
Percent where toFloat : Float deriving Inhabited namespace Percent
structure
Aesop
[]
Aesop/Percent.lean
Percent
null
ofFloat (f : Float) : Option Percent := if 0 <= f && f <= 1.0 then some ⟨f⟩ else none
def
Aesop
[]
Aesop/Percent.lean
ofFloat
null
δ : Percent := ⟨0.00001⟩
def
Aesop
[]
Aesop/Percent.lean
δ
null
hundred : Percent := ⟨1⟩
def
Aesop
[]
Aesop/Percent.lean
hundred
null
fifty : Percent := ⟨0.5⟩
def
Aesop
[]
Aesop/Percent.lean
fifty
null
toHumanString (p : Percent) : String := let str := toString (p.toFloat * 100) match str.splitToList λ c => c == '.' with | [beforePoint] => beforePoint ++ "%" | [beforePoint, afterPoint] => beforePoint ++ "." ++ afterPoint.take 4 ++ "%" | _ => unreachable!
def
Aesop
[]
Aesop/Percent.lean
toHumanString
null
ofNat (n : Nat) : Option Percent := Percent.ofFloat $ n.toFloat / 100
def
Aesop
[]
Aesop/Percent.lean
ofNat
null
NormRuleInfo where penalty : Int deriving Inhabited
structure
Aesop
[]
Aesop/Rule.lean
NormRuleInfo
null
NormRule := Rule NormRuleInfo
abbrev
Aesop
[]
Aesop/Rule.lean
NormRule
null
defaultNormPenalty : Int := 1
def
Aesop
[]
Aesop/Rule.lean
defaultNormPenalty
null
defaultSimpRulePriority : Int := eval_prio default /-! ### Safe and Almost Safe Rules -/
def
Aesop
[]
Aesop/Rule.lean
defaultSimpRulePriority
null
Safety | safe | almostSafe deriving Inhabited namespace Safety
inductive
Aesop
[]
Aesop/Rule.lean
Safety
null
SafeRuleInfo where penalty : Int safety : Safety deriving Inhabited
structure
Aesop
[]
Aesop/Rule.lean
SafeRuleInfo
null
SafeRule := Rule SafeRuleInfo
abbrev
Aesop
[]
Aesop/Rule.lean
SafeRule
null
defaultSafePenalty : Int := 1 /-! ### Unsafe Rules -/
def
Aesop
[]
Aesop/Rule.lean
defaultSafePenalty
null
UnsafeRuleInfo where successProbability : Percent deriving Inhabited
structure
Aesop
[]
Aesop/Rule.lean
UnsafeRuleInfo
null
UnsafeRule := Rule UnsafeRuleInfo
abbrev
Aesop
[]
Aesop/Rule.lean
UnsafeRule
null
defaultSuccessProbability : Percent := .fifty /-! ### Regular Rules -/
def
Aesop
[]
Aesop/Rule.lean
defaultSuccessProbability
null
RegularRule | safe (r : SafeRule) | «unsafe» (r : UnsafeRule) deriving Inhabited, BEq namespace RegularRule
inductive
Aesop
[]
Aesop/Rule.lean
RegularRule
null
successProbability : RegularRule → Percent | safe _ => Percent.hundred | «unsafe» r => r.extra.successProbability
def
Aesop
[]
Aesop/Rule.lean
successProbability
null
isSafe : RegularRule → Bool | safe _ => true | «unsafe» _ => false
def
Aesop
[]
Aesop/Rule.lean
isSafe
null
isUnsafe : RegularRule → Bool | safe _ => false | «unsafe» _ => true @[inline]
def
Aesop
[]
Aesop/Rule.lean
isUnsafe
null
withRule (f : ∀ {α}, Rule α → β) : RegularRule → β | safe r => f r | «unsafe» r => f r
def
Aesop
[]
Aesop/Rule.lean
withRule
null
name (r : RegularRule) : RuleName := r.withRule (·.name)
def
Aesop
[]
Aesop/Rule.lean
name
null
indexingMode (r : RegularRule) : IndexingMode := r.withRule (·.indexingMode)
def
Aesop
[]
Aesop/Rule.lean
indexingMode
null
tac (r : RegularRule) : RuleTacDescr := r.withRule (·.tac)
def
Aesop
[]
Aesop/Rule.lean
tac
null
NormSimpRule where name : RuleName entries : Array SimpEntry deriving Inhabited namespace NormSimpRule
structure
Aesop
[]
Aesop/Rule.lean
NormSimpRule
/-- A global rule for the norm simplifier. Each `SimpEntry` represents a member of the simp set, e.g. a declaration whose type is an equality or a smart unfolding theorem for a declaration. -/
LocalNormSimpRule where id : Name simpTheorem : Term deriving Inhabited namespace LocalNormSimpRule
structure
Aesop
[]
Aesop/Rule.lean
LocalNormSimpRule
/-- A local rule for the norm simplifier. -/
name (r : LocalNormSimpRule) : RuleName := { name := r.id, scope := .local, builder := .simp, phase := .norm }
def
Aesop
[]
Aesop/Rule.lean
name
/-- A local rule for the norm simplifier. -/
UnfoldRule where decl : Name unfoldThm? : Option Name deriving Inhabited namespace UnfoldRule
structure
Aesop
[]
Aesop/Rule.lean
UnfoldRule
/-- A local rule for the norm simplifier. -/
name (r : UnfoldRule) : RuleName := { name := r.decl, builder := .unfold, phase := .norm, scope := .global }
def
Aesop
[]
Aesop/Rule.lean
name
null
RulePattern where /-- An expression of the form `λ y₀ ... yₖ, p` representing the pattern. -/ pattern : AbstractMVarsResult /-- A partial map from the index set `{0, ..., n-1}` into `{0, ..., k-1}`. If `argMap[i] = j`, this indicates that when matching against the rule type, the instantiation `tⱼ` of `yⱼ` should be substituted for `xᵢ`. -/ argMap : Array (Option Nat) /-- A partial map from the level metavariables occurring in the rule to the pattern's level params. -/ levelArgMap : Array (Option Nat) /-- Discrimination tree keys for `p`. -/ discrTreeKeys : Array DiscrTree.Key deriving Inhabited namespace RulePattern
structure
Aesop
[]
Aesop/RulePattern.lean
RulePattern
null
boundPremises (pat : RulePattern) : Array Nat := Id.run do let mut result := Array.mkEmpty pat.argMap.size for h : i in [:pat.argMap.size] do if pat.argMap[i].isSome then result := result.push i return result -- Largely copy-paste from openAbstractMVarsResult
def
Aesop
[]
Aesop/RulePattern.lean
boundPremises
/-- Discrimination tree keys for `p`. -/
BaseRuleSet where /-- Normalisation rules registered in this rule set. -/ normRules : Index NormRuleInfo /-- Unsafe rules registered in this rule set. -/ unsafeRules : Index UnsafeRuleInfo /-- Safe rules registered in this rule set. -/ safeRules : Index SafeRuleInfo /-- Rules for the builtin unfold rule. A pair `(decl, unfoldThm?)` in this map represents a declaration `decl` which should be unfolded. `unfoldThm?` should be the output of `getUnfoldEqnFor? decl` and is cached here for efficiency. -/ -- TODO Don't cache equation name; this may lead to bugs and the performance -- cost is negligible. unfoldRules : PHashMap Name (Option Name) /-- Forward rules. There's a special procedure for applying forward rules, so we don't store them in the regular indices. -/ forwardRules : ForwardIndex /-- The names of all rules in `forwardRules`. -/ -- HACK to be removed once we switch fully to stateful forward reasoning. forwardRuleNames : PHashSet RuleName /-- An index for the rule patterns associated with rules contained in this rule set. When rules are removed from the rule set, their patterns are not removed from this index. -/ rulePatterns : RulePatternIndex /-- The set of rules that were erased from `normRules`, `unsafeRules`, `safeRules` and `forwardRules`. When we erase a rule which is present in any of these four indices, the rule is not removed from the indices but just added to this set. By contrast, when we erase a rule from `unfoldRules`, we actually delete it. -/ erased : PHashSet RuleName /-- A cache of the names of all rules registered in this rule set. Invariant: `ruleNames` contains exactly the names of the rules present in `normRules`, `unsafeRules`, `safeRules`, `forwardRules` and `unfoldRules` and not present in `erased`. We use this cache (a) to quickly determine whether a rule is present in the rule set and (b) to find the full rule names associated with the fvar or const identified by a name. -/ ruleNames : PHashMap Name (UnorderedArraySet RuleName) deriving Inhabited /-- A global Aesop rule set. When we tag a declaration with `@[aesop]`, it is stored in one or more of these rule sets. Internally, a `GlobalRuleSet` is composed of a `BaseRuleSet` (stored in an Aesop rule set extension) plus a set of simp theorems (stored in a `SimpExtension`). -/
structure
Aesop
[]
Aesop/RuleSet.lean
BaseRuleSet
/-- The Aesop-specific parts of an Aesop rule set. A `BaseRuleSet` stores global Aesop rules, e.g. safe and unsafe rules. It does not store simp theorems for the builtin norm simp rule; these are instead stored in a simp extension. -/
GlobalRuleSet extends BaseRuleSet where /-- The simp theorems stored in this rule set. -/ simpTheorems : SimpTheorems /-- The simprocs stored in this rule set. -/ simprocs : Simprocs deriving Inhabited /-- The rule set used by an Aesop tactic call. A local rule set is produced by combining several global rule sets and possibly adding or erasing some individual rules. -/
structure
Aesop
[]
Aesop/RuleSet.lean
GlobalRuleSet
/-- A global Aesop rule set. When we tag a declaration with `@[aesop]`, it is stored in one or more of these rule sets. Internally, a `GlobalRuleSet` is composed of a `BaseRuleSet` (stored in an Aesop rule set extension) plus a set of simp theorems (stored in a `SimpExtension`). -/
LocalRuleSet extends BaseRuleSet where /-- The simp theorems used by the builtin norm simp rule. -/ simpTheoremsArray : Array (Name × SimpTheorems) /-- The simp theorems array must contain at least one `SimpTheorems` structure. When a simp theorem is added to a `LocalRuleSet`, it is stored in this first `SimpTheorems` structure. -/ simpTheoremsArrayNonempty : 0 < simpTheoremsArray.size /-- The simprocs used by the builtin norm simp rule. -/ simprocsArray : Array (Name × Simprocs) /-- The simprocs array must contain at least one `Simprocs` structure, for the same reason as above. -/ simprocsArrayNonempty : 0 < simprocsArray.size /-- FVars that were explicitly added as simp rules. -/ localNormSimpRules : Array LocalNormSimpRule
structure
Aesop
[]
Aesop/RuleSet.lean
LocalRuleSet
/-- The rule set used by an Aesop tactic call. A local rule set is produced by combining several global rule sets and possibly adding or erasing some individual rules. -/
onBaseM [Monad m] (f : BaseRuleSet → m (BaseRuleSet × α)) (rs : GlobalRuleSet) : m (GlobalRuleSet × α) := do let (toBaseRuleSet, a) ← f rs.toBaseRuleSet let rs := { rs with toBaseRuleSet } return (rs, a) @[inline, always_inline]
def
Aesop
[]
Aesop/RuleSet.lean
onBaseM
/-- FVars that were explicitly added as simp rules. -/
onBase (f : BaseRuleSet → BaseRuleSet × α) (rs : GlobalRuleSet) : GlobalRuleSet × α := rs.onBaseM (m := Id) f @[inline, always_inline]
def
Aesop
[]
Aesop/RuleSet.lean
onBase
/-- FVars that were explicitly added as simp rules. -/
modifyBaseM [Monad m] (f : BaseRuleSet → m BaseRuleSet) (rs : GlobalRuleSet) : m GlobalRuleSet := (·.fst) <$> rs.onBaseM (λ rs => return (← f rs, ())) @[inline, always_inline]
def
Aesop
[]
Aesop/RuleSet.lean
modifyBaseM
null
modifyBase (f : BaseRuleSet → BaseRuleSet) (rs : GlobalRuleSet) : GlobalRuleSet := rs.modifyBaseM (m := Id) f
def
Aesop
[]
Aesop/RuleSet.lean
modifyBase
null
onBaseM [Monad m] (f : BaseRuleSet → m (BaseRuleSet × α)) (rs : LocalRuleSet) : m (LocalRuleSet × α) := do let (toBaseRuleSet, a) ← f rs.toBaseRuleSet return ({ rs with toBaseRuleSet }, a) @[inline, always_inline]
def
Aesop
[]
Aesop/RuleSet.lean
onBaseM
null
onBase (f : BaseRuleSet → (BaseRuleSet × α)) (rs : LocalRuleSet) : LocalRuleSet × α := rs.onBaseM (m := Id) f
def
Aesop
[]
Aesop/RuleSet.lean
onBase
null
modifyBaseM [Monad m] (f : BaseRuleSet → m BaseRuleSet) (rs : LocalRuleSet) : m LocalRuleSet := (·.fst) <$> rs.onBaseM (λ rs => return (← f rs, ()))
def
Aesop
[]
Aesop/RuleSet.lean
modifyBaseM
null
modifyBase (f : BaseRuleSet → BaseRuleSet) (rs : LocalRuleSet) : LocalRuleSet := rs.modifyBaseM (m := Id) f
def
Aesop
[]
Aesop/RuleSet.lean
modifyBase
null
BaseRuleSet.trace (rs : BaseRuleSet) (traceOpt : TraceOption) : CoreM Unit := do if ! (← traceOpt.isEnabled) then return withConstAesopTraceNode traceOpt (return "Erased rules") do aesop_trace![traceOpt] "(Note: even if these rules appear in the sections below, they will not be applied by Aesop.)" let erased := rs.erased.fold (init := #[]) λ ary r => ary.push r for r in erased.qsortOrd do aesop_trace![traceOpt] r withConstAesopTraceNode traceOpt (return "Unsafe rules") do rs.unsafeRules.trace traceOpt withConstAesopTraceNode traceOpt (return "Safe rules") do rs.safeRules.trace traceOpt withConstAesopTraceNode traceOpt (return "Forward rules") do rs.forwardRules.trace traceOpt withConstAesopTraceNode traceOpt (return "Normalisation rules") do rs.normRules.trace traceOpt withConstAesopTraceNode traceOpt (return "Constants to unfold") do for r in rs.unfoldRules.toArray.map (·.fst.toString) |>.qsortOrd do aesop_trace![traceOpt] r
def
Aesop
[]
Aesop/RuleSet.lean
BaseRuleSet.trace
null
GlobalRuleSet.trace (rs : GlobalRuleSet) (traceOpt : TraceOption) : CoreM Unit := do if ! (← traceOpt.isEnabled) then return rs.toBaseRuleSet.trace traceOpt withConstAesopTraceNode traceOpt (return "Normalisation simp theorems:") do traceSimpTheorems rs.simpTheorems traceOpt -- TODO trace simprocs
def
Aesop
[]
Aesop/RuleSet.lean
GlobalRuleSet.trace
null
LocalRuleSet.trace (rs : LocalRuleSet) (traceOpt : TraceOption) : CoreM Unit := do if ! (← traceOpt.isEnabled) then return rs.toBaseRuleSet.trace traceOpt withConstAesopTraceNode traceOpt (return "Simp sets used by normalisation simp:") do rs.simpTheoremsArray.map (printSimpSetName ·.fst) |>.qsortOrd.forM λ s => do aesop_trace![traceOpt] s withConstAesopTraceNode traceOpt (return "Local normalisation simp theorems") do for r in rs.localNormSimpRules.map (·.simpTheorem) do aesop_trace![traceOpt] r where printSimpSetName : Name → String | `_ => "<default>" | n => toString n
def
Aesop
[]
Aesop/RuleSet.lean
LocalRuleSet.trace
null
BaseRuleSet.empty : BaseRuleSet := by refine' {..} <;> exact {}
def
Aesop
[]
Aesop/RuleSet.lean
BaseRuleSet.empty
null
GlobalRuleSet.empty : GlobalRuleSet := by refine' {..} <;> exact {}
def
Aesop
[]
Aesop/RuleSet.lean
GlobalRuleSet.empty
null
End of preview. Expand in Data Studio

Lean4-Aesop

Structured dataset from Aesop — White-box proof search automation.

1,836 declarations extracted from Lean 4 source files.

Applications

  • Training language models on formal proofs
  • Fine-tuning theorem provers
  • Retrieval-augmented generation for proof assistants
  • Learning proof embeddings and representations

Source

Schema

Column Type Description
fact string Declaration body
type string theorem, def, lemma, etc.
library string Source module
imports list Required imports
filename string Source file path
symbolic_name string Identifier
docstring string Documentation (if present)
Downloads last month
20

Collection including phanerozoic/Lean4-Aesop