proof_tab.bend checks
raw source on the hub · import bend-osdev-gf@0.1.2.0/proof_tab.bend as Proof_tab
Proof helpers for bend-osdev-gf: the exp/log tables (tables.bend) as lists.
The method (as bend-osdev-blockdev's ImgDev and bend-osdev-crc's tables follow their arrays): array's laws turn each table fill, write by write, into Arrays.of_list(d, l, 0) for a Data list l (of_list_new, of_list_set; the fill's counter i is U32.from_nat(i), and its running power is Gf8.exp(f, i)). The exp table's list is gt.elist(510, f, 0): entry i is Gf8.exp(f, i), for every field. The log table's list is computed for the named fields (proof_tab_cases.bend). A read of a table is then array's of_list_get: a literal pair of the same table and the list's entry. Lemmas are prefixed gt.
8 imports
import Base import bend-osdev-array@0.1.0.1/array.bend as A import bend-osdev-array@0.1.0.1/LAWS.bend as AL import bend-osdev-array@0.1.0.1/PROOF.bend as APF import ./gf.bend as G import ./tables.bend as T import bend-osdev-u32@0.1.0.0/LAWS.bend as UL import bend-osdev-u32@0.1.0.0/PROOF.bend as UP
Definitions
def gt.bt source · line 23 · raw
@b:Bool -> Type
def gt.ft source · line 30 · raw
@e:{False{} == True{} : Bool} -> Empty
def gt.tf source · line 34 · raw
@e:{True{} == False{} : Bool} -> Empty
def gt.wcon2 source · line 38 · raw
@-p:Nat -> @-a:Bool -> @-b:Bool -> @-x:Word(p) -> @-y:Word(p) -> @ea:{a == b : Bool} -> @ex:{x == y : Word(p)} -> {WCon{a, x} == WCon{b, y} : Word(1n+p)}
def gt.u32_cong source · line 43 · raw
@-x:Word(32n) -> @-y:Word(32n) -> @e:{x == y : Word(32n)} -> {U32{x} == U32{y} : U32}
def gt.adc_zero source · line 49 · raw
@n:Nat -> @w:Word(n) -> {Word.adc(n, w, Word.zero(n), False{}, False{}) == w : Word(n)}
def gt.adc_inc source · line 63 · raw
@n:Nat -> @a:Word(n) -> @b:Word(n) -> {Word.adc(n, a, Word.inc(n, b), False{}, False{}) == Word.adc(n, a, b, False{}, True{}) : Word(n)}a + (b + 1) = a + b with a carry in
def gt.adc_carry source · line 81 · raw
@n:Nat -> @a:Word(n) -> @b:Word(n) -> {Word.adc(n, a, b, False{}, True{}) == Word.inc(n, Word.adc(n, a, b, False{}, False{})) : Word(n)}a + b with a carry in is (a + b) + 1
def gt.add_zero source · line 98 · raw
@x:U32 -> {U32.add(x, 0) == x : U32}
def gt.add_inc source · line 103 · raw
@a:U32 -> @b:U32 -> {U32.add(a, U32.inc(b)) == U32.inc(U32.add(a, b)) : U32}
def gt.add_one source · line 109 · raw
@+x:U32 -> {U32.add(x, 1) == U32.inc(x) : U32}the fills' counter: i + 1 is the increment
def gt.add_nat source · line 114 · raw
@+p:Nat -> @+q:Nat -> {U32.add(U32.from_nat(p), U32.from_nat(q)) == U32.from_nat(Nat.add(q, p)) : U32}the sum of two counts, as U32, is the U32 of their sum
def gt.lt_succ_r source · line 124 · raw
@+x:Nat -> @+y:Nat -> @h:{Nat.is_lt(x, y) == True{} : Bool} -> {Nat.is_lt(x, 1n+y) == True{} : Bool}
def gt.lt_self source · line 133 · raw
@+x:Nat -> {Nat.is_lt(x, 1n+x) == True{} : Bool}
def gt.lt_self_add source · line 141 · raw
@+n:Nat -> @+x:Nat -> {Nat.is_lt(x, 1n+Nat.add(n, x)) == True{} : Bool}x < 1 + (n + x)
def gt.lt_add_left source · line 149 · raw
@+m:Nat -> @+b:Nat -> @+n:Nat -> @+h:{Nat.is_lt(b, n) == True{} : Bool} -> {Nat.is_lt(b, Nat.add(m, n)) == True{} : Bool}b < n, so b < m + n
def gt.lt_sum source · line 157 · raw
@+a:Nat -> @+m:Nat -> @+b:Nat -> @+n:Nat -> @ha:{Nat.is_lt(a, m) == True{} : Bool} -> @+hb:{Nat.is_lt(b, n) == True{} : Bool} -> {Nat.is_lt(Nat.add(a, b), Nat.add(m, n)) == True{} : Bool}a < m and b < n, so a + b < m + n
def gt.sum_lt source · line 167 · raw
@+a:Nat -> @+b:Nat -> @+ha:{Nat.is_lt(a, 255n) == True{} : Bool} -> @+hb:{Nat.is_lt(b, 255n) == True{} : Bool} -> {Nat.is_lt(Nat.add(a, b), 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(9n)) == True{} : Bool}two logarithms (each below 255) sum below the exp table's 2^9 slots
def gt.log_go_lt source · line 172 · raw
@+n:Nat -> @hit:Bool -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+a:U32 -> @+cur:U32 -> @+i:Nat -> {Nat.is_lt(0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8.log.go(n, hit, f, a, cur, i), 1n+Nat.add(n, i)) == True{} : Bool}
def gt.log_lt source · line 182 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+a:U32 -> {Nat.is_lt(0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8.log(f, a), 255n) == True{} : Bool}
def gt.hd9 source · line 187 · raw
{Nat.is_lt(9n, 32n) == True{} : Bool}
def gt.hd8 source · line 190 · raw
{Nat.is_lt(8n, 32n) == True{} : Bool}
def gt.hl_set source · line 193 · raw
@+d:Nat -> @+xs:List<&2, U32> -> @+k:Nat -> @+v:U32 -> @+hl:{List.length(&2, U32, xs) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(d) : Nat} -> {List.length(&2, U32, List.set(&2, U32, xs, k, v)) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(d) : Nat}
def gt.fe source · line 197 · raw
@n:Nat -> @xs:List<&2, U32> -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+k:Nat -> List<&2, U32>
the exp fill's model: slot i (from slot k) holds gen^i
def gt.fill_exp source · line 204 · raw
@n:Nat -> @+xs:List<&2, U32> -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+k:Nat -> @+hl:{List.length(&2, U32, xs) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(9n) : Nat} -> {0x7a66255b2e354c73838e88d45f7d1593/tables.gf8tab.fill.exp(n, 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.of_list(U32, 9n, xs, 0), f, 0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8.exp(f, k), U32.from_nat(k)) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.of_list(U32, 9n, gt.fe(n, xs, f, k), 0) : Array<U32>}
def gt.fl source · line 214 · raw
@n:Nat -> @xs:List<&2, U32> -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+k:Nat -> List<&2, U32>
the log fill's model: slot gen^i holds i, from i = k
def gt.fill_log source · line 221 · raw
@n:Nat -> @+xs:List<&2, U32> -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+k:Nat -> @+hl:{List.length(&2, U32, xs) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(8n) : Nat} -> {0x7a66255b2e354c73838e88d45f7d1593/tables.gf8tab.fill.log(n, 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.of_list(U32, 8n, xs, 0), f, 0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8.exp(f, k), U32.from_nat(k)) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.of_list(U32, 8n, gt.fl(n, xs, f, k), 0) : Array<U32>}
def gt.elist source · line 232 · raw
@n:Nat -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+k:Nat -> List<&2, U32>
def gt.elist_model source · line 239 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> {gt.fe(510n, List.replicate(U32, 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(9n), 0), f, 0n) == gt.elist(510n, f, 0n) : List<&2, U32>}
def gt.rep_len source · line 242 · raw
@+n:Nat -> {List.length(&2, U32, List.replicate(U32, n, 0)) == n : Nat}
def gt.hl_rep source · line 250 · raw
@+d:Nat -> {List.length(&2, U32, List.replicate(U32, 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(d), 0)) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(d) : Nat}
def gt.hl_elist source · line 253 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> {List.length(&2, U32, gt.elist(510n, f, 0n)) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(9n) : Nat}
def gt.f0 source · line 256 · raw
{U32.from_nat(0n) == 0 : U32}
def gt.e0 source · line 259 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> {0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8.exp(f, 0n) == 1 : U32}
def gt.exp_table source · line 265 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+e0:{0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab.exp_table(f) == 0x7a66255b2e354c73838e88d45f7d1593/tables.gf8tab.fill.exp(510n, Array.new(U32, 9n, 0), f, 1, 0) : Array<U32>} -> {0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab.exp_table(f) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.of_list(U32, 9n, gt.elist(510n, f, 0n), 0) : Array<U32>}the exp table of a field f, given that it is its fill (for a named field that is computation, proof_tab_cases.bend; it is stated per field because --verdict's kernel compares the two sides by running them)
def gt.elist_nth source · line 274 · raw
@+n:Nat -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+k:Nat -> @+j:Nat -> @h:{Nat.is_lt(j, n) == True{} : Bool} -> {0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.nth(U32, gt.elist(n, f, k), j, 0) == 0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8.exp(f, Nat.add(j, k)) : U32}entry j of the exp table's list is gen^j, for j < 510
def gt.log_table source · line 288 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+l:List<&2, U32> -> @+e0:{0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab.log_table(f) == 0x7a66255b2e354c73838e88d45f7d1593/tables.gf8tab.fill.log(255n, Array.new(U32, 8n, 0), f, 1, 0) : Array<U32>} -> @+e:{gt.fl(255n, List.replicate(U32, 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(8n), 0), f, 0n) == l : List<&2, U32>} -> {0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab.log_table(f) == 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.of_list(U32, 8n, l, 0) : Array<U32>}
def gt.fl_split source · line 297 · raw
@+n:Nat -> @+m:Nat -> @xs:List<&2, U32> -> @+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+k:Nat -> {gt.fl(Nat.add(n, m), xs, f, k) == gt.fl(m, gt.fl(n, xs, f, k), f, Nat.add(n, k)) : List<&2, U32>}the log fill splits: n + m writes are n writes, then m more
def gt.tab source · line 307 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+l:List<&2, U32> -> 0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab
def gt.new source · line 310 · raw
@+f:0x7a66255b2e354c73838e88d45f7d1593/gf.Gf8Field -> @+l:List<&2, U32> -> @+ex0:{0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab.exp_table(f) == 0x7a66255b2e354c73838e88d45f7d1593/tables.gf8tab.fill.exp(510n, Array.new(U32, 9n, 0), f, 1, 0) : Array<U32>} -> @+el0:{0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab.log_table(f) == 0x7a66255b2e354c73838e88d45f7d1593/tables.gf8tab.fill.log(255n, Array.new(U32, 8n, 0), f, 1, 0) : Array<U32>} -> @+e:{gt.fl(255n, List.replicate(U32, 0xf8d2948fe25df08ae8d37c3c80a363ba/array.Arrays.slots(8n), 0), f, 0n) == l : List<&2, U32>} -> {gt.tab(f, l) == 0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab.new(f) : 0x7a66255b2e354c73838e88d45f7d1593/tables.Gf8Tab}