Package word16-bytes: 16-bit word to byte conversions
Information
name | word16-bytes |
version | 1.87 |
description | 16-bit word to byte conversions |
author | Joe Leslie-Hurd <joe@gilith.com> |
license | MIT |
checksum | 5f259557eb1ddc097fb5fedb9cbdd164e195f4e6 |
requires | base byte natural-bits word16-bits word16-def |
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.87.tgz
- Theory source 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 b0 @ fromByte b1) = fromBytes b0 b1
⊦ ∀w. ∃b0 b1. w = fromBytes b0 b1 ∧ toBytes w = (b0, b1)
⊦ ∀w.
toBytes w =
(fromNatural (toNatural w), fromNatural (toNatural (shiftRight w 8)))
⊦ ∀b0 b1.
fromBytes b0 b1 =
or (fromNatural (toNatural b0))
(shiftLeft (fromNatural (toNatural b1)) 8)
⊦ ∀w.
(toByte (take 8 (fromWord w)), toByte (drop 8 (fromWord w))) =
toBytes w
External Type Operators
- →
- bool
- Data
- Byte
- byte
- List
- list
- Pair
- ×
- Word16
- word16
- Byte
- Number
- Natural
- natural
- Natural
External Constants
- =
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∨
- ¬
- cond
- ⊥
- ⊤
- Byte
- fromNatural
- toNatural
- width
- Bits
- fromByte
- toByte
- List
- ::
- @
- []
- drop
- length
- replicate
- take
- zipWith
- Pair
- ,
- fst
- snd
- Word16
- fromNatural
- or
- shiftLeft
- shiftRight
- toNatural
- width
- Bits
- fromWord
- toWord
- Bool
- Number
- Natural
- +
- -
- <
- ≤
- bit0
- bit1
- suc
- zero
- Bits
- Bits.bound
- Bits.fromList
- Bits.toVector
- Natural
Assumptions
⊦ ⊤
⊦ ¬⊥ ⇔ ⊤
⊦ ¬⊤ ⇔ ⊥
⊦ length [] = 0
⊦ bit0 0 = 0
⊦ ∀x. x = x
⊦ ∀t. t ⇒ t
⊦ ∀n. n ≤ n
⊦ ⊥ ⇔ ∀p. p
⊦ ∀t. t ∨ ¬t
⊦ (¬) = λp. 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
⊦ ∀t. ⊤ ∨ t ⇔ ⊤
⊦ ∀t. t ∨ ⊥ ⇔ t
⊦ ∀t. t ∨ ⊤ ⇔ ⊤
⊦ ∀n. 0 + n = n
⊦ ∀m. m + 0 = m
⊦ ∀l. [] @ l = l
⊦ ∀l. drop 0 l = l
⊦ ∀l. take 0 l = []
⊦ width = 8
⊦ ∀t. (⊥ ⇔ t) ⇔ ¬t
⊦ ∀t. (t ⇔ ⊥) ⇔ ¬t
⊦ ∀t. t ⇒ ⊥ ⇔ ¬t
⊦ ∀n. bit1 n = suc (bit0 n)
⊦ ∀l. toByte l = fromNatural (Bits.fromList l)
⊦ ∀l. toWord l = fromNatural (Bits.fromList l)
⊦ ∀f. zipWith f [] [] = []
⊦ ∀m n. m ≤ m + n
⊦ width = 16
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ ⊤) ∨ (t ⇔ ⊥)
⊦ ∀w. fromByte w = Bits.toVector (toNatural w) width
⊦ ∀w. Bits.bound (toNatural w) width = toNatural w
⊦ ∀w. fromWord w = Bits.toVector (toNatural w) width
⊦ ∀w. Bits.bound (toNatural w) width = toNatural w
⊦ ∀x. (fst x, snd x) = x
⊦ ∀t1 t2. (if ⊥ then t1 else t2) = t2
⊦ ∀t1 t2. (if ⊤ then t1 else t2) = t1
⊦ ∀a b. fst (a, b) = a
⊦ ∀a b. snd (a, b) = b
⊦ ∀n. bit0 (suc n) = suc (suc (bit0 n))
⊦ ∀t1 t2. t1 ∨ t2 ⇔ t2 ∨ t1
⊦ ∀m n. m + n = n + m
⊦ ∀m n. m + n - n = m
⊦ ∀h t. length (h :: t) = suc (length t)
⊦ ∀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 ⊤ ⊤
⊦ ∀p. ¬(∀x. p x) ⇔ ∃x. ¬p x
⊦ ∀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 + suc n = suc (m + n)
⊦ ∀m n. suc m + n = suc (m + n)
⊦ ∀m n. suc m = suc n ⇔ m = n
⊦ ∀x n. replicate x (suc n) = x :: replicate x n
⊦ (∨) = λp q. ∀r. (p ⇒ r) ⇒ (q ⇒ r) ⇒ r
⊦ ∀w1 w2. or w1 w2 = toWord (zipWith (∨) (fromWord w1) (fromWord w2))
⊦ ∀l n. shiftLeft (toWord l) n = toWord (replicate ⊥ n @ l)
⊦ ∀m n. m < n ⇔ ∃d. n = m + suc d
⊦ ∀p q. p ∨ (∃x. q x) ⇔ ∃x. p ∨ q x
⊦ ∀t1 t2 t3. (t1 ∨ t2) ∨ t3 ⇔ t1 ∨ t2 ∨ t3
⊦ ∀m n p. m + (n + p) = m + n + p
⊦ ∀l h t. (h :: t) @ l = h :: t @ l
⊦ ∀p. p 0 ∧ (∀n. p n ⇒ p (suc n)) ⇒ ∀n. p n
⊦ ∀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
⊦ ∀n h t. n ≤ length t ⇒ drop (suc n) (h :: t) = drop n t
⊦ ∀h1 h2 t1 t2. h1 :: t1 = h2 :: t2 ⇔ h1 = h2 ∧ t1 = t2
⊦ ∀a b a' b'. (a, b) = (a', b') ⇔ a = a' ∧ b = 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)
else take width l
⊦ ∀l.
fromWord (toWord l) =
if length l ≤ width then l @ replicate ⊥ (width - length l)
else take width l
⊦ ∀f h1 h2 t1 t2.
length t1 = length t2 ⇒
zipWith f (h1 :: t1) (h2 :: t2) = f h1 h2 :: zipWith f t1 t2
⊦ ∀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 :: [])