~/bend-docscommunity

proof_zb.bend checks

raw source on the hub · import lawful-words@0.1.0.0/proof_zb.bend as Proof_zb

4 imports
import Base
import ./defs.bend as D
import ./proof_nat.bend as N
import ./proof_u32.bend as U

Laws

law allz_cmp provedsource · line 40 · raw

@+n:Nat -> @+w:Word(n) -> {Cmp.is_eq(Word.cmp(n, w, Word.zero(n))) == allz(n, w) : Bool}

law allz_andz provedsource · line 66 · raw

@+n:Nat -> @+r:Word(n) -> {allz(n, Word.and(n, r, Word.zero(n))) == True{} : Bool}

law zb_byte provedsource · line 85 · raw

@+n:Nat -> @+x:Word(8n) -> @+r:Word(n) -> @+kr:Word(n) -> @+hr:Word(n) -> {allz(Nat.add(8n, n), zf(Nat.add(8n, n), app8(n, x, r), app8(n, one8, kr), app8(n, h8, hr), True{})) == Bool.and(Bool.not(allz(8n, x)), allz(n, zf(n, r, kr, hr, True{}))) : Bool}

One byte of the zero-byte test, with no borrow in.

law allz_mask provedsource · line 610 · raw

@+n:Nat -> @+x:Word(8n) -> @+r:Word(n) -> {allz(Nat.add(8n, n), Word.and(Nat.add(8n, n), app8(n, x, r), app8(n, ones8, Word.zero(n)))) == Bool.and(allz(8n, x), allz(n, Word.and(n, r, Word.zero(n)))) : Bool}

A byte masked with 255.

law zb_zero provedsource · line 1132 · raw

@+v:U32 -> {U32.is_zero(0x5845906e4d684390fe5255aea46f9808/defs.zb(v)) == Bool.and(U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(v, 0n), 0), Bool.and(U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(v, 1n), 0), Bool.and(U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(v, 2n), 0), U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(v, 3n), 0)))) : Bool}

Definitions

def allz source · line 12 · raw

@n:Nat -> @w:Word(n) -> Bool

All bits clear.

def app8 source · line 22 · raw

@-n:Nat -> @x:Word(8n) -> @r:Word(n) -> Word(Nat.add(8n, n))

Eight bits x in front of r.

def one8 source · line 27 · raw

Word(8n)

def h8 source · line 30 · raw

Word(8n)

def ones8 source · line 33 · raw

Word(8n)

def zf source · line 37 · raw

@+n:Nat -> @+v:Word(n) -> @k:Word(n) -> @h:Word(n) -> @c:Bool -> Word(n)

The zero-byte flags of v with subtrahend k, flag mask h and carry in c.

def zb_ne0 source · line 1136 · raw

