diff --git a/src/Lean/Meta/Basic.lean b/src/Lean/Meta/Basic.lean index 43d6155523..cbe286ba31 100644 --- a/src/Lean/Meta/Basic.lean +++ b/src/Lean/Meta/Basic.lean @@ -2230,6 +2230,15 @@ def sortFVarIds (fvarIds : Array FVarId) : MetaM (Array FVarId) := do end Methods +/-- +Return `true` if `indVal` is an inductive predicate. That is, `inductive` type in `Prop`. +-/ +def isInductivePredicateVal (indVal : InductiveVal) : MetaM Bool := do + forallTelescopeReducing indVal.type fun _ type => do + match (← whnfD type) with + | .sort u .. => return u == levelZero + | _ => return false + /-- Return `some info` if `declName` is an inductive predicate where `info : InductiveVal`. That is, `inductive` type in `Prop`. @@ -2237,10 +2246,10 @@ That is, `inductive` type in `Prop`. def isInductivePredicate? (declName : Name) : MetaM (Option InductiveVal) := do match (← getEnv).find? declName with | some (.inductInfo info) => - forallTelescopeReducing info.type fun _ type => do - match (← whnfD type) with - | .sort u .. => if u == levelZero then return some info else return none - | _ => return none + if (← isInductivePredicateVal info) then + return some info + else + return none | _ => return none /-- Return `true` if `declName` is an inductive predicate. That is, `inductive` type in `Prop`. -/