LAWS.to_nat_and_mask: law of lawful-words@0.1.0.0 Import: import lawful-words@0.1.0.0/LAWS.bend as LAWS Lines 251-260 of lawful-words@0.1.0.0/LAWS.bend: https://jend.leeeet.dev/read.txt?path=lawful-words@0.1.0.0/LAWS.bend&start_line=251&end_line=260 import Base # And with a mask of the low k bits takes the number modulo 2^k. The mask is # any word standing for 2^k - 1, so a literal such as 255 or 3 qualifies. No # word stands for 2^k - 1 when k > 32, so in practice k <= 32 (k = 32 is the # all-ones word). law to_nat_and_mask: for a: U32 for m: U32 for k: Nat for h: {U32.to_nat(m) == Nat.sub(Nat.pow(2n, k), 1n) : Nat} {U32.to_nat(U32.and(a, m)) == Nat.mod(U32.to_nat(a), Nat.pow(2n, k)) : Nat} Uses (8): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.pow https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=lawful-words@0.1.0.0/proof_u32.bend&name=to_nat_and_mask