law mulhi_value
import bend-osdev-word64@0.1.1.0/LAWS_mul.bend as LAWSMulimport 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
8# Multiplication. W64.mulhi(a, b) is the high 32 bits of the product of two
9# 32-bit words: with the low 32 bits (U32.mul), the whole product. W64.mul
10# is the product modulo 2^64: its value is the low 64 bits of the product of
11# the values (U32Nat.low, from bend-osdev-u32), what wraps is 2^64 times the
12# rest, and with the product no more than a word's value nothing wraps.
13law mulhi_value:
14 for +a: U32
15 for +b: U32
16 {Nat.add(U32.to_nat(U32.mul(a, b)), U.U32Nat.dbl(32n, U32.to_nat(W.W64.mulhi(a, b)))) == Nat.mul(U32.to_nat(a), U32.to_nat(b)) : Nat}