Package natural-prime-sieve-def: Definition of the sieve of Eratosthenes

Information

namenatural-prime-sieve-def
version1.26
descriptionDefinition of the sieve of Eratosthenes
authorJoe Leslie-Hurd <joe@gilith.com>
licenseMIT
provenanceHOL Light theory extracted on 2014-01-13
requiresbool
list
natural
natural-prime-stream
pair
relation
showData.Bool
Data.List
Data.Pair
Number.Natural
Number.Natural.Prime.Sieve

Files

Defined Type Operator

Defined Constants

Theorems

a. mk (dest a) = a

n i. invariant.inv n i []

initial = mk (1, [])

s. max s = fst (dest s)

s. primes s = map fst (snd (dest s))

r. invariant r dest (mk r) = r

n i. increment.inc n i [] = (, (n, 0, 0) :: [])

s.
    next s =
    let (b, s') increment s in if b then (max s', s') else next s'

n ps.
    invariant (n, ps)
    ¬(n = 0) map fst ps = Prime.below (n + 1) invariant.inv n 0 ps

n i p k j ps.
    invariant.inv n i ((p, k, j) :: ps)
    ¬(p = 0) (k + i) mod p = n mod p invariant.inv n (i + j) ps

s.
    increment s =
    let (n, ps) dest s in
    let n' n + 1 in
    let (b, ps') increment.inc n' 1 ps in
    (b, mk (n', ps'))

n i p k j ps.
    increment.inc n i ((p, k, j) :: ps) =
    let k' (k + i) mod p in
    let j' j + i in
    if k' = 0 then (, (p, 0, j') :: ps)
    else let (b, ps') increment.inc n j' ps in (b, (p, k', 0) :: ps')

External Type Operators

External Constants

Assumptions

¬

¬

bit0 0 = 0

p. p

(¬) = λp. p

() = λp. p ((select) p)

t. (λx. t x) = t

() = λp. p = λx.

Prime.below 2 = []

t. (t ) t

t. t t

t. t t

t. t

n. ¬(suc n = 0)

n. 0 + n = n

f. map f [] = []

n. bit1 n = suc (bit0 n)

() = λp q. p q p

t. (t ) (t )

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

p x. p x p ((select) p)

n. bit0 (suc n) = suc (suc (bit0 n))

x. a b. x = (a, b)

() = λp q. (λf. f p q) = λf. f

() = λp. q. (x. p x q) q

m n. suc m + n = suc (m + n)

() = λp q. r. (p r) (q r) r

f. fn. a b. fn (a, b) = f a b

r. (x. y. r x y) f. x. r x (f x)

p g h. f. x. f x = if p x then f (g x) else h x

b f. fn. fn [] = b h t. fn (h :: t) = f h t (fn t)