Package word16-bytes: 16-bit word to byte pair conversions
Information
name | word16-bytes |
version | 1.36 |
description | 16-bit word to byte pair conversions |
author | Joe Hurd <joe@gilith.com> |
license | MIT |
requires | bool pair natural list byte word16-def word16-bits |
show | Data.Bool Data.Byte Data.Byte.Bits Data.List Data.Pair Data.Word16 Data.Word16.Bits Number.Natural |
Files
- Package tarball word16-bytes-1.36.tgz
- Theory file word16-bytes.thy (included in the package tarball)
Defined Constants
- Data
- Word16
- fromBytes
- toBytes
- Word16
Theorems
⊦ ∀b. fromNatural (toNatural b) = toWord (fromByte b)
⊦ ∀w. fromNatural (toNatural w) = toByte (fromWord w)
⊦ ∀w. ∃b0 b1. w = fromBytes b0 b1
⊦ ∀b0 b1. toWord (fromByte b1 @ fromByte b0) = fromBytes b0 b1
⊦ ∀w. ∃b0 b1. w = fromBytes b0 b1 ∧ toBytes w = (b0, b1)
⊦ ∀b1 b2.
fromBytes b1 b2 =
or (shiftLeft (fromNatural (toNatural b1)) 8)
(fromNatural (toNatural b2))
⊦ ∀w.
(toByte (drop 8 (fromWord w)), toByte (take 8 (fromWord w))) =
toBytes w
⊦ ∀w.
toBytes w =
(fromNatural (toNatural (shiftRight w 8)),
fromNatural (toNatural (and w 255)))
Input Type Operators
- →
- bool
- Data
- Byte
- byte
- List
- list
- Pair
- ×
- Word16
- word16
- Byte
- Number
- Natural
- natural
- Natural
Input Constants
- =
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∨
- ¬
- cond
- F
- T
- Byte
- bit
- fromNatural
- modulus
- toNatural
- width
- Bits
- fromByte
- toByte
- List
- ::
- @
- []
- drop
- length
- nth
- replicate
- take
- zipWith
- Pair
- ,
- fst
- snd
- Word16
- and
- bit
- fromNatural
- modulus
- or
- shiftLeft
- shiftRight
- toNatural
- width
- Bits
- fromWord
- toWord
- Bool
- Number
- Natural
- *
- +
- -
- <
- ≤
- bit0
- bit1
- div
- even
- exp
- mod
- odd
- suc
- zero
- Natural
Assumptions
⊦ T
⊦ ¬F ⇔ T
⊦ ¬T ⇔ F
⊦ odd 0 ⇔ F
⊦ length [] = 0
⊦ bit0 0 = 0
⊦ ∀x. x = x
⊦ ∀t. t ⇒ t
⊦ ∀n. 0 ≤ n
⊦ F ⇔ ∀p. p
⊦ toWord [] = 0
⊦ ∀t. t ∨ ¬t
⊦ (¬) = λp. p ⇒ F
⊦ ∀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
⊦ ∀w. toByte (fromByte w) = w
⊦ ∀w. length (fromByte w) = width
⊦ ∀w. toWord (fromWord w) = w
⊦ ∀w. length (fromWord w) = width
⊦ ∀n. ¬(suc n = 0)
⊦ ∀n. 0 * n = 0
⊦ ∀m. m * 0 = 0
⊦ ∀n. 0 + n = n
⊦ ∀m. m + 0 = m
⊦ ∀l. [] @ l = l
⊦ ∀l. drop 0 l = l
⊦ ∀l. take 0 l = []
⊦ modulus = exp 2 width
⊦ width = 8
⊦ modulus = exp 2 width
⊦ ∀t. (F ⇔ t) ⇔ ¬t
⊦ ∀t. (t ⇔ F) ⇔ ¬t
⊦ ∀t. t ⇒ F ⇔ ¬t
⊦ ∀n. bit1 n = suc (bit0 n)
⊦ ∀m. exp m 0 = 1
⊦ ∀m. m * 1 = m
⊦ ∀n. n mod 1 = 0
⊦ ∀m. 1 * m = m
⊦ ∀f. zipWith f [] [] = []
⊦ width = 16
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ T) ∨ (t ⇔ F)
⊦ ∀n. even (suc n) ⇔ ¬even n
⊦ ∀n. odd (suc n) ⇔ ¬odd n
⊦ ∀m. m ≤ 0 ⇔ m = 0
⊦ ∀x. toNatural (fromNatural x) = x mod modulus
⊦ ∀x. toNatural (fromNatural x) = x mod modulus
⊦ ∀x. (fst x, snd x) = x
⊦ ∀t1 t2. (if F then t1 else t2) = t2
⊦ ∀t1 t2. (if T then t1 else t2) = t1
⊦ ∀x y. fst (x, y) = x
⊦ ∀x y. snd (x, y) = y
⊦ ∀n. bit0 (suc n) = suc (suc (bit0 n))
⊦ ∀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. m + n - m = n
⊦ ∀m n. m + n - n = m
⊦ ∀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. suc m ≤ n ⇔ m < n
⊦ ∀m. m = 0 ∨ ∃n. m = suc n
⊦ (∧) = λp q. (λf. f p q) = λf. f T T
⊦ ∀p. ¬(∀x. p x) ⇔ ∃x. ¬p x
⊦ (∃) = λp. ∀q. (∀x. p x ⇒ q) ⇒ q
⊦ ∀w1 w2. fromByte w1 = fromByte w2 ⇔ w1 = w2
⊦ ∀w1 w2. fromWord w1 = fromWord w2 ⇔ w1 = w2
⊦ ∀m n. m < n ⇒ m div n = 0
⊦ ∀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. 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. m * suc n = m + m * n
⊦ ∀m n. exp m (suc n) = m * exp m n
⊦ ∀m n. suc m * n = m * n + n
⊦ ∀m n. ¬(n = 0) ⇒ m mod n < n
⊦ ∀m n. m ≤ n ⇔ ∃d. n = m + d
⊦ (∨) = λp q. ∀r. (p ⇒ r) ⇒ (q ⇒ r) ⇒ r
⊦ ∀w1 w2. and w1 w2 = toWord (zipWith (∧) (fromWord w1) (fromWord w2))
⊦ ∀w1 w2. or w1 w2 = toWord (zipWith (∨) (fromWord w1) (fromWord w2))
⊦ ∀m n. m ≤ n ⇔ m < n ∨ m = n
⊦ ∀m n. n ≤ m ⇒ n + (m - n) = m
⊦ ∀m n. odd (m + n) ⇔ ¬(odd m ⇔ odd n)
⊦ ∀m n. m ≤ n ∧ n ≤ m ⇔ m = n
⊦ ∀l n. shiftLeft (toWord l) n = toWord (replicate n F @ l)
⊦ ∀p q. p ∨ (∃x. q x) ⇔ ∃x. p ∨ q x
⊦ ∀x y z. x = y ∧ y = z ⇒ x = z
⊦ ∀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 ∧ n ≤ p ⇒ m < p
⊦ ∀n. toWord (odd n :: fromWord (fromNatural (n div 2))) = fromNatural n
⊦ ∀l h t. (h :: t) @ l = h :: t @ l
⊦ ∀w n. bit w n ⇔ odd (toNatural w div exp 2 n)
⊦ ∀w n. bit w n ⇔ odd (toNatural w div exp 2 n)
⊦ ∀m n. m ≤ suc n ⇔ m = suc n ∨ m ≤ n
⊦ ∀m n. m * n = 0 ⇔ m = 0 ∨ n = 0
⊦ ∀P. P 0 ∧ (∀n. P n ⇒ P (suc n)) ⇒ ∀n. P n
⊦ ∀m n. exp m n = 0 ⇔ m = 0 ∧ ¬(n = 0)
⊦ ∀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
⊦ ∀w1 w2. (∀i. i < width ⇒ (bit w1 i ⇔ bit w2 i)) ⇒ w1 = w2
⊦ ∀w1 w2. (∀i. i < width ⇒ (bit w1 i ⇔ bit w2 i)) ⇒ w1 = w2
⊦ ∀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
⊦ ∀l n. bit (toByte l) n ⇔ n < width ∧ n < length l ∧ nth n l
⊦ ∀l n. bit (toWord l) n ⇔ n < width ∧ n < length l ∧ nth n l
⊦ ∀m n p. m * n < m * p ⇔ ¬(m = 0) ∧ n < p
⊦ ∀h1 h2 t1 t2. h1 :: t1 = h2 :: t2 ⇔ h1 = h2 ∧ t1 = t2
⊦ ∀x y a b. (x, y) = (a, b) ⇔ x = a ∧ y = b
⊦ ∀n h t. n ≤ length t ⇒ take (suc n) (h :: t) = h :: take n t
⊦ ∀l.
fromByte (toByte l) =
if length l ≤ width then l @ replicate (width - length l) F
else take width l
⊦ ∀l.
fromWord (toWord l) =
if length l ≤ width then l @ replicate (width - length l) F
else take width l
⊦ ∀m n p. ¬(n * p = 0) ⇒ m mod (n * p) mod n = m mod n
⊦ ∀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 * p = 0) ⇒ m div n mod p = m mod (n * p) div n
⊦ ∀f h1 h2 t1 t2.
length t1 = length t2 ⇒
zipWith f (h1 :: t1) (h2 :: t2) = f h1 h2 :: zipWith f t1 t2
⊦ ∀x m n.
exp x m ≤ exp x n ⇔ if x = 0 then m = 0 ⇒ n = 0 else x = 1 ∨ m ≤ n
⊦ ∀b.
∃x0 x1 x2 x3 x4 x5 x6 x7.
b = toByte (x0 :: x1 :: x2 :: x3 :: x4 :: x5 :: x6 :: x7 :: [])
⊦ ∀l n.
shiftRight (toWord l) n =
if length l ≤ width then
if length l ≤ n then toWord [] else toWord (drop n l)
else if width ≤ n then toWord []
else toWord (drop n (take width l))
⊦ ∀w.
∃x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15.
w =
toWord
(x0 :: x1 :: x2 :: x3 :: x4 :: x5 :: x6 :: x7 :: x8 :: x9 :: x10 ::
x11 :: x12 :: x13 :: x14 :: x15 :: [])