proof_enc.bend checks
raw source on the hub · import 0xeb25eff332574f4f1d48668b83cdda30/proof_enc.bend as Proof_enc
Proofs for bend-osdev-asn1: decoding what the encoder wrote gives the elements back, under any rules they conform to. Element by element: the header reads back (proof_head.bend), the contents octets are taken, a constructed element's contents decode to its elements (the induction), and the rules' checks pass because the value conforms.
17 imports
import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B import bend-osdev-bytes@0.1.0.0/LAWS.bend as BL import ./error.bend as E import ./number.bend as Nu import ./tag.bend as T import ./length.bend as L import ./node.bend as N import ./rules.bend as R import ./encode.bend as En import ./conform.bend as C import ./asn1.bend as A import ./proof_nat.bend as AN import ./proof_list.bend as AL import ./proof_u32.bend as AU import ./proof_num.bend as PN import ./proof_head.bend as PH
Definitions
def pe.fix_b source · line 26 · raw
@+k:Nat -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.byte(0xeb25eff332574f4f1d48668b83cdda30/number.a1.b(k)) == 0xeb25eff332574f4f1d48668b83cdda30/number.a1.b(k) : U32}
def pe.fix_bytes_of source · line 29 · raw
@ds:List<&2, Nat> -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/number.a1.bytes_of(ds)) == 0xeb25eff332574f4f1d48668b83cdda30/number.a1.bytes_of(ds) : List<&2, U32>}
def pe.fix_enc128 source · line 38 · raw
@ds:List<&2, Nat> -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/number.a1.enc128(ds)) == 0xeb25eff332574f4f1d48668b83cdda30/number.a1.enc128(ds) : List<&2, U32>}
def pe.fix_id.go source · line 54 · raw
@lt:Bool -> @+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> @+hl:{Nat.is_lt(n, 31n) == lt : Bool} -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/tag.a1.id_bytes(c, cons, n)) == 0xeb25eff332574f4f1d48668b83cdda30/tag.a1.id_bytes(c, cons, n) : List<&2, U32>}
def pe.fix_id source · line 69 · raw
@+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/tag.a1.id_bytes(c, cons, n)) == 0xeb25eff332574f4f1d48668b83cdda30/tag.a1.id_bytes(c, cons, n) : List<&2, U32>}
def pe.fix_len.go source · line 72 · raw
@lt:Bool -> @+n:Nat -> @+hl:{Nat.is_lt(n, 128n) == lt : Bool} -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/length.a1.len_bytes(n)) == 0xeb25eff332574f4f1d48668b83cdda30/length.a1.len_bytes(n) : List<&2, U32>}
def pe.fix_len source · line 86 · raw
@+n:Nat -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/length.a1.len_bytes(n)) == 0xeb25eff332574f4f1d48668b83cdda30/length.a1.len_bytes(n) : List<&2, U32>}
def pe.mask_tlv source · line 90 · raw
@+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> @+cs:List<&2, U32> -> @+rest:List<&2, U32> -> @+hcs:{0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(cs) == cs : List<&2, U32>} -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/encode.a1.tlv(c, cons, n, cs, rest)) == 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.tlv(c, cons, n, cs, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(rest)) : List<&2, U32>}masking an element's octets masks only what follows its contents
def pe.mask_enc source · line 103 · raw
@ns:List<&2, 0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node> -> @+tail:List<&2, U32> -> {0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_list(ns, tail)) == 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_list(ns, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.mask(tail)) : List<&2, U32>}masking the encoder's octets changes nothing but the tail
def pe.mdisc source · line 120 · raw
@m:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> Type
def pe.sn source · line 127 · raw
@-x:0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error -> @e:{Some{x} == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> Empty
def pe.first_l source · line 131 · raw
@a:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> @-b:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> @+h:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.first(a, b) == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> {a == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>}
def pe.first_r source · line 138 · raw
@a:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> @-b:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> @+h:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.first(a, b) == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> {b == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>}
def pe.u0 source · line 146 · raw
@u0:Bool -> @-idok:Bool -> @-ok:Bool -> @+h:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.node_err.pick(u0, idok, ok) == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> {u0 == False{} : Bool}
def pe.idk source · line 153 · raw
@u0:Bool -> @idok:Bool -> @-ok:Bool -> @+h:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.node_err.pick(u0, idok, ok) == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> {idok == True{} : Bool}
def pe.lok source · line 162 · raw
@u0:Bool -> @idok:Bool -> @ok:Bool -> @+h:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.node_err.pick(u0, idok, ok) == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> {ok == True{} : Bool}
def pe.id_ne.go source · line 176 · raw
@lt:Bool -> @+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> @+hl:{Nat.is_lt(n, 31n) == lt : Bool} -> {Nat.is_le(1n, List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/tag.a1.id_bytes(c, cons, n))) == True{} : Bool}
def pe.id_ne source · line 185 · raw
@+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> {Nat.is_le(1n, List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/tag.a1.id_bytes(c, cons, n))) == True{} : Bool}
def pe.lt_plus source · line 188 · raw
@+a:Nat -> @+x:Nat -> @+y:Nat -> @+ha:{Nat.is_le(1n, a) == True{} : Bool} -> @+hx:{Nat.is_le(x, y) == True{} : Bool} -> {Nat.is_lt(x, Nat.add(a, y)) == True{} : Bool}
def pe.len_tlv source · line 196 · raw
@+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> @+cs:List<&2, U32> -> @+rest:List<&2, U32> -> {List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.tlv(c, cons, n, cs, rest)) == Nat.add(List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/tag.a1.id_bytes(c, cons, n)), Nat.add(List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/length.a1.len_bytes(List.length(&2, U32, cs))), Nat.add(List.length(&2, U32, cs), List.length(&2, U32, rest)))) : Nat}the length of an element's octets
def pe.lt_tlv_rest source · line 206 · raw
@+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> @+cs:List<&2, U32> -> @+rest:List<&2, U32> -> {Nat.is_lt(List.length(&2, U32, rest), List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.tlv(c, cons, n, cs, rest))) == True{} : Bool}
def pe.lt_tlv_cs source · line 213 · raw
@+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+cons:Bool -> @+n:Nat -> @+cs:List<&2, U32> -> @+rest:List<&2, U32> -> {Nat.is_lt(List.length(&2, U32, cs), List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.tlv(c, cons, n, cs, rest))) == True{} : Bool}
def pe.fuel_in source · line 221 · raw
@+x:Nat -> @+len:Nat -> @+g:Nat -> @+hx:{Nat.is_lt(x, len) == True{} : Bool} -> @+hf:{Nat.is_lt(len, 1n+g) == True{} : Bool} -> {Nat.is_lt(x, g) == True{} : Bool}fuel above an element's octets is fuel above what is inside it
def pe.no_fuel source · line 224 · raw
@+x:Nat -> @+hf:{Nat.is_lt(x, 0n) == True{} : Bool} -> Empty
def pe.all source · line 229 · raw
@ns:List<&2, 0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node> -> @f:Nat -> @+r:0xeb25eff332574f4f1d48668b83cdda30/rules.Asn1Rules -> @+herr:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_err(ns) == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> @+hconf:{0xeb25eff332574f4f1d48668b83cdda30/conform.a1.conf_list(ns, r) == True{} : Bool} -> @+hf:{Nat.is_lt(List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_list(ns, [])), f) == True{} : Bool} -> {0xeb25eff332574f4f1d48668b83cdda30/asn1.a1.dec(f, r, 0xeb25eff332574f4f1d48668b83cdda30/asn1.A1All{}, 0xeb25eff332574f4f1d48668b83cdda30/asn1.a1.head(r, 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_list(ns, []))) == Done{0xeb25eff332574f4f1d48668b83cdda30/asn1.A1Out{ns, []}} : Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0xeb25eff332574f4f1d48668b83cdda30/asn1.A1Out>}Decoding the encoder's octets of elements ns, to the end of the input, gives ns back (the induction runs over the elements and their contents)
def pe.one source · line 301 · raw
@x0:0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node -> @f:Nat -> @+r:0xeb25eff332574f4f1d48668b83cdda30/rules.Asn1Rules -> @+herr:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_err([x0]) == None{} : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> @+hconf:{0xeb25eff332574f4f1d48668b83cdda30/conform.a1.conf_list([x0], r) == True{} : Bool} -> @+hf:{Nat.is_lt(List.length(&2, U32, 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_list([x0], [])), f) == True{} : Bool} -> {0xeb25eff332574f4f1d48668b83cdda30/asn1.a1.dec(f, r, 0xeb25eff332574f4f1d48668b83cdda30/asn1.A1One{}, 0xeb25eff332574f4f1d48668b83cdda30/asn1.a1.head(r, 0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_list([x0], []))) == Done{0xeb25eff332574f4f1d48668b83cdda30/asn1.A1Out{[x0], []}} : Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0xeb25eff332574f4f1d48668b83cdda30/asn1.A1Out>}decoding one element the encoder wrote gives it back
def pe.odisc source · line 354 · raw
@r:Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets> -> Type
def pe.fd source · line 361 · raw
@-x:0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error -> @-y:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @e:{Fail{x} == Done{y} : Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>} -> Empty
def pe.od source · line 365 · raw
@r:Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets> -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets
def pe.de source · line 373 · raw
@m:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> @+r:0xeb25eff332574f4f1d48668b83cdda30/rules.Asn1Rules -> @+x0:0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node -> @-b:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @+em:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.enc_err([x0]) == m : Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>} -> @+e:{0xeb25eff332574f4f1d48668b83cdda30/encode.a1.encode.go(m, [x0]) == Done{b} : Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>} -> @+hc:{0xeb25eff332574f4f1d48668b83cdda30/conform.a1.conf_list([x0], r) == True{} : Bool} -> {0xeb25eff332574f4f1d48668b83cdda30/asn1.Asn1.decode(r, b) == Done{x0} : Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node>}decode after encode