feat: add Level.dec

This commit is contained in:
Leonardo de Moura 2019-10-30 18:23:12 -07:00
parent f66b0d562c
commit a9f3aa086d

View file

@ -62,6 +62,10 @@ def isMVar : Level → Bool
| mvar _ => true
| _ => false
def mvarId! : Level → Name
| mvar mvarId => mvarId
| _ => panic! "metavariable expected"
/-- If result is true, then forall assignments `A` which assigns all parameters and metavariables occuring
in `l`, `l[A] != zero` -/
def isNeverZero : Level → Bool
@ -264,6 +268,17 @@ partial def normalize : Level → Level
def isEquiv (u v : Level) : Bool :=
u == v || u.normalize == v.normalize
/-- Reduce (if possible) universe level by 1 -/
def dec : Level → Option Level
| zero => none
| param _ => none
| mvar _ => none
| succ l => l
| max l₁ l₂ => max <$> dec l₁ <*> dec l₂
/- Remark: `max` in the following line is not a typo.
If `dec l₂` succeeds, then `imax l₁ l₂` is equivalent to `max l₁ l₂`. -/
| imax l₁ l₂ => max <$> dec l₁ <*> dec l₂
/- Level to Format -/
namespace LevelToFormat
inductive Result