File: .lake/packages/aesop/Aesop/Frontend/Command.lean

full_name: Aesop.Frontend.Parser.declareAesopRuleSets
code: syntax (name := declareAesopRuleSets)
  "declare_aesop_rule_sets " "[" ident,+,? "]"
  ("(" &"default" " := " Aesop.bool_lit ")")? : command
goal: Lean.ParserDescr

full_name: Aesop.Frontend.Parser.elabDeclareAesopRuleSets
code: @[command_elab declareAesopRuleSets]
def elabDeclareAesopRuleSets : CommandElab
  
goal: Lean.Elab.Command.CommandElab

full_name: Aesop.Frontend.Parser.command_Add_aesop_rules_
code: elab attrKind:attrKind "add_aesop_rules " e:Aesop.rule_expr : command => do
  let attrKind :=
    match attrKind with
    | `(Lean.Parser.Term.attrKind| local) => .local
    | `(Lean.Parser.Term.attrKind| scoped) => .scoped
    | _ => .global
  let rules ← liftTermElabM do
    let e ← RuleExpr.elab e |>.run (← ElabM.Context.forAdditionalGlobalRules)
    e.buildAdditionalGlobalRules none
  for (rule, rsNames) in rules do
    for rsName in rsNames do
      addGlobalRule rsName rule attrKind (checkNotExists := true)
goal: Lean.ParserDescr

full_name: Aesop.Frontend.Parser.«_aux_.lake_packages_aesop_Aesop_Frontend_Command___elabRules_Aesop_Frontend_Parser_command_Add_aesop_rules__1»
code: elab attrKind:attrKind "add_aesop_rules " e:Aesop.rule_expr : command => do
  let attrKind :=
    match attrKind with
    | `(Lean.Parser.Term.attrKind| local) => .local
    | `(Lean.Parser.Term.attrKind| scoped) => .scoped
    | _ => .global
  let rules ← liftTermElabM do
    let e ← RuleExpr.elab e |>.run (← ElabM.Context.forAdditionalGlobalRules)
    e.buildAdditionalGlobalRules none
  for (rule, rsNames) in rules do
    for rsName in rsNames do
      addGlobalRule rsName rule attrKind (checkNotExists := true)
goal: Lean.Elab.Command.CommandElab

full_name: Aesop.Frontend.Parser.«commandErase_aesop_rules[_,,]»
code: elab "erase_aesop_rules " "[" es:Aesop.rule_expr,* "]" : command => do
  let filters ← Elab.Command.liftTermElabM do
    let ctx ← ElabM.Context.forGlobalErasing
    (es : Array _).mapM λ e => do
      let e ← RuleExpr.elab e |>.run ctx
      e.toGlobalRuleFilters
  for fs in filters do
    for (rsFilter, rFilter) in fs do
      eraseGlobalRules rsFilter rFilter (checkExists := true)
goal: Lean.ParserDescr

full_name: Aesop.Frontend.Parser.«_aux_.lake_packages_aesop_Aesop_Frontend_Command___elabRules_Aesop_Frontend_Parser_commandErase_aesop_rules[_,,]_1»
code: elab "erase_aesop_rules " "[" es:Aesop.rule_expr,* "]" : command => do
  let filters ← Elab.Command.liftTermElabM do
    let ctx ← ElabM.Context.forGlobalErasing
    (es : Array _).mapM λ e => do
      let e ← RuleExpr.elab e |>.run ctx
      e.toGlobalRuleFilters
  for fs in filters do
    for (rsFilter, rFilter) in fs do
      eraseGlobalRules rsFilter rFilter (checkExists := true)
goal: Lean.Elab.Command.CommandElab

full_name: Aesop.Frontend.Parser.«command#aesop_rules»
code: elab "#aesop_rules" : command => do
  liftTermElabM do
    let lt := λ (n₁, _) (n₂, _) => n₁.cmp n₂ |>.isLT
    let rss := (← getDeclaredGlobalRuleSets).qsort lt
    TraceOption.ruleSet.withEnabled do
      for (name, rs, _) in rss do
        withConstAesopTraceNode .ruleSet (return m!"Rule set '{name}'") do
          rs.trace .ruleSet
goal: Lean.ParserDescr

full_name: Aesop.Frontend.Parser.«_aux_.lake_packages_aesop_Aesop_Frontend_Command___elabRules_Aesop_Frontend_Parser_command#aesop_rules_1»
code: elab "#aesop_rules" : command => do
  liftTermElabM do
    let lt := λ (n₁, _) (n₂, _) => n₁.cmp n₂ |>.isLT
    let rss := (← getDeclaredGlobalRuleSets).qsort lt
    TraceOption.ruleSet.withEnabled do
      for (name, rs, _) in rss do
        withConstAesopTraceNode .ruleSet (return m!"Rule set '{name}'") do
          rs.trace .ruleSet
goal: Lean.Elab.Command.CommandElab

full_name: Aesop.Frontend.Parser.evalStatsReport?
code: def evalStatsReport? (name : Name) : CoreM (Option StatsReport) 
goal: Lean.CoreM (Option Aesop.StatsReport)

full_name: Aesop.Frontend.Parser.«command#aesop_stats_»
code: elab "#aesop_stats" report?:(ident)? : command => do
  let resolveReport : Option Ident → CommandElabM StatsReport
    | none => pure StatsReport.default
    | some id => do
      let openDecl := OpenDecl.simple ``Aesop.StatsReport []
      withScope (λ s => { s with openDecls := openDecl :: s.openDecls }) do
        let names ← resolveGlobalConst id
        liftTermElabM do
          for name in names do
            if let some report ← evalStatsReport? name then
              return report
          throwError "'{id}' is not a constant of type 'Aesop.StatsReport'"
  let report ← resolveReport report?
  logInfo $ report $ ← getStatsArray
goal: Lean.ParserDescr

full_name: Aesop.Frontend.Parser.«_aux_.lake_packages_aesop_Aesop_Frontend_Command___elabRules_Aesop_Frontend_Parser_command#aesop_stats__1»
code: elab "#aesop_stats" report?:(ident)? : command => do
  let resolveReport : Option Ident → CommandElabM StatsReport
    | none => pure StatsReport.default
    | some id => do
      let openDecl := OpenDecl.simple ``Aesop.StatsReport []
      withScope (λ s => { s with openDecls := openDecl :: s.openDecls }) do
        let names ← resolveGlobalConst id
        liftTermElabM do
          for name in names do
            if let some report ← evalStatsReport? name then
              return report
          throwError "'{id}' is not a constant of type 'Aesop.StatsReport'"
  let report ← resolveReport report?
  logInfo $ report $ ← getStatsArray
goal: Lean.Elab.Command.CommandElab