Package word16: 16-bit words
Information
name | word16 |
version | 1.107 |
description | 16-bit words |
author | Joe Leslie-Hurd <joe@gilith.com> |
license | MIT |
requires | bool byte list natural natural-bits natural-divides pair probability |
show | Data.Bool Data.Byte Data.Byte.Bits Data.List Data.Pair Data.Word16 Data.Word16.Bits Number.Natural Probability.Random |
Files
- Package tarball word16-1.107.tgz
- Theory source file word16.thy (included in the package tarball)
Defined Type Operator
- Data
- Word16
- word16
- Word16
Defined Constants
- Data
- Word16
- *
- +
- -
- <
- ≤
- ↑
- ~
- and
- bit
- fromBytes
- fromNatural
- fromRandom
- modulus
- not
- or
- shiftLeft
- shiftRight
- toBytes
- toNatural
- width
- Bits
- compare
- fromWord
- normal
- toWord
- Word16
Theorems
⊦ ¬(modulus = 0)
⊦ ∀w. normal (fromWord w)
⊦ ∀x. x ≤ x
⊦ fromNatural modulus = 0
⊦ toWord [] = 0
⊦ toNatural (toWord []) = 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. toWord (fromWord w) = w
⊦ ∀w. length (fromWord w) = width
⊦ ∀n. n mod modulus < modulus
⊦ ∀n. n mod modulus ≤ n
⊦ modulus = 2 ↑ width
⊦ ∀q. compare q [] [] ⇔ q
⊦ ∀x. x + 0 = x
⊦ ∀x. x ↑ 1 = x
⊦ ∀x. 0 + x = x
⊦ ∀x. toNatural x div modulus = 0
⊦ ∀l. toWord l = fromNatural (Bits.toNatural l)
⊦ width = 16
⊦ ∀b. fromNatural (toNatural b) = toWord (fromByte b)
⊦ ∀w. fromNatural (toNatural w) = toByte (fromWord w)
⊦ ∀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
⊦ ∀x. x * 1 = x
⊦ ∀x. 1 * x = x
⊦ ∀n. toNatural (fromNatural n) = n mod modulus
⊦ ∀l. normal l ⇔ length l = width
⊦ ∀w. ∃b0 b1. w = fromBytes b0 b1
⊦ ∀x. ~x = fromNatural (modulus - toNatural x)
⊦ ∀w. not w = toWord (map (¬) (fromWord w))
⊦ ∀x y. x * y = y * x
⊦ ∀x y. x + y = y + x
⊦ ∀w. fromWord w = map (bit w) (interval 0 width)
⊦ ∀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
⊦ ∀x. ~x = 0 ⇔ x = 0
⊦ ∀l. toNatural (toWord l) < 2 ↑ length l
⊦ ∀l. length l = width ⇔ fromWord (toWord 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. fromWord w1 = fromWord w2 ⇔ w1 = w2
⊦ ∀x y. ~x = ~y ⇒ x = y
⊦ ∀x y. toNatural x = toNatural y ⇒ x = y
⊦ ∀w1 w2. fromWord w1 = fromWord w2 ⇒ w1 = w2
⊦ ∀w n. bit w n ⇔ odd (toNatural (shiftRight w n))
⊦ ∀m n. fromNatural (m ↑ n) = fromNatural m ↑ n
⊦ ∀b0 b1. toWord (fromByte b0 @ fromByte b1) = fromBytes b0 b1
⊦ ∀x y. x + y = x ⇔ y = 0
⊦ ∀x y. y + x = x ⇔ y = 0
⊦ ∀x y. ~x + ~y = ~(x + y)
⊦ ∀w1 w2. compare ⊥ (fromWord w1) (fromWord w2) ⇔ w1 < w2
⊦ ∀w1 w2. compare ⊤ (fromWord w1) (fromWord 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
⊦ ∀l. width ≤ length l ⇒ fromWord (toWord l) = take width l
⊦ ∀w1 w2. and w1 w2 = toWord (zipWith (∧) (fromWord w1) (fromWord w2))
⊦ ∀w1 w2. or w1 w2 = toWord (zipWith (∨) (fromWord w1) (fromWord w2))
⊦ ∀l n. shiftLeft (toWord l) n = toWord (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
⊦ ∀n. toWord (odd n :: fromWord (fromNatural (n div 2))) = fromNatural n
⊦ ∀w n. bit w n ⇔ odd (toNatural w div 2 ↑ n)
⊦ ∀w n. shiftLeft w n = fromNatural (2 ↑ n * toNatural w)
⊦ ∀w n. shiftRight w n = fromNatural (toNatural w div 2 ↑ n)
⊦ ∀x y. fromNatural x = fromNatural y ⇔ x mod modulus = y mod modulus
⊦ ∀w. ∃b0 b1. w = fromBytes b0 b1 ∧ toBytes w = (b0, b1)
⊦ ∀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)
⊦ ∀w.
toBytes w =
(fromNatural (toNatural w), fromNatural (toNatural (shiftRight w 8)))
⊦ ∀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 ⇒
fromWord (toWord l) = l @ replicate ⊥ (width - length l)
⊦ ∀q w1 w2.
compare q (fromWord w1) (fromWord w2) ⇔ if q then w1 ≤ w2 else w1 < w2
⊦ ∀w1 w2. (∀i. i < width ⇒ (bit w1 i ⇔ bit w2 i)) ⇒ w1 = w2
⊦ ∀l. 1 + 2 * toNatural (toWord l) < 2 ↑ suc (length l)
⊦ ∀b0 b1.
fromBytes b0 b1 =
or (fromNatural (toNatural b0))
(shiftLeft (fromNatural (toNatural b1)) 8)
⊦ ∀x y. x < modulus ∧ y < modulus ∧ fromNatural x = fromNatural y ⇒ x = y
⊦ ∀l n. bit (toWord l) n ⇔ n < width ∧ n < length l ∧ nth l n
⊦ ∀n.
fromNatural n =
toWord
(if n = 0 then [] else odd n :: fromWord (fromNatural (n div 2)))
⊦ ∀r.
fromRandom r =
let (n, r') ← Uniform.fromRandom modulus r in (fromNatural n, r')
⊦ ∀l.
fromWord (toWord l) =
if length l ≤ width then l @ replicate ⊥ (width - length l)
else take width l
⊦ ∀w.
(toByte (take 8 (fromWord w)), toByte (drop 8 (fromWord w))) =
toBytes w
⊦ ∀h t.
toWord (h :: t) =
if h then 1 + shiftLeft (toWord t) 1 else shiftLeft (toWord t) 1
⊦ ∀h t.
toNatural (toWord (h :: t)) =
((if h then 1 else 0) + 2 * toNatural (toWord t)) mod modulus
⊦ ∀h t.
(if h then 1 else 0) + 2 * toNatural (toWord t) < 2 ↑ suc (length t)
⊦ ∀l n.
length l ≤ width ⇒
shiftRight (toWord l) n =
if length l ≤ n then toWord [] else toWord (drop n l)
⊦ ∀l n.
width ≤ length l ⇒
shiftRight (toWord l) n =
if width ≤ n then toWord [] else toWord (drop n (take width l))
⊦ ∀q h1 h2 t1 t2.
compare q (h1 :: t1) (h2 :: t2) ⇔
compare (¬h1 ∧ h2 ∨ ¬(h1 ∧ ¬h2) ∧ q) t1 t2
⊦ ∀r.
fromRandom r =
let (r1, r2) ← split r in
let (l, r1') ← bits width r1 in
(toWord l, r2)
⊦ ∀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 :: [])
External Type Operators
- →
- bool
- Data
- Byte
- byte
- List
- list
- Pair
- ×
- Byte
- Number
- Natural
- natural
- Natural
- Probability
- Random
- random
- Random
External Constants
- =
- select
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∃!
- ∨
- ¬
- cond
- ⊥
- ⊤
- Byte
- bit
- fromNatural
- modulus
- toNatural
- width
- Bits
- fromByte
- toByte
- List
- ::
- @
- []
- drop
- head
- interval
- length
- map
- nth
- replicate
- tail
- take
- zipWith
- Pair
- ,
- fst
- snd
- Bool
- Number
- Natural
- *
- +
- -
- <
- ≤
- ↑
- bit0
- bit1
- div
- divides
- even
- fromBool
- mod
- odd
- suc
- zero
- Bits
- Bits.cons
- Bits.toNatural
- Bits.width
- Uniform
- Uniform.fromRandom
- Uniform.fromRandom.loop
- Uniform.fromRandom
- Natural
- Probability
- Random
- bits
- split
- Random
Assumptions
⊦ ⊤
⊦ even 0
⊦ ¬odd 0
⊦ ¬⊥ ⇔ ⊤
⊦ ¬⊤ ⇔ ⊥
⊦ length [] = 0
⊦ bit0 0 = 0
⊦ Bits.toNatural [] = 0
⊦ ∀x. x = x
⊦ ∀t. t ⇒ t
⊦ ∀n. 0 ≤ n
⊦ ∀n. n ≤ n
⊦ ⊥ ⇔ ∀p. p
⊦ ∀t. t ∨ ¬t
⊦ ∀m. ¬(m < 0)
⊦ ∀n. 0 < suc n
⊦ ∀n. n < suc n
⊦ ∀n. n ≤ suc n
⊦ (¬) = λ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. ⊥ ∨ t ⇔ t
⊦ ∀t. ⊤ ∨ t ⇔ ⊤
⊦ ∀t. t ∨ ⊥ ⇔ t
⊦ ∀t. t ∨ ⊤ ⇔ ⊤
⊦ ∀w. toByte (fromByte w) = w
⊦ ∀w. length (fromByte w) = width
⊦ ∀n. ¬(suc n = 0)
⊦ ∀n. even n ∨ odd n
⊦ ∀n. 0 * n = 0
⊦ ∀m. m * 0 = 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
⊦ ∀l. take 0 l = []
⊦ ∀f. map f [] = []
⊦ modulus = 2 ↑ width
⊦ width = 8
⊦ ∀t. (⊥ ⇔ t) ⇔ ¬t
⊦ ∀t. (t ⇔ ⊥) ⇔ ¬t
⊦ ∀t. t ⇒ ⊥ ⇔ ¬t
⊦ ∀n. even (2 * n)
⊦ ∀n. bit1 n = suc (bit0 n)
⊦ ∀n. ¬even n ⇔ odd n
⊦ ∀n. ¬odd n ⇔ even n
⊦ ∀m. m ↑ 0 = 1
⊦ ∀m. m * 1 = m
⊦ ∀n. n ↑ 1 = n
⊦ ∀n. n div 1 = n
⊦ ∀n. n mod 1 = 0
⊦ ∀m. 1 * m = m
⊦ ∀l. take (length l) l = l
⊦ ∀f. zipWith f [] [] = []
⊦ ∀m n. m ≤ m + n
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ ⊤) ∨ (t ⇔ ⊥)
⊦ ∀n. odd (suc (2 * n))
⊦ ∀m. suc m = m + 1
⊦ ∀m. m ≤ 0 ⇔ m = 0
⊦ ∀n. toNatural (fromNatural n) = n mod modulus
⊦ ∀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
⊦ ∀x n. length (replicate x n) = n
⊦ ∀h t. head (h :: t) = h
⊦ ∀h t. tail (h :: t) = t
⊦ ∀m n. length (interval m n) = n
⊦ ∀p x. p x ⇒ p ((select) p)
⊦ ∀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 = []
⊦ ∀f y. (let x ← y in f x) = f y
⊦ ∀x. ∃a b. x = (a, b)
⊦ ∀x y. x = y ⇔ y = x
⊦ ∀x y. x = y ⇒ y = x
⊦ ∀h t. nth (h :: t) 0 = h
⊦ ∀t1 t2. t1 ∧ t2 ⇔ t2 ∧ t1
⊦ ∀t1 t2. t1 ∨ t2 ⇔ t2 ∨ t1
⊦ ∀a b. (a ⇔ b) ⇒ a ⇒ b
⊦ ∀m n. m * n = n * m
⊦ ∀m n. m + n = n + m
⊦ ∀m n. m < n ⇒ m ≤ n
⊦ ∀m n. m ≤ n ∨ n ≤ m
⊦ ∀m n. m + n - m = n
⊦ ∀m n. m + n - n = m
⊦ ∀n r. length (fst (bits n r)) = n
⊦ ∀f l. length (map f l) = length l
⊦ ∀l. Bits.toNatural l < 2 ↑ length l
⊦ ∀h t. length (h :: t) = suc (length t)
⊦ ∀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 ⊤ ⊤
⊦ ∀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. ¬(∃x. p x) ⇔ ∀x. ¬p x
⊦ (∃) = λp. ∀q. (∀x. p x ⇒ q) ⇒ q
⊦ ∀h t. Bits.toNatural (h :: t) = Bits.cons h (Bits.toNatural t)
⊦ ∀w1 w2. fromByte w1 = fromByte w2 ⇔ w1 = w2
⊦ ∀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
⊦ ∀n. 0 ↑ n = if n = 0 then 1 else 0
⊦ ∀k. Bits.width (2 ↑ k - 1) = k
⊦ ∀x n. replicate x (suc n) = x :: replicate x n
⊦ ∀t1 t2. ¬(t1 ∧ t2) ⇔ ¬t1 ∨ ¬t2
⊦ ∀m n. m * suc n = m + m * n
⊦ ∀m n. m ↑ suc n = m * 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
⊦ ∀l1 l2. length (l1 @ l2) = length l1 + length l2
⊦ ∀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. 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
⊦ ∀f. ∃fn. ∀a b. fn (a, b) = f a b
⊦ ∀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
⊦ ∀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
⊦ ∀x n i. i < n ⇒ nth (replicate x n) i = x
⊦ ∀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
⊦ ∀m n p. m + n < m + p ⇔ n < p
⊦ ∀m n p. n + m ≤ p + m ⇔ 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
⊦ ∀r. (∀x. ∃y. r x y) ⇔ ∃f. ∀x. r x (f x)
⊦ ∀w n. bit w n ⇔ odd (toNatural w div 2 ↑ n)
⊦ ∀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)
⊦ ∀n m. ¬(n = 0) ⇒ m mod n mod n = m mod n
⊦ ∀m n. ¬(n = 0) ⇒ (m div n = 0 ⇔ m < n)
⊦ ∀m n. m ↑ n = 0 ⇔ m = 0 ∧ ¬(n = 0)
⊦ ∀m n i. i < n ⇒ nth (interval m n) i = m + i
⊦ ∀m n p. m * (n + p) = m * n + m * p
⊦ ∀m n p. m ↑ (n + p) = m ↑ n * m ↑ p
⊦ ∀m n p. (m + n) * p = m * p + n * p
⊦ (∃!) = λ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
⊦ ∀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
⊦ ∀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
⊦ ∀h t n. n < length t ⇒ nth (h :: t) (suc n) = nth t n
⊦ ∀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
⊦ ∀f l i. i < length l ⇒ nth (map f l) i = f (nth l i)
⊦ ∀l n. bit (toByte l) n ⇔ n < width ∧ n < length l ∧ nth l n
⊦ ∀m n p. m * n < m * p ⇔ ¬(m = 0) ∧ n < p
⊦ ∀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
⊦ ∀b f. ∃fn. fn [] = b ∧ ∀h t. fn (h :: t) = f h t (fn t)
⊦ ∀n m 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 (take n l) i = nth l i
⊦ ∀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
⊦ ∀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
⊦ ∀m n p. ¬(n * p = 0) ⇒ m div n mod p = m mod n * p div n
⊦ ∀l1 l2.
length l1 = length l2 ∧ (∀i. i < length l1 ⇒ nth l1 i = nth l2 i) ⇒
l1 = l2
⊦ ∀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. x ↑ m ≤ x ↑ n ⇔ if x = 0 then m = 0 ⇒ n = 0 else x = 1 ∨ m ≤ n
⊦ ∀n r.
Uniform.fromRandom n r =
let w ← Bits.width (n - 1) in
let (r1, r2) ← split r in
(Uniform.fromRandom.loop n w r1 mod n, r2)
⊦ ∀l1 l2 k.
k < length l1 + length l2 ⇒
nth (l1 @ l2) k =
if k < length l1 then nth l1 k else nth l2 (k - length l1)
⊦ ∀b.
∃x0 x1 x2 x3 x4 x5 x6 x7.
b = toByte (x0 :: x1 :: x2 :: x3 :: x4 :: x5 :: x6 :: x7 :: [])
⊦ ∀n w r.
Uniform.fromRandom.loop n w r =
let (l, r') ← bits w r in
let m ← Bits.toNatural l in
if m < n then m else Uniform.fromRandom.loop n w r'
⊦ ∀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)