HORIZON HASKELLDocslts/ghc-9.14.x7a6c33e2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 7a6c33e · 2026-10-12

Special Inequalities

valuezero :: 0 <= a

Zero is less-than-or-equal-to any number.

Substitution

valuesubstituteL :: b :=: c -> b <= a -> c <= a

Replace the left-hand side of a strict inequality with an equal number.

valuesubstituteR :: b :=: c -> a <= b -> a <= c

Replace the right-hand side of a strict inequality with an equal number.

Increment

valueincrementL :: a <= b -> (c + a) <= (c + b)

Add a constant to the left-hand side of both sides of the inequality.

valueincrementR :: a <= b -> (a + c) <= (b + c)

Add a constant to the right-hand side of both sides of the inequality.

Decrement

valuedecrementL :: (c + a) <= (c + b) -> a <= b

Subtract a constant from the left-hand side of both sides of the inequality. This is the opposite of incrementL.

valuedecrementR :: (a + c) <= (b + c) -> a <= b

Subtract a constant from the right-hand side of both sides of the inequality. This is the opposite of incrementR.

Weaken

valueweakenL :: a <= b -> a <= (c + b)

Add a constant to the left-hand side of the right-hand side of the inequality.

valueweakenR :: a <= b -> a <= (b + c)

Add a constant to the right-hand side of the right-hand side of the inequality.

Composition

Convert Strict Inequality

valuefromStrict :: a < b -> a <= b

Weaken a strict inequality to a non-strict inequality.

valuefromStrictSucc :: a < b -> (a + 1) <= b

Weaken a strict inequality to a non-strict inequality, incrementing the right-hand argument by one.

Integration with GHC solver

valueconstant :: IsLte (CmpNat a b) ~ 'True => a <= b

Use GHC's built-in type-level arithmetic to prove that one number is less-than-or-equal-to another. The type-checker only reduces CmpNat if both arguments are constants.

Lift and Unlift