law add_wrap
import bend-osdev-word64@0.1.1.0/LAWS.bend as LAWSimport Base
import bend-osdev-u32@0.1.0.0/u32.bend as U
import bend-osdev-word64@0.1.1.0/word64.bend as W
125# Addition, for every pair of words: the sum of the values, less 2^64 when
126# it wraps, which is exactly when the result is below the first operand;
127# and with the sum no more than a word's value, it does not wrap.
128law add_wrap:
129 for +a: W.W64
130 for +b: W.W64
131 {Nat.add(W.W64.to_nat(W.W64.add(a, b)), U.U32Nat.dbl(64n, U.U32Nat.bit(W.W64.is_lt(W.W64.add(a, b), a)))) == Nat.add(W.W64.to_nat(a), W.W64.to_nat(b)) : Nat}
Uses (17)
Used by (0)
No other definition uses this definition.