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:
parent
0db795a1dc
commit
d32f04ba21
1 changed files with 13 additions and 4 deletions
|
|
@ -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`. -/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue