def hlf_lower

bend-collections-laws-math@1.0.0.0 · proofs/lib/u32half.bend:78

import bend-collections-laws-math@1.0.0.0/proofs/lib/u32half.bend as U32half
import Base
import bend-collections-laws-math@1.0.0.0/proofs/lib/logic.bend as L
import bend-collections-laws-math@1.0.0.0/proofs/lib/nat.bend as N

78# The midpoint of a nonempty range lies inside it: a <= hlf(a+b) < b
79# whenever a < b.
80def hlf_lower(+a: Nat, +b: Nat, +h: {Nat.is_lt(a, b) == True{} : Bool}) -> {Nat.is_le(a, hlf(Nat.add(a, b))) == True{} : Bool}:
81  match a b:
82    case 0n b0:
83      N.zero_le(hlf(Nat.add(0n, b0)))
84    case 1n+p 0n:
85      Empty.absurd({Nat.is_le(1n+p, hlf(Nat.add(1n+p, 0n))) == True{} : Bool}, L.false_true(h))
86    case 1n+ +p 1n+ +q:
87      %Equal.sym(Nat, Nat.add(p, 1n+q), 1n+Nat.add(p, q), N.add_succ(p, q)) : {Nat.is_le(1n+p, hlf(1n+_)) == True{} : Bool}
88      hlf_lower(p, q, h)

Uses (11)

Used by (0)

No other definition uses this definition.