Package byte: Bytes
Information
name | byte |
version | 1.31 |
description | Bytes |
author | Joe Hurd <joe@gilith.com> |
license | MIT |
requires | bool natural list natural-divides |
show | Data.Bool Data.Byte Data.Byte.Bits Data.List Number.Natural |
Files
- Package tarball byte-1.31.tgz
- Theory 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
- shiftLeft
- shiftRight
- toNatural
- width
- Bits
- compare
- fromByte
- normal
- toByte
- Byte
Theorems
⊦ ¬(modulus = 0)
⊦ ∀w. normal (fromByte w)
⊦ ∀w. w ≤ w
⊦ fromNatural modulus = 0
⊦ toByte [] = 0
⊦ toNatural (toByte []) = 0
⊦ modulus mod modulus = 0
⊦ 0 mod modulus = 0
⊦ ∀w. ¬(w < w)
⊦ ∀x. toNatural x < modulus
⊦ ~0 = 0
⊦ ∀x. ~~x = x
⊦ ∀x. fromNatural (toNatural x) = x
⊦ ∀w. toByte (fromByte w) = w
⊦ ∀w. length (fromByte w) = width
⊦ ∀n. n mod modulus < modulus
⊦ modulus = exp 2 width
⊦ width = 8
⊦ ∀q. compare q [] [] ⇔ q
⊦ ∀x. x + 0 = x
⊦ ∀x. 0 + x = x
⊦ ∀x. toNatural x div modulus = 0
⊦ ∀x. x * 0 = 0
⊦ ∀x. x + ~x = 0
⊦ ∀x. 0 * x = 0
⊦ ∀x. ~x + x = 0
⊦ ∀x. toNatural x mod modulus = toNatural x
⊦ ∀x. x * 1 = x
⊦ ∀x. 1 * x = x
⊦ ∀x. toNatural (fromNatural x) = x mod modulus
⊦ ∀l. normal l ⇔ length l = width
⊦ ∀x. ~x = fromNatural (modulus - toNatural x)
⊦ ∀w. not w = toByte (map (¬) (fromByte w))
⊦ ∀x y. x * y = y * x
⊦ ∀x y. x + y = y + x
⊦ ∀w. fromByte w = map (bit w) (interval 0 width)
⊦ ∀n. divides modulus n ⇔ n mod modulus = 0
⊦ ∀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 ⇔ ¬(y ≤ x)
⊦ ∀x y. x - y = x + ~y
⊦ ∀x. ~x = 0 ⇔ x = 0
⊦ ∀l. toNatural (toByte l) < exp 2 (length l)
⊦ ∀l. length l = width ⇔ fromByte (toByte l) = 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. bit w n ⇔ odd (toNatural (shiftRight w n))
⊦ ∀x y. x + y = x ⇔ y = 0
⊦ ∀x y. y + x = x ⇔ y = 0
⊦ ∀x y. ~x + ~y = ~(x + y)
⊦ ∀w1 w2. compare F (fromByte w1) (fromByte w2) ⇔ w1 < w2
⊦ ∀w1 w2. compare T (fromByte w1) (fromByte w2) ⇔ w1 ≤ w2
⊦ ∀x1 y1. fromNatural (x1 * y1) = fromNatural x1 * fromNatural y1
⊦ ∀x1 y1. fromNatural (x1 + y1) = fromNatural x1 + fromNatural y1
⊦ ∀l. width ≤ length l ⇒ fromByte (toByte l) = take width l
⊦ ∀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 F @ 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
⊦ ∀w1 w2 w3. w1 < w2 ∧ w2 < w3 ⇒ w1 < w3
⊦ ∀w1 w2 w3. w1 < w2 ∧ w2 ≤ w3 ⇒ w1 < w3
⊦ ∀w1 w2 w3. w1 ≤ w2 ∧ w2 < w3 ⇒ w1 < w3
⊦ ∀w1 w2 w3. w1 ≤ w2 ∧ w2 ≤ w3 ⇒ w1 ≤ w3
⊦ ∀n. toByte (odd n :: fromByte (fromNatural (n div 2))) = fromNatural n
⊦ ∀w n. bit w n ⇔ odd (toNatural w div exp 2 n)
⊦ ∀w n. shiftLeft w n = fromNatural (exp 2 n * toNatural w)
⊦ ∀w n. shiftRight w n = fromNatural (toNatural w div exp 2 n)
⊦ ∀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
⊦ ∀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
⊦ ∀l.
length l ≤ width ⇒
fromByte (toByte l) = l @ replicate (width - length l) F
⊦ ∀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
⊦ ∀l. 2 * toNatural (toByte l) + 1 < exp 2 (suc (length l))
⊦ ∀x y. x < modulus ∧ y < modulus ∧ fromNatural x = fromNatural y ⇒ x = y
⊦ ∀l n. bit (toByte l) n ⇔ n < width ∧ n < length l ∧ nth n l
⊦ ∀n.
fromNatural n =
toByte
(if n = 0 then [] else odd n :: fromByte (fromNatural (n div 2)))
⊦ ∀l.
fromByte (toByte l) =
if length l ≤ width then l @ replicate (width - length l) F
else take width l
⊦ ∀h t.
toByte (h :: t) =
if h then shiftLeft (toByte t) 1 + 1 else shiftLeft (toByte t) 1
⊦ ∀h t.
toNatural (toByte (h :: t)) =
(2 * toNatural (toByte t) + if h then 1 else 0) mod modulus
⊦ ∀h t.
2 * toNatural (toByte t) + (if h then 1 else 0) <
exp 2 (suc (length t))
⊦ ∀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))
Input Type Operators
- →
- bool
- Data
- List
- list
- List
- Number
- Natural
- natural
- Natural
Input Constants
- =
- select
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∨
- ¬
- cond
- F
- T
- List
- ::
- @
- []
- drop
- head
- interval
- length
- map
- nth
- replicate
- tail
- take
- zipWith
- Bool
- Number
- Natural
- *
- +
- -
- <
- ≤
- bit0
- bit1
- div
- divides
- even
- exp
- mod
- odd
- suc
- zero
- Natural
Assumptions
⊦ T
⊦ ¬F ⇔ T
⊦ ¬T ⇔ F
⊦ even 0 ⇔ T
⊦ odd 0 ⇔ F
⊦ length [] = 0
⊦ bit0 0 = 0
⊦ ∀t. t ⇒ t
⊦ ∀n. 0 ≤ n
⊦ ∀n. n ≤ n
⊦ F ⇔ ∀p. p
⊦ ∀t. t ∨ ¬t
⊦ ∀n. 0 < suc n
⊦ ∀n. n < suc n
⊦ ∀n. n ≤ suc n
⊦ (¬) = λp. p ⇒ F
⊦ (∃) = λP. P ((select) P)
⊦ ∀t. (∀x. t) ⇔ t
⊦ ∀t. (λx. t x) = t
⊦ (∀) = λp. p = λx. T
⊦ ∀x. replicate 0 x = []
⊦ ∀t. ¬¬t ⇔ t
⊦ ∀t. (T ⇔ t) ⇔ t
⊦ ∀t. (t ⇔ T) ⇔ t
⊦ ∀t. F ∧ t ⇔ F
⊦ ∀t. T ∧ t ⇔ t
⊦ ∀t. t ∧ F ⇔ F
⊦ ∀t. t ∧ T ⇔ t
⊦ ∀t. t ∧ t ⇔ t
⊦ ∀t. F ⇒ t ⇔ T
⊦ ∀t. T ⇒ t ⇔ t
⊦ ∀t. t ⇒ T ⇔ T
⊦ ∀t. F ∨ t ⇔ t
⊦ ∀t. T ∨ t ⇔ T
⊦ ∀t. t ∨ F ⇔ t
⊦ ∀t. t ∨ T ⇔ T
⊦ ∀n. ¬(suc n = 0)
⊦ ∀n. even n ∨ odd n
⊦ ∀m. m < 0 ⇔ F
⊦ ∀n. 0 * n = 0
⊦ ∀n. 0 + n = n
⊦ ∀m. m + 0 = m
⊦ ∀m. m - 0 = m
⊦ ∀n. n - n = 0
⊦ ∀m. interval m 0 = []
⊦ ∀l. [] @ l = l
⊦ ∀l. drop 0 l = l
⊦ ∀f. map f [] = []
⊦ ∀t. (F ⇔ t) ⇔ ¬t
⊦ ∀t. (t ⇔ F) ⇔ ¬t
⊦ ∀t. t ⇒ F ⇔ ¬t
⊦ ∀n. even (2 * n)
⊦ ∀n. bit1 n = suc (bit0 n)
⊦ ∀n. ¬even n ⇔ odd n
⊦ ∀n. ¬odd n ⇔ even n
⊦ ∀m. exp m 0 = 1
⊦ ∀m. m * 1 = m
⊦ ∀n. n div 1 = n
⊦ ∀n. exp n 1 = n
⊦ ∀n. n mod 1 = 0
⊦ ∀m. 1 * m = m
⊦ ∀l. take (length l) l = l
⊦ ∀m n. m ≤ m + n
⊦ ∀m n. n ≤ m + n
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ T) ∨ (t ⇔ F)
⊦ ∀n. odd (suc (2 * n))
⊦ ∀m. suc m = m + 1
⊦ ∀n. even (suc n) ⇔ ¬even n
⊦ ∀m. m ≤ 0 ⇔ m = 0
⊦ ∀t1 t2. (if F then t1 else t2) = t2
⊦ ∀t1 t2. (if T then t1 else t2) = t1
⊦ ∀h t. head (h :: t) = h
⊦ ∀h t. tail (h :: t) = t
⊦ ∀n x. length (replicate n x) = n
⊦ ∀m n. length (interval m n) = n
⊦ ∀n. 0 < n ⇔ ¬(n = 0)
⊦ ∀n. bit0 (suc n) = suc (suc (bit0 n))
⊦ ∀l. length l = 0 ⇔ l = []
⊦ ∀x y. x = y ⇔ y = x
⊦ ∀x y. x = y ⇒ y = x
⊦ ∀h t. nth 0 (h :: t) = h
⊦ ∀t1 t2. t1 ∧ t2 ⇔ t2 ∧ t1
⊦ ∀t1 t2. t1 ∨ t2 ⇔ t2 ∨ t1
⊦ ∀m n. m * n = n * m
⊦ ∀m n. m + n = n + m
⊦ ∀m n. m = n ⇒ m ≤ n
⊦ ∀m n. m < n ⇒ m ≤ n
⊦ ∀m n. m ≤ n ∨ n ≤ m
⊦ ∀m n. m + n - m = n
⊦ ∀l f. length (map f l) = length l
⊦ ∀n. 2 * n = n + n
⊦ ∀h t. length (h :: t) = suc (length t)
⊦ ∀m n. ¬(m < n ∧ n ≤ m)
⊦ ∀m n. ¬(m ≤ n ∧ n < m)
⊦ ∀m n. ¬(m < n) ⇔ n ≤ m
⊦ ∀m n. ¬(m ≤ n) ⇔ n < m
⊦ ∀m n. m < suc n ⇔ m ≤ n
⊦ ∀m n. suc m ≤ n ⇔ m < n
⊦ ∀m. m = 0 ∨ ∃n. m = suc n
⊦ (∧) = λp q. (λf. f p q) = λf. f T T
⊦ ∀n. even n ⇔ n mod 2 = 0
⊦ ∀n. ¬(n = 0) ⇒ 0 mod n = 0
⊦ ∀n. ¬(n = 0) ⇒ n mod n = 0
⊦ ∀P. ¬(∀x. P x) ⇔ ∃x. ¬P x
⊦ (∃) = λP. ∀q. (∀x. P x ⇒ q) ⇒ q
⊦ ∀t1 t2. ¬t1 ⇒ ¬t2 ⇔ t2 ⇒ t1
⊦ ∀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. m < m + n ⇔ 0 < n
⊦ ∀m n. suc m = suc n ⇔ m = n
⊦ ∀m n. suc m < suc n ⇔ m < n
⊦ ∀m n. suc m ≤ suc n ⇔ m ≤ n
⊦ ∀m n. m + n = m ⇔ n = 0
⊦ ∀n. odd n ⇔ n mod 2 = 1
⊦ ∀x n. replicate (suc n) x = x :: replicate n x
⊦ ∀m n. even (m * n) ⇔ even m ∨ even n
⊦ ∀m n. even (m + n) ⇔ even m ⇔ even n
⊦ ∀m n. exp m (suc n) = m * exp m n
⊦ ∀m n. ¬(n = 0) ⇒ m mod n < n
⊦ ∀m n. ¬(n = 0) ⇒ m div n ≤ m
⊦ ∀m n. ¬(n = 0) ⇒ m mod n ≤ m
⊦ ∀l m. length (l @ m) = length l + length m
⊦ ∀m n. m ≤ n ⇔ ∃d. n = m + d
⊦ ∀l. l = [] ∨ ∃h t. l = h :: t
⊦ ∀f g. (∀x. f x = g x) ⇔ f = g
⊦ (∨) = λp q. ∀r. (p ⇒ r) ⇒ (q ⇒ r) ⇒ r
⊦ ∀m n. m ≤ n ⇔ m < n ∨ m = n
⊦ ∀m n. n ≤ m ⇒ n + (m - n) = m
⊦ ∀m n. n ≤ m ⇒ m - n + n = m
⊦ ∀m n. interval m (suc n) = m :: interval (suc m) n
⊦ ∀m n. m ≤ n ∧ n ≤ m ⇔ m = n
⊦ ∀n l. n ≤ length l ⇒ length (take n l) = n
⊦ ∀P. (∀x y. P x y) ⇔ ∀y x. P x y
⊦ ∀P Q. P ∨ (∃x. Q x) ⇔ ∃x. P ∨ Q x
⊦ ∀m n. ¬(m = 0) ⇒ m * n div m = n
⊦ ∀m n. ¬(m = 0) ⇒ m * n mod m = 0
⊦ ∀x y z. x = y ∧ y = z ⇒ x = z
⊦ ∀t1 t2 t3. (t1 ∨ t2) ∨ t3 ⇔ t1 ∨ t2 ∨ t3
⊦ ∀n x i. i < n ⇒ nth i (replicate n x) = x
⊦ ∀m n p. m * (n * p) = m * n * p
⊦ ∀m n p. m + (n + p) = m + n + p
⊦ ∀m n p. m + n < m + p ⇔ n < p
⊦ ∀m n p. n + m < p + m ⇔ n < p
⊦ ∀m n p. m + n ≤ m + p ⇔ n ≤ 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
⊦ ∀m n p. m ≤ n ∧ n ≤ p ⇒ m ≤ p
⊦ ∀l h t. (h :: t) @ l = h :: t @ l
⊦ ∀P. (∀x. ∃y. P x y) ⇔ ∃y. ∀x. P x (y x)
⊦ ∀m n. n < m ⇒ suc (m - suc n) = m - n
⊦ ∀m n. n ≤ m ⇒ (m - n = 0 ⇔ m = n)
⊦ ∀m n. m ≤ suc n ⇔ m = suc n ∨ m ≤ n
⊦ ∀m n. m * n = 0 ⇔ m = 0 ∨ n = 0
⊦ ∀f h t. map f (h :: t) = f h :: map f t
⊦ ∀P. P 0 ∧ (∀n. P n ⇒ P (suc n)) ⇒ ∀n. P n
⊦ ∀a b. ¬(a = 0) ⇒ (divides a b ⇔ b mod a = 0)
⊦ ∀m n. ¬(n = 0) ⇒ (m div n = 0 ⇔ m < n)
⊦ ∀m n. ¬(n = 0) ⇒ m mod n mod n = m mod n
⊦ ∀m n. exp m n = 0 ⇔ m = 0 ∧ ¬(n = 0)
⊦ ∀m n i. i < n ⇒ nth i (interval m n) = m + i
⊦ ∀m n p. m * (n + p) = m * n + m * p
⊦ ∀m n p. exp m (n + p) = exp m n * exp m p
⊦ ∀m n p. (m + n) * p = m * p + n * p
⊦ ∀P Q. (∀x. P x ∧ Q x) ⇔ (∀x. P x) ∧ ∀x. Q x
⊦ ∀P Q. (∃x. P x) ∨ (∃x. Q x) ⇔ ∃x. P x ∨ Q x
⊦ ∀m n. ¬(n = 0) ⇒ m div n * n + m mod n = m
⊦ ∀P. P [] ∧ (∀a0 a1. P a1 ⇒ P (a0 :: a1)) ⇒ ∀x. P x
⊦ ∀h t n. n < length t ⇒ nth (suc n) (h :: t) = nth n t
⊦ ∀n h t. n ≤ length t ⇒ drop (suc n) (h :: t) = drop n t
⊦ ∀m n p. m * n = m * p ⇔ m = 0 ∨ n = p
⊦ ∀m n p. m * n ≤ m * p ⇔ m = 0 ∨ n ≤ p
⊦ ∀f l i. i < length l ⇒ nth i (map f l) = f (nth i l)
⊦ ∀m n p. m * n < m * p ⇔ ¬(m = 0) ∧ n < p
⊦ ∀h1 h2 t1 t2. h1 :: t1 = h2 :: t2 ⇔ h1 = h2 ∧ t1 = t2
⊦ ∀NIL' CONS'.
∃fn. fn [] = NIL' ∧ ∀a0 a1. fn (a0 :: a1) = CONS' a0 a1 (fn a1)
⊦ ∀m n p. ¬(n = 0) ⇒ m * (p mod n) mod n = m * p mod n
⊦ ∀m n p. ¬(n * p = 0) ⇒ m div n div p = m div (n * p)
⊦ ∀m n p. ¬(n * p = 0) ⇒ m mod (n * p) mod n = m mod n
⊦ ∀n l i. n ≤ length l ∧ i < n ⇒ nth i (take n l) = nth i l
⊦ ∀m n q r. m = q * n + r ∧ r < n ⇒ m div n = q
⊦ ∀m n q r. m = q * n + r ∧ r < n ⇒ m mod n = r
⊦ ∀m n p. ¬(n = 0) ⇒ m mod n * (p mod n) mod n = m * p mod n
⊦ ∀a b n. ¬(n = 0) ⇒ (a mod n + b mod n) mod n = (a + b) mod n
⊦ ∀m n p. ¬(n * p = 0) ⇒ m div n mod p = m mod (n * p) div n
⊦ ∀l m.
length l = length m ∧ (∀i. i < length l ⇒ nth i l = nth i m) ⇒ l = m
⊦ ∀x m n.
exp x m ≤ exp x n ⇔ if x = 0 then m = 0 ⇒ n = 0 else x = 1 ∨ m ≤ n
⊦ ∀k l m.
k < length l + length m ⇒
nth k (l @ m) = if k < length l then nth k l else nth (k - length l) m
⊦ ∀a b n.
¬(n = 0) ⇒
((a + b) mod n = a mod n + b mod n ⇔ (a + b) div n = a div n + b div n)