Package gfp: Parametric theory of GF(p) finite fields
Information
name | gfp |
version | 1.53 |
description | Parametric theory of GF(p) finite fields |
author | Joe Hurd <joe@gilith.com> |
license | MIT |
requires | bool gfp-witness list natural natural-divides natural-fibonacci natural-gcd natural-prime pair relation |
show | Data.Bool Data.List Data.Pair Number.GF(p) Number.Natural Number.Natural.Fibonacci |
Files
- Package tarball gfp-1.53.tgz
- Theory file gfp.thy (included in the package tarball)
Defined Type Operator
- Number
- GF(p)
- gfp
- GF(p)
Defined Constants
- Number
- GF(p)
- *
- +
- -
- /
- <
- ≤
- ↑
- ~
- divGcd
- expDiv
- fromNatural
- inv
- toNatural
- GF(p)
Theorems
⊦ ¬(oddprime = 0)
⊦ 1 < oddprime
⊦ ∀x. x ≤ x
⊦ ¬(oddprime = 1)
⊦ ¬divides oddprime 1
⊦ fromNatural oddprime = 0
⊦ oddprime mod oddprime = 0
⊦ 0 mod oddprime = 0
⊦ 2 < oddprime
⊦ ∀x. ¬(x < x)
⊦ ∀x. toNatural x < oddprime
⊦ ¬(oddprime = 2)
⊦ ¬divides oddprime 2
⊦ ¬divides 2 oddprime
⊦ ~0 = 0
⊦ ∀x. ~~x = x
⊦ ∀x. fromNatural (toNatural x) = x
⊦ ∀n. n mod oddprime < oddprime
⊦ ¬(1 = 0)
⊦ 1 mod oddprime = 1
⊦ ∀x. x + 0 = x
⊦ ∀x. x ↑ 1 = x
⊦ ∀x. 0 + x = x
⊦ ∀x. toNatural x div oddprime = 0
⊦ ¬(2 = 0)
⊦ inv 1 = 1
⊦ ∀x. x ↑ 0 = 1
⊦ ∀x. x * 0 = 0
⊦ ∀x. x + ~x = 0
⊦ ∀x. 0 * x = 0
⊦ ∀x. ~x + x = 0
⊦ ∀x. toNatural x mod oddprime = toNatural x
⊦ ∀x. x * 1 = x
⊦ ∀x. x / 1 = x
⊦ ∀x. 1 * x = x
⊦ ∀n. toNatural (fromNatural n) = n mod oddprime
⊦ 2 mod oddprime = 2
⊦ ∀x. ~x = fromNatural (oddprime - toNatural x)
⊦ ∀x y. x * y = y * x
⊦ ∀x y. x + y = y + x
⊦ ∀n. divides oddprime n ⇔ n mod oddprime = 0
⊦ ∀n. n < oddprime ⇒ toNatural (fromNatural n) = n
⊦ ∀n. n < oddprime ⇒ n mod oddprime = n
⊦ ∀x. fromNatural x = 0 ⇔ divides oddprime x
⊦ ∀n. n mod oddprime mod oddprime = n mod oddprime
⊦ ∀x y. x - y = x + ~y
⊦ ∀x y. ¬(x < y) ⇔ y ≤ x
⊦ ∀x y. ¬(x ≤ y) ⇔ y < x
⊦ ∀x. ~x = 0 ⇔ x = 0
⊦ ∀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)
⊦ ∀x y. ~x = ~y ⇒ x = y
⊦ ∀x y. toNatural x = toNatural y ⇒ x = y
⊦ ∀m n. fromNatural (m ↑ n) = fromNatural m ↑ n
⊦ ∀x. ¬(x = 0) ⇒ inv (inv x) = x
⊦ ∀x y. x + y = x ⇔ y = 0
⊦ ∀x y. y + x = x ⇔ y = 0
⊦ ∀x y. ~x + ~y = ~(x + y)
⊦ ∀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
⊦ ∀x. ¬(x = 0) ⇒ ¬(inv x = 0)
⊦ ∀x y. toNatural (x * y) = toNatural x * toNatural y mod oddprime
⊦ ∀x y. toNatural (x + y) = (toNatural x + toNatural y) mod oddprime
⊦ ∀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
⊦ ∀x. ¬(x = 0) ⇒ x * inv x = 1
⊦ ∀x. ¬(x = 0) ⇒ inv x * x = 1
⊦ ∀n. 0 ↑ n = if n = 0 then 1 else 0
⊦ ∀x y. ¬(x = 0) ⇒ x * (y / x) = y
⊦ ∀x y. ¬(x = 0) ⇒ (y / x) * x = y
⊦ ∀x y. ¬(x = 0) ⇒ x * y / x = y
⊦ ∀x y. ¬(x = 0) ⇒ y * x / x = y
⊦ ∀m n. divides oddprime (m * n) ⇔ divides oddprime m ∨ divides oddprime n
⊦ ∀x y. fromNatural x = fromNatural y ⇔ x mod oddprime = y mod oddprime
⊦ ∀x y. ¬(x = 0) ⇒ y / x = y * inv x
⊦ ∀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)
⊦ ∀x n. ¬(x = 0) ⇒ inv x ↑ n = inv (x ↑ n)
⊦ ∀m n.
(m mod oddprime) * (n mod oddprime) mod oddprime = m * n mod oddprime
⊦ ∀m n.
(m mod oddprime + n mod oddprime) mod oddprime = (m + n) mod oddprime
⊦ ∀x y. x * y = x ⇔ x = 0 ∨ y = 1
⊦ ∀x y. y * x = x ⇔ x = 0 ∨ y = 1
⊦ ∀x y. x * y = 0 ⇔ x = 0 ∨ y = 0
⊦ ∀x n. x ↑ n = 0 ⇔ x = 0 ∧ ¬(n = 0)
⊦ ∀x. ¬(x = 0) ∧ inv x = 1 ⇒ x = 1
⊦ ∀x y. ¬(y = 0) ⇒ x / y = divGcd (toNatural y) oddprime x 0
⊦ ∀x y. x < oddprime ∧ y < oddprime ∧ fromNatural x = fromNatural y ⇒ x = y
⊦ ∀x y z. x * y = x * z ⇔ x = 0 ∨ y = z
⊦ ∀x y z. y * x = z * x ⇔ x = 0 ∨ y = z
⊦ ∀x y. x * y = if y = 0 then 0 else x / (1 / y)
⊦ ∀x y z. ¬(x = 0) ∧ x * y = x * z ⇒ y = z
⊦ ∀x y z. ¬(x = 0) ∧ y * x = z * x ⇒ y = z
⊦ ∀x y. ¬(x = 0) ∧ ¬(y = 0) ⇒ ¬(y / x = 0)
⊦ ∀x y. ¬(x = 0) ∧ ¬(y = 0) ⇒ inv (y / x) = x / y
⊦ ∀b n d f p. expDiv b n d f p [] = if b then n / d else d / n
⊦ ∀x y. ¬(x = 0) ∧ ¬(y = 0) ∧ inv x = inv y ⇒ x = y
⊦ ∀x y. ¬(x = 0) ∧ ¬(y = 0) ⇒ inv x * inv y = inv (x * y)
⊦ ∀x y z. ¬(y = 0) ∧ ¬(z = 0) ⇒ x / (y / z) = x * z / y
⊦ ∀x n.
x ↑ n =
if n = 0 then 1 else if x = 0 then 0 else expDiv ⊤ 1 1 x 1 (encode n)
⊦ ∀b n d f p h t.
expDiv b n d f p (h :: t) =
let s ← p / f in expDiv (¬b) d (if h then n / s else n) s f t
⊦ ∀u v x1 x2.
gcd u v = 1 ∧ fromNatural u * x2 = fromNatural v * x1 ⇒
fromNatural u * divGcd u v x1 x2 = x1 ∧
fromNatural v * divGcd u v x1 x2 = x2
⊦ ∀x n d f p l.
¬(x = 0) ∧ ¬(n = 0) ∧ ¬(d = 0) ⇒
expDiv ⊤ n d (x ↑ f) (inv (x ↑ p)) l =
(n / d) * x ↑ decode.dest f p l ∧
expDiv ⊥ n d (inv (x ↑ f)) (x ↑ p) l = (d / n) * x ↑ decode.dest f p l
⊦ ∀u v x1 x2.
divGcd u v x1 x2 =
if u = 1 then x1
else if v = 1 then x2
else if even u then divGcd (u div 2) v (x1 / 2) x2
else if even v then divGcd u (v div 2) x1 (x2 / 2)
else if v ≤ u then divGcd (u - v) v (x1 - x2) x2
else divGcd u (v - u) x1 (x2 - x1)
⊦ ∀p.
(∀v. p 1 v) ∧ (∀u. ¬(u = 1) ⇒ p u 1) ∧
(∀u v. gcd (2 * u) v = 1 ∧ ¬(v = 1) ∧ p u v ⇒ p (2 * u) v) ∧
(∀u v. gcd u (2 * v) = 1 ∧ ¬(u = 1) ∧ odd u ∧ p u v ⇒ p u (2 * v)) ∧
(∀u v. gcd u v = 1 ∧ even u ∧ ¬(v = 1) ∧ odd v ∧ p u v ⇒ p (v + u) v) ∧
(∀u v. gcd u v = 1 ∧ ¬(u = 1) ∧ odd u ∧ even v ∧ p u v ⇒ p u (u + v)) ⇒
∀u v. gcd u v = 1 ⇒ p u v
⊦ ∀p.
(∀v x1 x2. p 1 v x1 x2 x1) ∧ (∀u x1 x2. p u 1 x1 x2 x2) ∧
(∀u v x1 x2 g.
gcd (2 * u) v = 1 ∧ p u v x1 x2 g ⇒ p (2 * u) v (2 * x1) x2 g) ∧
(∀u v x1 x2 g.
gcd u (2 * v) = 1 ∧ p u v x1 x2 g ⇒ p u (2 * v) x1 (2 * x2) g) ∧
(∀u v x1 x2 g.
gcd u v = 1 ∧ p u v x1 x2 g ⇒ p (v + u) v (x2 + x1) x2 g) ∧
(∀u v x1 x2 g.
gcd u v = 1 ∧ p u v x1 x2 g ⇒ p u (u + v) x1 (x1 + x2) g) ⇒
∀u v x1 x2. gcd u v = 1 ⇒ p u v x1 x2 (divGcd u v x1 x2)
Input Type Operators
- →
- bool
- Data
- List
- list
- Pair
- ×
- List
- Number
- Natural
- natural
- Natural
Input Constants
- =
- select
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∃!
- ∨
- ¬
- cond
- ⊥
- ⊤
- List
- ::
- []
- Pair
- ,
- Bool
- Number
- GF(p)
- oddprime
- Natural
- *
- +
- -
- <
- ≤
- ↑
- bit0
- bit1
- div
- divides
- even
- gcd
- mod
- odd
- prime
- suc
- zero
- Fibonacci
- decode
- decode.dest
- encode
- decode
- GF(p)
Assumptions
⊦ ⊤
⊦ odd oddprime
⊦ prime oddprime
⊦ ¬prime 0
⊦ ¬prime 1
⊦ ¬⊥ ⇔ ⊤
⊦ ¬⊤ ⇔ ⊥
⊦ odd 0 ⇔ ⊥
⊦ bit0 0 = 0
⊦ ∀t. t ⇒ t
⊦ ∀n. 0 ≤ n
⊦ ∀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. ⊤
⊦ ∀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 ∨ ⊤ ⇔ ⊤
⊦ ∀t. t ∨ t ⇔ t
⊦ ∀n. ¬(suc n = 0)
⊦ ∀n. decode (encode n) = n
⊦ ∀n. 0 * n = 0
⊦ ∀n. 0 + n = n
⊦ ∀m. m + 0 = m
⊦ ∀a. gcd 0 a = a
⊦ ∀a. gcd a 0 = a
⊦ ∀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. 1 * m = m
⊦ ∀m n. m ≤ m + n
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ ⊤) ∨ (t ⇔ ⊥)
⊦ ∀n. even (suc n) ⇔ ¬even n
⊦ ∀n. odd (suc n) ⇔ ¬odd n
⊦ ∀m. m ≤ 0 ⇔ m = 0
⊦ ∀t1 t2. (if ⊥ then t1 else t2) = t2
⊦ ∀t1 t2. (if ⊤ then t1 else t2) = t1
⊦ ∀f p. decode.dest f p [] = 0
⊦ ∀p x. p x ⇒ p ((select) p)
⊦ ∀n. 0 < n ⇔ ¬(n = 0)
⊦ ∀n. bit0 (suc n) = suc (suc (bit0 n))
⊦ ∀a. divides 2 a ⇔ even a
⊦ ∀l. decode l = decode.dest 1 0 l
⊦ ∀x y. x = y ⇔ y = x
⊦ ∀x y. x = y ⇒ y = x
⊦ ∀t1 t2. t1 ∨ t2 ⇔ t2 ∨ t1
⊦ ∀m n. m * n = n * m
⊦ ∀m n. m + n = n + m
⊦ ∀a b. gcd a b = gcd b a
⊦ ∀m n. m < n ⇒ m ≤ n
⊦ ∀m n. m ≤ n ∨ n ≤ m
⊦ ∀m n. m + n - m = n
⊦ ∀a. divides a 1 ⇔ a = 1
⊦ ∀n. 2 * n = n + n
⊦ ∀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. (∀b. p b) ⇔ p ⊤ ∧ p ⊥
⊦ (∧) = λp q. (λf. f p q) = λf. f ⊤ ⊤
⊦ ∀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. n < m + n ⇔ 0 < m
⊦ ∀m n. suc m = suc n ⇔ m = n
⊦ ∀a b. gcd a (a + b) = gcd a b
⊦ ∀a b. gcd (b + a) b = gcd a b
⊦ ∀n. 0 ↑ n = if n = 0 then 1 else 0
⊦ ∀t1 t2. ¬(t1 ∨ t2) ⇔ ¬t1 ∧ ¬t2
⊦ ∀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. ¬(n = 0) ⇒ m mod n < n
⊦ ∀n. even n ⇔ ∃m. n = 2 * m
⊦ ∀p. (∀xy. p xy) ⇔ ∀x y. p (x, y)
⊦ ∀m n. m ≤ n ⇔ ∃d. n = m + d
⊦ ∀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 ⇒ m - n + n = m
⊦ ∀m n. m ≤ n ∧ n ≤ m ⇔ m = n
⊦ ∀f. ∃fn. ∀x y. fn (x, y) = f x y
⊦ ∀p q. (∀x. p ⇒ q x) ⇔ p ⇒ ∀x. q x
⊦ ∀p q. p ∧ (∃x. q x) ⇔ ∃x. p ∧ q x
⊦ ∀p q. p ⇒ (∃x. q x) ⇔ ∃x. p ⇒ q x
⊦ ∀p q. p ∨ (∀x. q x) ⇔ ∀x. p ∨ q x
⊦ ∀p q. p ∨ (∃x. q x) ⇔ ∃x. p ∨ q x
⊦ ∀m n. m < n ⇔ m ≤ n ∧ ¬(m = n)
⊦ ∀m n. ¬(m = 0) ⇒ m * n div m = n
⊦ ∀p q. (∃x. p x) ∧ q ⇔ ∃x. p x ∧ q
⊦ ∀p q. (∃x. p x) ∨ q ⇔ ∃x. p x ∨ q
⊦ ∀x y z. x = y ∧ y = z ⇒ x = z
⊦ ∀p q r. p ⇒ q ⇒ r ⇔ p ∧ q ⇒ r
⊦ ∀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 ≤ 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
⊦ ∀p. (∀x. ∃y. p x y) ⇔ ∃y. ∀x. p x (y x)
⊦ ∀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
⊦ ∀a b. ¬(a = 0) ⇒ (divides a b ⇔ b mod a = 0)
⊦ ∀m n. ¬(n = 0) ⇒ m mod n mod n = m mod n
⊦ ∀p n. prime p ∧ ¬divides p n ⇒ gcd p n = 1
⊦ ∀m n p. m * (n + p) = m * n + m * p
⊦ ∀m n p. (m + n) * p = m * p + n * p
⊦ ∀a. divides a 2 ⇔ a = 1 ∨ a = 2
⊦ (∃!) = λ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. (∀n. (∀m. m < n ⇒ p m) ⇒ p n) ⇒ ∀n. p n
⊦ ∀p g h. ∃f. ∀x. f x = if p x then f (g x) else h 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
⊦ ∀m n p. m * n = m * p ⇔ m = 0 ∨ n = p
⊦ ∀m n p. m * n ≤ m * p ⇔ m = 0 ∨ n ≤ p
⊦ ∀p m n. prime p ⇒ (divides p (m * n) ⇔ divides p m ∨ divides p n)
⊦ ∀m n p. m * n < m * p ⇔ ¬(m = 0) ∧ n < p
⊦ ∀m n p. m * p < n * p ⇔ m < n ∧ ¬(p = 0)
⊦ ∀a b. ¬(a = 0) ⇒ ∃s t. t * b + gcd b a = s * a
⊦ ∀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)
⊦ ∀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
⊦ ∀a b c. gcd a (b * c) = 1 ⇔ gcd a b = 1 ∧ gcd a c = 1
⊦ ∀a b c. gcd (b * c) a = 1 ⇔ gcd b a = 1 ∧ gcd c a = 1
⊦ ∀f p h t.
decode.dest f p (h :: t) =
let s ← f + p in let n ← decode.dest s f t in if h then s + n else n