def covered

bendtorch-core@0.1.0.0 · src/tensor/slice_PROOF.bend:195

import bendtorch-core@0.1.0.0/src/tensor/slice_PROOF.bend as SlicePROOF
import Base
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
import bendtorch-core@0.1.0.0/src/tensor/contracts/build_facts.bend as Facts
import bendtorch-core@0.1.0.0/src/tensor/elementwise_walk_proof.bend as Walk
import bendtorch-core@0.1.0.0/src/autograd/reduce_fiber_proof.bend as Fiber

195# 1 + rest <= step + (rest / step) * step for a positive step: rest's
196# remainder is below the step.
197def covered(+rest: Nat, +s: Nat, given: Fiber.Decomposed<rest, 1n+s>) ->
198  {Nat.is_le(1n+rest, Nat.add(1n+s, Nat.mul(Nat.div(rest, 1n+s), 1n+s))) == True{} : Bool}:
199  Fiber.Decomposed{below, sum} = given
200  +q = Nat.mul(Nat.div(rest, 1n+s), 1n+s)
201  %sum : {Nat.is_le(1n+_, Nat.add(1n+s, q)) == True{} : Bool}
202  %Walk.add_comm(q, 1n+s) : {Nat.is_le(1n+Nat.add(q, Nat.mod(rest, 1n+s)), _) == True{} : Bool}
203  %Arith.add_succ(q, Nat.mod(rest, 1n+s)) : {Nat.is_le(_, Nat.add(q, 1n+s)) == True{} : Bool}
204  Facts.le_add_cong(q, 1n+Nat.mod(rest, 1n+s), 1n+s, lt_le_succ(Nat.mod(rest, 1n+s), 1n+s, below))

Uses (12)

Used by (1)