Lamport transfers #
A transfer moves lamports from one account to another. Two preconditions are carried in the type signature, one per arithmetic edge:
h_under : amount ≤ src.lamports— the source has enough to send.h_over : dst.lamports.toNat + amount.toNat < UInt64.size— the destination won't overflowu64after the credit.
Both bounds together guarantee the underlying UInt64 add and sub
operations do not wrap, so the conservation theorem holds in the
"natural" arithmetic sense.
Main definitions #
TransferResult— pair of (source,destination) accounts after a transfer.transfer— the operation, taking both bounds proofs explicitly.
Main statements #
transfer_preserves_total— total lamports (asNat, via.toNat) across source and destination is invariant undertransfer. Conservation is stated inLamportsUnchecked(Nat) world soomegacloses the arithmetic; the bridge fromLamportslives inAccount.credit_lamports_toNatandAccount.debit_lamports_toNat.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Move amount lamports from src to dst.
Carries two preconditions in its type:
h_under—srchas at leastamountlamports (no underflow on debit).h_over— addingamounttodstdoes not overflowu64(no wrap on credit).
The compiler will reject any call site that hasn't proved both.
Equations
Instances For
Lamport conservation. A transfer neither creates nor destroys
lamports: the .toNat sum across source and destination after the
operation equals the original .toNat sum.
The statement uses .toNat (i.e. LamportsUnchecked = Nat) so the
arithmetic is unbounded — that's what omega reasons about. The
UInt64-level operations are well-defined by the h_under / h_over
preconditions; conservation in u64 arithmetic also holds, but is a
corollary not stated here.