def attached_point
bendtorch-core@0.1.0.0 · src/tensor/construction_contract_PROOF.bend:58
import bendtorch-core@0.1.0.0/src/tensor/construction_contract_PROOF.bend as ConstructionContractPROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/nat_proofs.bend as Nats
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/allocation_PROOF.bend as AllocationProof
import bendtorch-core@0.1.0.0/src/tensor/observation.bend as Observation
58def attached_point(+shape: Shape.Shape, +fill: F32, +index: U32, +length: Nat,
59 decision: Shape.BoolCase<Nat.is_eq(length, Shape.elements(shape))>, storage: Storage.Storage,
60 -exact: {Lifecycle.logical_length(storage) == length : Nat},
61 counted: {length == Shape.elements(shape) : Nat},
62 value: {Lifecycle.read_value(Storage.get(storage, index)) == Some{fill} : Maybe<&2, F32>}) ->
63 {Observation.point(shape, index, Core.attach_decided(shape, storage, length, exact, decision)) == Some{fill} : Maybe<&2, F32>}:
64 match decision:
65 case Shape.BFalse{no}:
66 Empty.absurd({None{} == Some{fill} : Maybe<&2, F32>},
67 Nats.contradiction(Nat.is_eq(length, Shape.elements(shape)),
68 AllocationProof.natural_equal_true(length, Shape.elements(shape), counted), no))
69 case Shape.BTrue{yes}:
70 Equal.trans(Maybe<&2, F32>,
71 Observation.point(shape, index, Core.attach_decided(shape, storage, length, exact, Shape.BTrue{yes})),
72 Lifecycle.read_value(Storage.get(storage, index)), Some{fill},
73 Core.read_result_value(shape, storage,
74 Equal.trans(Nat, Lifecycle.logical_length(storage), length, Shape.logical_numel(Shape.dimensions(shape)), exact,
75 Equal.trans(Nat, length, Shape.elements(shape), Shape.logical_numel(Shape.dimensions(shape)),
76 Lifecycle.natural_equal(length, Shape.elements(shape), yes), Shape.elements_exact(shape))),
77 index, Storage.get(storage, index), {==}), value)