def flatten_fits

bendtorch-core@0.1.0.0 · src/shape/boundary_proofs.bend:141

import bendtorch-core@0.1.0.0/src/shape/boundary_proofs.bend as BoundaryProofs
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/coordinate_proofs.bend as Coordinates
import bendtorch-core@0.1.0.0/src/shape/LAWS.bend as Laws

141def flatten_fits(+shape: Shape.Shape, +values: List<&2, U32>, +verdict: Shape.BoolCase<Shape.fit_words(Shape.dimensions(shape), values)>) -> {Laws.index_result(shape, Shape.flatten_checked.fits(shape, values, verdict)) == Laws.flatten_spec(Shape.extents(shape), Laws.decode(Shape.extents(shape), Shape.naturals(values))) : Maybe<&2, U32>}:
142  match verdict:
143    case Shape.BFalse{equal}:
144      %decode_unfit(Shape.extents(shape), Shape.naturals(values), fit_words_false(Shape.dimensions(shape), values, equal)) : {None{} == Laws.flatten_spec(Shape.extents(shape), _) : Maybe<&2, U32>}
145      {==}
146    case Shape.BTrue{equal}:
147      +fits = Coordinates.fits_of(Shape.extents(shape), Shape.naturals(values), fit_words_true(Shape.dimensions(shape), values, equal))
148      +coordinate = Coordinates.coordinate_of(Shape.extents(shape), Shape.naturals(values), fits)
149      +flat = Shape.horner(Shape.dimensions(shape), values, 0n)
150      %Equal.sym(Maybe<&2, Shape.Coordinate(Shape.extents(shape))>, Laws.decode(Shape.extents(shape), Shape.naturals(values)), Some{coordinate}, decode_fit(Shape.extents(shape), Shape.naturals(values), fits)) : {Laws.index_result(shape, Shape.flat_checked(shape, flat)) == Laws.flatten_spec(Shape.extents(shape), _) : Maybe<&2, U32>}
151      %horner_fits(shape, values, fits) : {Laws.index_result(shape, Shape.flat_checked(shape, flat)) == Some{U32.from_nat(_)} : Maybe<&2, U32>}
152      flat_view(shape, flat, Shape.bool_case(Nat.is_lt(flat, Shape.elements(shape))), horner_below(shape, values, fits))

Uses (30)

Used by (1)