Package byte: Bytes
Information
name | byte |
version | 1.134 |
description | Bytes |
author | Joe Leslie-Hurd <joe@gilith.com> |
license | MIT |
homepage | http://opentheory.gilith.com/?pkg=byte |
hol-light-int-file | hol-light.int |
hol-light-thm-file | hol-light.art |
haskell-int-file | haskell.int |
haskell-src-file | haskell.art |
haskell-equality-type | "Data.Byte.byte" |
haskell-arbitrary-type | "Data.Byte.byte" |
checksum | 6d38785df4ac50458193ff322a469fa4fec5c9f8 |
requires | base natural-bits natural-divides probability |
show | Data.Bool Data.Byte Data.Byte.Bits Data.List Number.Natural Probability.Random |
Files
- Package tarball byte-1.134.tgz
- Theory source file byte.thy (included in the package tarball)
Defined Type Operator
- Data
- Byte
- byte
- Byte
Defined Constants
- Data
- Byte
- *
- +
- -
- <
- ≤
- ↑
- ~
- and
- bit
- fromNatural
- modulus
- not
- or
- random
- shiftLeft
- shiftRight
- toNatural
- width
- Bits
- compare
- fromByte
- normal
- toByte
- Byte
Theorems
⊦ ¬(modulus = 0)
⊦ ∀w. normal (fromByte w)
⊦ ∀x. x ≤ x
⊦ fromNatural modulus = 0
⊦ toByte [] = 0
⊦ toNatural (toByte []) = 0
⊦ modulus mod modulus = 0
⊦ 0 mod modulus = 0
⊦ ∀x. ¬(x < x)
⊦ ∀x. toNatural x < modulus
⊦ ~0 = 0
⊦ ∀x. ~~x = x
⊦ ∀x. fromNatural (toNatural x) = x
⊦ ∀w. toByte (fromByte w) = w
⊦ ∀w. length (fromByte w) = width
⊦ ∀w. Bits.width (toNatural w) ≤ width
⊦ ∀n. n mod modulus < modulus
⊦ ∀n. n mod modulus ≤ n
⊦ modulus = 2 ↑ width
⊦ width = 8
⊦ ∀q. compare q [] [] ⇔ q
⊦ ∀w. Bits.fromList (fromByte w) = toNatural w
⊦ ∀x. x + 0 = x
⊦ ∀x. x ↑ 1 = x
⊦ ∀x. 0 + x = x
⊦ ∀x. toNatural x div modulus = 0
⊦ ∀l. toByte l = fromNatural (Bits.fromList l)
⊦ ∀w. fromByte w = Bits.toVector (toNatural w) width
⊦ ∀x. x ↑ 0 = 1
⊦ ∀x. x * 0 = 0
⊦ ∀x. x + ~x = 0
⊦ ∀x. 0 * x = 0
⊦ ∀x. ~x + x = 0
⊦ ∀x. toNatural x mod modulus = toNatural x
⊦ ∀w. Bits.bound (toNatural w) width = toNatural w
⊦ ∀x. x * 1 = x
⊦ ∀x. 1 * x = x
⊦ ∀n. toNatural (fromNatural n) = n mod modulus
⊦ ∀n. toNatural (fromNatural n) = Bits.bound n width
⊦ ∀r. random r = fromNatural (Uniform.random modulus r)
⊦ ∀l. normal l ⇔ length l = width
⊦ ∀x. ~x = fromNatural (modulus - toNatural x)
⊦ ∀w. not w = toByte (map (¬) (fromByte w))
⊦ ∀l. normal l ⇔ fromByte (toByte l) = l
⊦ ∀x y. x * y = y * x
⊦ ∀x y. x + y = y + x
⊦ ∀n. divides modulus n ⇔ n mod modulus = 0
⊦ ∀n. n < modulus ⇒ toNatural (fromNatural n) = n
⊦ ∀n. n < modulus ⇒ n mod modulus = n
⊦ ∀x. fromNatural x = 0 ⇔ divides modulus x
⊦ ∀n. n mod modulus mod modulus = n mod modulus
⊦ ∀x y. x - y = x + ~y
⊦ ∀x y. ¬(x < y) ⇔ y ≤ x
⊦ ∀x y. ¬(x ≤ y) ⇔ y < x
⊦ ∀w n. bit w n ⇔ Bits.bit (toNatural w) n
⊦ ∀x. ~x = 0 ⇔ x = 0
⊦ ∀l. toNatural (toByte l) < 2 ↑ length l
⊦ ∀x y. x < y ⇔ toNatural x < toNatural y
⊦ ∀x y. x ≤ y ⇔ toNatural x ≤ toNatural y
⊦ ∀x y. x * ~y = ~(x * y)
⊦ ∀x y. ~x * y = ~(x * y)
⊦ ∀w1 w2. fromByte w1 = fromByte w2 ⇔ w1 = w2
⊦ ∀x y. ~x = ~y ⇒ x = y
⊦ ∀x y. toNatural x = toNatural y ⇒ x = y
⊦ ∀w1 w2. fromByte w1 = fromByte w2 ⇒ w1 = w2
⊦ ∀w n. shiftLeft w n = fromNatural (Bits.shiftLeft (toNatural w) n)
⊦ ∀w n. shiftRight w n = fromNatural (Bits.shiftRight (toNatural w) n)
⊦ ∀m n. fromNatural (m ↑ n) = fromNatural m ↑ n
⊦ ∀w1 w2. and w1 w2 = fromNatural (Bits.and (toNatural w1) (toNatural w2))
⊦ ∀w1 w2. or w1 w2 = fromNatural (Bits.or (toNatural w1) (toNatural w2))
⊦ ∀x y. x + y = x ⇔ y = 0
⊦ ∀x y. y + x = x ⇔ y = 0
⊦ ∀x y. ~x + ~y = ~(x + y)
⊦ ∀w1 w2. compare ⊥ (fromByte w1) (fromByte w2) ⇔ w1 < w2
⊦ ∀w1 w2. compare ⊤ (fromByte w1) (fromByte w2) ⇔ w1 ≤ w2
⊦ ∀x n. x ↑ suc n = x * x ↑ n
⊦ ∀x1 y1. fromNatural (x1 * y1) = fromNatural x1 * fromNatural y1
⊦ ∀x1 y1. fromNatural (x1 + y1) = fromNatural x1 + fromNatural y1
⊦ ∀w1 w2. and w1 w2 = toByte (zipWith (∧) (fromByte w1) (fromByte w2))
⊦ ∀w1 w2. or w1 w2 = toByte (zipWith (∨) (fromByte w1) (fromByte w2))
⊦ ∀l n. shiftLeft (toByte l) n = toByte (replicate ⊥ n @ l)
⊦ ∀x y. toNatural (x * y) = toNatural x * toNatural y mod modulus
⊦ ∀x y. toNatural (x + y) = (toNatural x + toNatural y) mod modulus
⊦ ∀x y z. x * y * z = x * (y * z)
⊦ ∀x y z. x + y + z = x + (y + z)
⊦ ∀x y z. x + y = x + z ⇔ y = z
⊦ ∀x y z. y + x = z + x ⇔ y = z
⊦ ∀x1 x2 x3. x1 < x2 ∧ x2 < x3 ⇒ x1 < x3
⊦ ∀x1 x2 x3. x1 < x2 ∧ x2 ≤ x3 ⇒ x1 < x3
⊦ ∀x1 x2 x3. x1 ≤ x2 ∧ x2 < x3 ⇒ x1 < x3
⊦ ∀x1 x2 x3. x1 ≤ x2 ∧ x2 ≤ x3 ⇒ x1 ≤ x3
⊦ ∀n. 0 ↑ n = if n = 0 then 1 else 0
⊦ ∀k w. bit (not w) k ⇔ k < width ∧ ¬bit w k
⊦ ∀x y. fromNatural x = fromNatural y ⇔ x mod modulus = y mod modulus
⊦ ∀x y z. x * (y + z) = x * y + x * z
⊦ ∀x y z. (y + z) * x = y * x + z * x
⊦ ∀x m n. x ↑ m * x ↑ n = x ↑ (m + n)
⊦ ∀k w1 w2. bit (and w1 w2) k ⇔ bit w1 k ∧ bit w2 k
⊦ ∀k w1 w2. bit (or w1 w2) k ⇔ bit w1 k ∨ bit w2 k
⊦ ∀m n. (m mod modulus) * (n mod modulus) mod modulus = m * n mod modulus
⊦ ∀m n. (m mod modulus + n mod modulus) mod modulus = (m + n) mod modulus
⊦ ∀q w1 w2.
compare q (fromByte w1) (fromByte w2) ⇔ if q then w1 ≤ w2 else w1 < w2
⊦ ∀w1 w2. (∀i. i < width ⇒ (bit w1 i ⇔ bit w2 i)) ⇒ w1 = w2
⊦ ∀x y. x < modulus ∧ y < modulus ∧ fromNatural x = fromNatural y ⇒ x = y
⊦ ∀l n. bit (toByte l) n ⇔ n < width ∧ n < length l ∧ nth l n
⊦ ∀q l1 l2.
length l1 = length l2 ⇒
(compare q l1 l2 ⇔
Bits.compare q (Bits.fromList l1) (Bits.fromList l2))
⊦ ∀l.
fromByte (toByte l) =
if length l ≤ width then l @ replicate ⊥ (width - length l)
else take width l
⊦ ∀h t.
toByte (h :: t) =
if h then 1 + shiftLeft (toByte t) 1 else shiftLeft (toByte t) 1
⊦ ∀l n.
length l ≤ width ⇒
shiftRight (toByte l) n =
if length l ≤ n then toByte [] else toByte (drop n l)
⊦ ∀l n.
width ≤ length l ⇒
shiftRight (toByte l) n =
if width ≤ n then toByte [] else toByte (drop n (take width l))
⊦ ∀q h1 h2 t1 t2.
compare q (h1 :: t1) (h2 :: t2) ⇔
compare (¬h1 ∧ h2 ∨ ¬(h1 ∧ ¬h2) ∧ q) t1 t2
⊦ ∀b.
∃x0 x1 x2 x3 x4 x5 x6 x7.
b = toByte (x0 :: x1 :: x2 :: x3 :: x4 :: x5 :: x6 :: x7 :: [])
⊦ ∀l n.
shiftRight (toByte l) n =
if length l ≤ width then
if length l ≤ n then toByte [] else toByte (drop n l)
else if width ≤ n then toByte []
else toByte (drop n (take width l))
External Type Operators
- →
- bool
- Data
- List
- list
- List
- Number
- Natural
- natural
- Natural
- Probability
- Random
- random
- Random
External Constants
- =
- select
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∃!
- ∨
- ¬
- cond
- ⊥
- ⊤
- List
- ::
- @
- []
- drop
- head
- length
- map
- nth
- replicate
- tail
- take
- zipWith
- Bool
- Number
- Natural
- *
- +
- -
- <
- ≤
- ↑
- bit0
- bit1
- div
- divides
- fromBool
- min
- mod
- suc
- zero
- Bits
- Bits.and
- Bits.bit
- Bits.bound
- Bits.compare
- Bits.cons
- Bits.fromList
- Bits.or
- Bits.shiftLeft
- Bits.shiftRight
- Bits.toVector
- Bits.width
- Uniform
- Uniform.random
- Natural
Assumptions
⊦ ⊤
⊦ ¬⊥ ⇔ ⊤
⊦ ¬⊤ ⇔ ⊥
⊦ length [] = 0
⊦ bit0 0 = 0
⊦ Bits.fromList [] = 0
⊦ ∀t. t ⇒ t
⊦ ∀n. n ≤ n
⊦ ⊥ ⇔ ∀p. p
⊦ ∀t. t ∨ ¬t
⊦ (¬) = λp. p ⇒ ⊥
⊦ (∃) = λp. p ((select) p)
⊦ ∀t. (∀x. t) ⇔ t
⊦ ∀t. (λx. t x) = t
⊦ (∀) = λp. p = λx. ⊤
⊦ ∀x. replicate x 0 = []
⊦ ∀t. ¬¬t ⇔ t
⊦ ∀t. (⊤ ⇔ t) ⇔ t
⊦ ∀t. (t ⇔ ⊤) ⇔ t
⊦ ∀t. ⊥ ∧ t ⇔ ⊥
⊦ ∀t. ⊤ ∧ t ⇔ t
⊦ ∀t. ⊥ ⇒ t ⇔ ⊤
⊦ ∀t. ⊤ ⇒ t ⇔ t
⊦ ∀t. t ⇒ ⊤ ⇔ ⊤
⊦ ∀t. ⊥ ∨ t ⇔ t
⊦ ∀t. ⊤ ∨ t ⇔ ⊤
⊦ ∀t. t ∨ ⊥ ⇔ t
⊦ ∀t. t ∨ ⊤ ⇔ ⊤
⊦ ∀n. ¬(suc n = 0)
⊦ ∀n. 0 * n = 0
⊦ ∀n. 0 + n = n
⊦ ∀m. m + 0 = m
⊦ ∀n. n - n = 0
⊦ ∀k. Bits.bound 0 k = 0
⊦ ∀l. l @ [] = l
⊦ ∀t. (⊥ ⇔ t) ⇔ ¬t
⊦ ∀t. (t ⇔ ⊥) ⇔ ¬t
⊦ ∀t. t ⇒ ⊥ ⇔ ¬t
⊦ ∀n. bit1 n = suc (bit0 n)
⊦ ∀m. m ↑ 0 = 1
⊦ ∀k. Bits.fromList (replicate ⊥ k) = 0
⊦ ∀m. 1 * m = m
⊦ ∀l. take (length l) l = l
⊦ ∀l. Bits.width (Bits.fromList l) ≤ length l
⊦ ∀m n. m ≤ m + n
⊦ ∀n k. Bits.bound n k ≤ n
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ ⊤) ∨ (t ⇔ ⊥)
⊦ ∀t1 t2. (if ⊥ then t1 else t2) = t2
⊦ ∀t1 t2. (if ⊤ then t1 else t2) = t1
⊦ ∀x n. length (replicate x n) = n
⊦ ∀h t. head (h :: t) = h
⊦ ∀h t. tail (h :: t) = t
⊦ ∀n k. length (Bits.toVector n k) = k
⊦ ∀b. fromBool b = if b then 1 else 0
⊦ ∀n. 0 < n ⇔ ¬(n = 0)
⊦ ∀n. bit0 (suc n) = suc (suc (bit0 n))
⊦ ∀l. length l = 0 ⇔ l = []
⊦ ∀x y. x = y ⇔ y = x
⊦ ∀t1 t2. t1 ∨ t2 ⇔ t2 ∨ t1
⊦ ∀m n. m * n = n * m
⊦ ∀m n. m + n = n + m
⊦ ∀m n. min m n = min n m
⊦ ∀m n. m < n ⇒ m ≤ n
⊦ ∀f l. length (map f l) = length l
⊦ ∀l. Bits.fromList l < 2 ↑ length l
⊦ ∀h t. length (h :: t) = suc (length t)
⊦ ∀m n. ¬(m < n) ⇔ n ≤ m
⊦ ∀m n. ¬(m ≤ n) ⇔ n < m
⊦ ∀n k. Bits.fromList (Bits.toVector n k) = Bits.bound n k
⊦ (∧) = λp q. (λf. f p q) = λf. f ⊤ ⊤
⊦ ∀n. Bits.shiftLeft n 1 = 2 * n
⊦ ∀n. ¬(n = 0) ⇒ n mod n = 0
⊦ ∀p. ¬(∀x. p x) ⇔ ∃x. ¬p x
⊦ ∀p. ¬(∃x. p x) ⇔ ∀x. ¬p x
⊦ (∃) = λp. ∀q. (∀x. p x ⇒ q) ⇒ q
⊦ ∀h t. Bits.fromList (h :: t) = Bits.cons h (Bits.fromList t)
⊦ ∀m n. m < n ⇒ m div n = 0
⊦ ∀m n. m < n ⇒ m mod n = m
⊦ ∀m n. m + suc n = suc (m + n)
⊦ ∀m n. suc m + n = suc (m + n)
⊦ ∀m n. suc m = suc n ⇔ m = n
⊦ ∀n k. Bits.toVector (Bits.bound n k) k = Bits.toVector n k
⊦ ∀n. 0 ↑ n = if n = 0 then 1 else 0
⊦ ∀t1 t2. ¬(t1 ∧ t2) ⇔ ¬t1 ∨ ¬t2
⊦ ∀m n. min m n = if m ≤ n then m else n
⊦ ∀m n. m ↑ suc n = m * m ↑ n
⊦ ∀m n. ¬(n = 0) ⇒ m mod n < n
⊦ ∀m n. ¬(n = 0) ⇒ m mod n ≤ m
⊦ ∀n k. Bits.bound n k = n ⇔ Bits.width n ≤ k
⊦ ∀l. l = [] ∨ ∃h t. l = h :: t
⊦ ∀f g. (∀x. f x = g x) ⇔ f = g
⊦ (∨) = λp q. ∀r. (p ⇒ r) ⇒ (q ⇒ r) ⇒ r
⊦ ∀q n. Bits.compare q 0 n ⇔ q ∨ ¬(n = 0)
⊦ ∀n k. Bits.bound n k = n mod 2 ↑ k
⊦ ∀m n. n ≤ m ⇒ m - n + n = m
⊦ ∀m n. m ≤ n ∧ n ≤ m ⇔ m = n
⊦ ∀n l. n ≤ length l ⇒ length (take n l) = n
⊦ ∀m n. m < n ⇔ ∃d. n = m + suc d
⊦ ∀p. (∀x y. p x y) ⇔ ∀y x. p x y
⊦ ∀h t. Bits.cons h t = fromBool h + 2 * t
⊦ ∀n k. Bits.width n ≤ k ⇔ n < 2 ↑ k
⊦ ∀t1 t2 t3. (t1 ∧ t2) ∧ t3 ⇔ t1 ∧ t2 ∧ t3
⊦ ∀t1 t2 t3. (t1 ∨ t2) ∨ t3 ⇔ t1 ∨ t2 ∨ t3
⊦ ∀m n p. m * (n * p) = m * n * p
⊦ ∀m n p. m + (n + p) = m + n + p
⊦ ∀n j k. Bits.bound (Bits.bound n j) k = Bits.bound n (min j k)
⊦ ∀m n p. m < n ∧ n < p ⇒ m < p
⊦ ∀m n p. m < n ∧ n ≤ p ⇒ m < p
⊦ ∀m n p. m ≤ n ∧ n < p ⇒ m < p
⊦ ∀m n p. m ≤ n ∧ n ≤ p ⇒ m ≤ p
⊦ ∀r. (∀x. ∃y. r x y) ⇔ ∃f. ∀x. r x (f x)
⊦ ∀l i. Bits.bit (Bits.fromList l) i ⇔ i < length l ∧ nth l i
⊦ ∀l1 l2.
Bits.fromList (l1 @ l2) =
Bits.fromList l1 + Bits.shiftLeft (Bits.fromList l2) (length l1)
⊦ ∀p. p 0 ∧ (∀n. p n ⇒ p (suc n)) ⇒ ∀n. p n
⊦ ∀a b. ¬(a = 0) ⇒ (divides a b ⇔ b mod a = 0)
⊦ ∀n m. ¬(n = 0) ⇒ m mod n mod n = m mod n
⊦ ∀m n. m ↑ n = 0 ⇔ m = 0 ∧ ¬(n = 0)
⊦ ∀p q r. p ∧ (q ∨ r) ⇔ p ∧ q ∨ p ∧ r
⊦ ∀q m n. Bits.compare q m n ⇔ if q then m ≤ n else m < n
⊦ ∀m n i. Bits.bit (Bits.and m n) i ⇔ Bits.bit m i ∧ Bits.bit n i
⊦ ∀n i k. Bits.bit (Bits.bound n k) i ⇔ i < k ∧ Bits.bit n i
⊦ ∀m n i. Bits.bit (Bits.or m n) i ⇔ Bits.bit m i ∨ Bits.bit n i
⊦ ∀m n p. m * (n + p) = m * n + m * p
⊦ ∀m n p. (m + n) * p = m * p + n * p
⊦ ∀n j k.
Bits.bound (Bits.shiftLeft n k) (j + k) =
Bits.shiftLeft (Bits.bound n j) k
⊦ ∀n j k.
Bits.shiftRight (Bits.bound n (j + k)) k =
Bits.bound (Bits.shiftRight n k) j
⊦ (∃!) = λp. (∃) p ∧ ∀x y. p x ∧ p y ⇒ x = y
⊦ ∀b f x y. f (if b then x else y) = if b then f x else f y
⊦ ∀l k.
Bits.shiftRight (Bits.fromList l) k =
if length l ≤ k then 0 else Bits.fromList (drop k l)
⊦ ∀m n k.
Bits.toVector (Bits.and m n) k =
zipWith (∧) (Bits.toVector m k) (Bits.toVector n k)
⊦ ∀m n k.
Bits.toVector (Bits.or m n) k =
zipWith (∨) (Bits.toVector m k) (Bits.toVector n k)
⊦ ∀e f. ∃!fn. fn 0 = e ∧ ∀n. fn (suc n) = f (fn n) n
⊦ ∀m n. ¬(n = 0) ⇒ (m div n) * n + m mod n = m
⊦ ∀p. p [] ∧ (∀h t. p t ⇒ p (h :: t)) ⇒ ∀l. p l
⊦ ∀f l i. i < length l ⇒ nth (map f l) i = f (nth l i)
⊦ ∀h1 h2 t1 t2. h1 :: t1 = h2 :: t2 ⇔ h1 = h2 ∧ t1 = t2
⊦ ∀p c x y. p (if c then x else y) ⇔ (c ⇒ p x) ∧ (¬c ⇒ p y)
⊦ ∀b f. ∃fn. fn [] = b ∧ ∀h t. fn (h :: t) = f h t (fn t)
⊦ ∀l k.
Bits.toVector (Bits.fromList l) k =
if length l ≤ k then l @ replicate ⊥ (k - length l) else take k l
⊦ ∀n m p. ¬(n = 0) ⇒ (m mod n) * (p mod n) mod n = m * p mod n
⊦ ∀n a b. ¬(n = 0) ⇒ (a mod n + b mod n) mod n = (a + b) mod n
⊦ ∀l1 l2.
length l1 = length l2 ∧ (∀i. i < length l1 ⇒ nth l1 i = nth l2 i) ⇒
l1 = l2
⊦ ∀q h1 h2 t1 t2.
Bits.compare q (Bits.cons h1 t1) (Bits.cons h2 t2) ⇔
Bits.compare (¬h1 ∧ h2 ∨ ¬(h1 ∧ ¬h2) ∧ q) t1 t2