def lt_sub

bend-collections-laws-math@1.0.0.0 · proofs/math/natural/roots.bend:88

import bend-collections-laws-math@1.0.0.0/proofs/math/natural/roots.bend as Roots
import Base
import bend-collections-laws-math@1.0.0.0/proofs/lib/nat.bend as N
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/math/natural/fact.bend as F

88# b < c <= a gives a - c < a - b
89def lt_sub(+a: Nat, +b: Nat, +c: Nat, +h1: {Nat.is_lt(b, c) == True{} : Bool}, +h2: {Nat.is_le(c, a) == True{} : Bool}) -> {Nat.is_lt(Nat.sub(a, c), Nat.sub(a, b)) == True{} : Bool}:
90  match a b c:
91    case 0n 0n 0n:
92      Empty.absurd({Nat.is_lt(Nat.sub(0n, 0n), Nat.sub(0n, 0n)) == True{} : Bool}, L.false_true(h1))
93    case 0n 0n 1n+cp:
94      Empty.absurd({Nat.is_lt(Nat.sub(0n, 1n+cp), Nat.sub(0n, 0n)) == True{} : Bool}, L.false_true(h2))
95    case 0n 1n+bp 0n:
96      Empty.absurd({Nat.is_lt(Nat.sub(0n, 0n), Nat.sub(0n, 1n+bp)) == True{} : Bool}, L.false_true(h1))
97    case 0n 1n+bp 1n+cp:
98      Empty.absurd({Nat.is_lt(Nat.sub(0n, 1n+cp), Nat.sub(0n, 1n+bp)) == True{} : Bool}, L.false_true(h2))
99    case 1n+ap 0n 0n:
100      Empty.absurd({Nat.is_lt(Nat.sub(1n+ap, 0n), Nat.sub(1n+ap, 0n)) == True{} : Bool}, L.false_true(h1))
101    case 1n+ +ap 0n 1n+ +cp:
102      N.le_lt_succ(Nat.sub(ap, cp), ap, F.sub_le_self(ap, cp))
103    case 1n+ap 1n+bp 0n:
104      Empty.absurd({Nat.is_lt(Nat.sub(1n+ap, 0n), Nat.sub(1n+ap, 1n+bp)) == True{} : Bool}, L.false_true(h1))
105    case 1n+ +ap 1n+ +bp 1n+ +cp:
106      lt_sub(ap, bp, cp, h1, h2)

Uses (9)

Used by (1)