blob: 56ade87aa59e495afdcfd89240000cc8c96e98bc [file]
/-
Copyright (c) 2025 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving
-/
module
prelude
public import Lean.Declaration
public import Lean.Util.FoldConsts
namespace Lake.Check
public def runForUsedConsts [Monad m] (info : Lean.ConstantInfo) (f : Lean.Name → m Unit) : m Unit := do
info.type.getUsedConstants.forM f
f info.name
if let some val := info.value? (allowOpaque := true) then
val.getUsedConstants.forM f
match info with
| .axiomInfo .. | .quotInfo .. | .defnInfo .. | .thmInfo .. | .opaqueInfo .. => return ()
| .inductInfo info =>
info.ctors.forM f
info.all.forM f
| .ctorInfo info =>
f info.induct
| .recInfo info =>
info.rules.forM fun rule => do
f rule.ctor
rule.rhs.getUsedConstants.forM f
end Lake.Check