refactor: split out an isInductivePredicateVal function (#10033)

This is just like `isInductivePredicate?`, but on an existing
`InductiveVal` rather than one that is looked up by name.
This commit is contained in:
Cameron Zwarich 2025-08-21 11:05:14 -07:00 committed by GitHub
parent 0db795a1dc
commit d32f04ba21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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`. -/