@+c0:Bool -> @+c1:Bool -> @+c2:Bool -> @+c3:Bool -> @+c4:Bool -> @+c5:Bool -> @+c6:Bool -> @+c7:Bool -> @+c8:Bool -> @+c9:Bool -> @+c10:Bool -> @+c11:Bool -> @+c12:Bool -> @+c13:Bool -> @+c14:Bool -> @+c15:Bool -> @+c16:Bool -> @+c17:Bool -> @+c18:Bool -> @+c19:Bool -> @+c20:Bool -> @+c21:Bool -> @+c22:Bool -> @+c23:Bool -> @+c24:Bool -> @+c25:Bool -> @+c26:Bool -> @+c27:Bool -> @+c28:Bool -> @+c29:Bool -> @+c30:Bool -> @+c31:Bool -> {U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(U32{WCon{c0, WCon{c1, WCon{c2, WCon{c3, WCon{c4, WCon{c5, WCon{c6, WCon{c7, WCon{c8, WCon{c9, WCon{c10, WCon{c11, WCon{c12, WCon{c13, WCon{c14, WCon{c15, WCon{c16, WCon{c17, WCon{c18, WCon{c19, WCon{c20, WCon{c21, WCon{c22, WCon{c23, WCon{c24, WCon{c25, WCon{c26, WCon{c27, WCon{c28, WCon{c29, WCon{c30, WCon{c31, WNil{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}, 0n), 0) == Bool.not(allz(8n, WCon{c0, WCon{c1, WCon{c2, WCon{c3, WCon{c4, WCon{c5, WCon{c6, WCon{c7, WNil{}}}}}}}}})) : Bool}

def zb_ne1 source · line 1146 · raw

@+c0:Bool -> @+c1:Bool -> @+c2:Bool -> @+c3:Bool -> @+c4:Bool -> @+c5:Bool -> @+c6:Bool -> @+c7:Bool -> @+c8:Bool -> @+c9:Bool -> @+c10:Bool -> @+c11:Bool -> @+c12:Bool -> @+c13:Bool -> @+c14:Bool -> @+c15:Bool -> @+c16:Bool -> @+c17:Bool -> @+c18:Bool -> @+c19:Bool -> @+c20:Bool -> @+c21:Bool -> @+c22:Bool -> @+c23:Bool -> @+c24:Bool -> @+c25:Bool -> @+c26:Bool -> @+c27:Bool -> @+c28:Bool -> @+c29:Bool -> @+c30:Bool -> @+c31:Bool -> {U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(U32{WCon{c0, WCon{c1, WCon{c2, WCon{c3, WCon{c4, WCon{c5, WCon{c6, WCon{c7, WCon{c8, WCon{c9, WCon{c10, WCon{c11, WCon{c12, WCon{c13, WCon{c14, WCon{c15, WCon{c16, WCon{c17, WCon{c18, WCon{c19, WCon{c20, WCon{c21, WCon{c22, WCon{c23, WCon{c24, WCon{c25, WCon{c26, WCon{c27, WCon{c28, WCon{c29, WCon{c30, WCon{c31, WNil{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}, 1n), 0) == Bool.not(allz(8n, WCon{c8, WCon{c9, WCon{c10, WCon{c11, WCon{c12, WCon{c13, WCon{c14, WCon{c15, WNil{}}}}}}}}})) : Bool}

def zb_ne2 source · line 1156 · raw

@+c0:Bool -> @+c1:Bool -> @+c2:Bool -> @+c3:Bool -> @+c4:Bool -> @+c5:Bool -> @+c6:Bool -> @+c7:Bool -> @+c8:Bool -> @+c9:Bool -> @+c10:Bool -> @+c11:Bool -> @+c12:Bool -> @+c13:Bool -> @+c14:Bool -> @+c15:Bool -> @+c16:Bool -> @+c17:Bool -> @+c18:Bool -> @+c19:Bool -> @+c20:Bool -> @+c21:Bool -> @+c22:Bool -> @+c23:Bool -> @+c24:Bool -> @+c25:Bool -> @+c26:Bool -> @+c27:Bool -> @+c28:Bool -> @+c29:Bool -> @+c30:Bool -> @+c31:Bool -> {U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(U32{WCon{c0, WCon{c1, WCon{c2, WCon{c3, WCon{c4, WCon{c5, WCon{c6, WCon{c7, WCon{c8, WCon{c9, WCon{c10, WCon{c11, WCon{c12, WCon{c13, WCon{c14, WCon{c15, WCon{c16, WCon{c17, WCon{c18, WCon{c19, WCon{c20, WCon{c21, WCon{c22, WCon{c23, WCon{c24, WCon{c25, WCon{c26, WCon{c27, WCon{c28, WCon{c29, WCon{c30, WCon{c31, WNil{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}, 2n), 0) == Bool.not(allz(8n, WCon{c16, WCon{c17, WCon{c18, WCon{c19, WCon{c20, WCon{c21, WCon{c22, WCon{c23, WNil{}}}}}}}}})) : Bool}

def zb_ne3 source · line 1166 · raw

@+c0:Bool -> @+c1:Bool -> @+c2:Bool -> @+c3:Bool -> @+c4:Bool -> @+c5:Bool -> @+c6:Bool -> @+c7:Bool -> @+c8:Bool -> @+c9:Bool -> @+c10:Bool -> @+c11:Bool -> @+c12:Bool -> @+c13:Bool -> @+c14:Bool -> @+c15:Bool -> @+c16:Bool -> @+c17:Bool -> @+c18:Bool -> @+c19:Bool -> @+c20:Bool -> @+c21:Bool -> @+c22:Bool -> @+c23:Bool -> @+c24:Bool -> @+c25:Bool -> @+c26:Bool -> @+c27:Bool -> @+c28:Bool -> @+c29:Bool -> @+c30:Bool -> @+c31:Bool -> {U32.is_ne(0x5845906e4d684390fe5255aea46f9808/defs.byte(U32{WCon{c0, WCon{c1, WCon{c2, WCon{c3, WCon{c4, WCon{c5, WCon{c6, WCon{c7, WCon{c8, WCon{c9, WCon{c10, WCon{c11, WCon{c12, WCon{c13, WCon{c14, WCon{c15, WCon{c16, WCon{c17, WCon{c18, WCon{c19, WCon{c20, WCon{c21, WCon{c22, WCon{c23, WCon{c24, WCon{c25, WCon{c26, WCon{c27, WCon{c28, WCon{c29, WCon{c30, WCon{c31, WNil{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}, 3n), 0) == Bool.not(allz(8n, WCon{c24, WCon{c25, WCon{c26, WCon{c27, WCon{c28, WCon{c29, WCon{c30, WCon{c31, WNil{}}}}}}}}})) : Bool}