def kept_hit

bendtorch-core@0.1.0.0 · src/autograd/reduce_fiber_proof.bend:770

import bendtorch-core@0.1.0.0/src/autograd/reduce_fiber_proof.bend as ReduceFiberProof
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/broadcast_proofs.bend as Broadcast

770# On a kept row, the blocks from `digit` that cover the target's digit hold
771# exactly the rows below at the target's remainder.
772def kept_hit(+f: Nat, +stride: Nat, +left: Nat, +right: Nat, +rest: List<&2, Shape.Row>, +target: Nat, +base: Nat, +digit: Nat,
773  +from: {Nat.is_le(digit, Nat.div(target, left)) == True{} : Bool},
774  +until: {Nat.is_lt(Nat.div(target, left), Nat.add(digit, f)) == True{} : Bool},
775  +given: Decomposed<target, left>, +bound: BoundBy<rest, left, stride>) ->
776  {masked(Nat.mul(f, stride), Shape.Row{stride, left, right} <> rest, target, base, Nat.mul(digit, stride)) ==
777    masked(stride, rest, Nat.mod(target, left), Nat.add(base, Nat.mul(right, Nat.div(target, left))), 0n) : List<&2, Nat>}:
778  match f:
779    case 0n:
780      Empty.absurd({masked(0n, Shape.Row{stride, left, right} <> rest, target, base, Nat.mul(digit, stride)) ==
781        masked(stride, rest, Nat.mod(target, left), Nat.add(base, Nat.mul(right, Nat.div(target, left))), 0n) : List<&2, Nat>},
782        le_lt_absurd(digit, Nat.div(target, left), from,
783          %Broadcast.add_zero(digit) : {Nat.is_lt(Nat.div(target, left), _) == True{} : Bool}
784          until))
785    case 1n+g:
786      kept_hit_step(g, stride, left, right, rest, target, base, digit, Shape.bool_case(Nat.is_eq(digit, Nat.div(target, left))),
787        from, until, given, bound,
788        next => from => until => kept_hit(g, stride, left, right, rest, target, base, next, from, until, given, bound))

Uses (19)

Used by (1)