import Mathlib.MeasureTheory.Order.Lattice import Lean.Meta.DecLevel import Lean.Meta.Transform import Lean.Util.Recognizers import Mathlib.Probability.Kernel.Composition.Prod /-! # Standalone extraction for `collectExprUniverses` Definitions are copied verbatim; theorem proofs are replaced by `sorry`. Auto-generated by Referee. -/ set_option quotPrecheck false -- Namespace stubs (so later `open`s resolve). namespace Finset end Finset namespace Lean end Lean namespace Lean.Meta end Lean.Meta namespace ProbabilityTheory end ProbabilityTheory -- ═══ ForMathlib.MeasureTheory.Order.Lattice ═══ section open Finset variable {α δ : Type*} [MeasurableSpace δ] [SemilatticeInf α] {m : MeasurableSpace α} [MeasurableInf₂ α] attribute [to_dual existing] MeasurableInf₂ end -- ═══ Tactic.EqLift.Tactic.Universe ═══ section public meta section open Lean Meta ProbabilityTheory /-- Recursively traverses an expression and collects all universe levels. -/ def collectExprUniverses.aux (e : Expr) : List Level := match e with | Expr.const _ univs => univs | Expr.sort u => [u] | Expr.app f a => aux f ++ aux a | Expr.lam _ t b _ => aux t ++ aux b | Expr.forallE _ t b _ => aux t ++ aux b | Expr.letE _ t v b _ => aux t ++ aux v ++ aux b | Expr.mdata _ b => aux b | Expr.proj _ _ b => aux b | Expr.bvar _ | Expr.fvar _ | Expr.mvar _ | Expr.lit _ => [] /-- Recursively traverse an expression and collect universe levels found. Returns a list of all unique universe levels encountered. -/ def collectExprUniverses (e : Expr) : MetaM (List Level) := do let e ← instantiateMVars e let e ← zetaReduce e return (collectExprUniverses.aux e).eraseDups end