feat: add isTypeFormer

This commit is contained in:
Leonardo de Moura 2020-02-10 19:06:34 -08:00
parent 34776c4f41
commit 97057e56e0

View file

@ -327,5 +327,22 @@ match r with
| Expr.sort _ _ => pure true
| _ => pure false
partial def isTypeFormerAux : Expr → MetaM Bool
| type => do
type ← whnfD type;
match type with
| Expr.sort _ _ => pure true
| Expr.forallE n d b c =>
withLocalDecl n d c.binderInfo $ fun fvar =>
isTypeFormerAux (b.instantiate1 fvar)
| _ => pure false
/--
Return true iff `e : Sort _` or `e : (forall As, Sort _)`.
Remark: it subsumes `isType` -/
def isTypeFormer (e : Expr) : MetaM Bool := do
type ← inferType e;
isTypeFormerAux type
end Meta
end Lean