LAWS_div.bend open laws/TODOs
raw source on the hub · import bend-osdev-word64@0.1.1.0/LAWS_div.bend as LAWS_div
bend-osdev-word64's laws of division, for every input: W64.div and W64.mod are the Nat quotient and remainder, and division by 0 gives 0 and the dividend. Proved in PROOF_div.bend.
3 imports
import Base import bend-osdev-u32@0.1.0.0/u32.bend as U import ./word64.bend as W
Laws
law divmod_value provedin PROOF_div.bendsource · line 11 · raw
@+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+b:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @h:{0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.is_zero(b) == False{} : Bool} -> {Nat.add(Nat.mul(0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.to_nat(0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.div(a, b)), 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.to_nat(b)), 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.to_nat(0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.mod(a, b))) == 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.to_nat(a) : Nat}Division (shift and subtract, 64 steps): for b not 0, the quotient and the remainder are the Nat ones, a = q b + r with r < b; by 0, the quotient is 0 and the remainder a.
law mod_lt provedin PROOF_div.bendsource · line 17 · raw
@+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+b:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @h:{0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.is_zero(b) == False{} : Bool} -> {Nat.is_lt(0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.to_nat(0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.mod(a, b)), 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.to_nat(b)) == True{} : Bool}
law div_zero provedin PROOF_div.bendsource · line 23 · raw
@+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> {0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.div(a, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.zero) == 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.zero : 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64}
law mod_zero provedin PROOF_div.bendsource · line 27 · raw
@+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> {0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.mod(a, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64.zero) == a : 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64}