Returning an allocated array across a call and a later allocation #
make allocates an initialized array and returns its descriptor. retain
calls that actual body, allocates a second array, then reads the original
array's first cell when it is nonempty and returns the original descriptor.
The empty case returns directly. Both allocations remain in the final heap.
The mathematical result is ordinary Array.replicate contents, with every
old view preserved. Source termination has no capacity or time premise.
Readiness separately requires fitting values and cumulative reserved capacity;
costs compose the shared allocation, call, branch, read and return rules.
This typed source consumer adds no algorithm-specific lowering or registers.
Apply a supplied source contract with ordinary named arguments and its actual returned value and final heap. No callee body or new contract is inferred.
The same source action, without an asserted total mathematical model.
Equations
Instances For
Prove the ordinary-parameter source contract with a total-correctness triple for the same action. The ghost initial heap equals the actual entry heap; successful results use the actual final heap, and faults are excluded.
The source contract is equivalent to ordinary curried preconditions and successful result/heap postconditions, including termination and absence of faults.
The actual declared argument environment, constructed from ordinary source parameters. This is proof-side parameter transport, not an additional runtime operation.
Equations
Instances For
Apply a predicate, postcondition or bound with ordinary source parameters to the actual argument environment. No new contract or execution is introduced.
Equations
- Complexity.Language.Examples.Allocation.Named.Source.make_onArgs function✝ env✝ = function✝ env✝.head env✝.tail.head
Instances For
The named function's actual independently interpreted source body.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The source program's declared first-order signatures.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Budget-free total correctness with ordinary source parameters and relational initial/final heap postconditions. This is the existing source function contract.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The finite table of actual named source bodies.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
This named source function's index in its declared signature table.
Equations
Instances For
Equations
Instances For
The named function's actual partial source action, with ordinary typed arguments and an explicitly supplied shared heap.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One source-body equation in ordinary monadic notation; named callees remain opaque.
Ordinary arguments and the actual result observed in their real source heaps. This interface does not assert the existence of a total mathematical model.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Named allocation has an ordinary native Array specification. The shared allocation specification supplies the proof; no register or capacity appears.
The actual producer and caller signatures.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
Instances For
Allocate exactly the requested initialized native array and return its view.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The empty path returns the original descriptor without attempting a read.
Equations
Instances For
The nonempty path performs an actual read before returning the original descriptor.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Inspect the saved buffer after the second allocation, without reading an empty array.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A second allocation uses the caller's requested extra extent.
Equations
- One or more equations did not get rendered due to their size.
Instances For
This is a real call to make, followed by allocation and use of its returned buffer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Both bodies occupy the source function table used by the compiler.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
The first source allocation's actual returned handle.
Equations
- Complexity.Language.Examples.Allocation.savedBuffer heap n initial = (heap.alloc n initial).1
Instances For
The actual source heap after both allocations, without reclamation.
Equations
- Complexity.Language.Examples.Allocation.retainedHeap heap n initial extra = ((heap.alloc n initial).2.alloc extra 0).2
Instances For
The second allocation does not change the first array's mathematical contents.
A nonempty returned array is really read from the heap after the later allocation.
Producer execution terminates for all natural inputs and every initial heap.
The caller retains both allocations and returns the first descriptor.
The same theorem includes n = 0; no fake read or default cell is needed.
Every old view survives the complete caller execution by the shared frame rule, without replaying its individual allocations in this proof.
The returned empty object remains valid and has fresh identity after the later allocation.
Actual return-field copying and flag assignment for the two-word result.
Equations
Instances For
The producer pays the shared allocator's counted initialization and its return.
Equations
Instances For
Only the nonempty branch executes the heap read; branch prices come from the corresponding arena cost constructors.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The continuation's second allocation does not reuse the first allocation's capacity.
Equations
Instances For
Call overhead uses the real generated callee frame and includes its body flag initialization.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The exact producer count observes the source execution above, with backend range/capacity assumptions separated from its unconditional mathematical result.
One true source call and both allocations share a monotonically growing cursor. The exact call count is derived from the actual compiled function, not a chosen ABI price.
The actual compiled caller halts with the first array still represented after both allocations. The same final target witnesses the exact runner count, returned descriptor, extended placement and cumulative arena extent. The two-frame stack bound covers this caller and its real producer call.