#|
Copyright (C) 1994 by David Russinoff.  All Rights Reserved.
You may copy and distribute verbatim copies of this Nqthm-1992 event script as
you receive it, in any medium, including embedding it verbatim in derivative
works, provided that you conspicuously and appropriately publish on each copy
a valid copyright notice "Copyright (C) 1994 by David Russinoff.  All Rights
Reserved."
NO WARRANTY
David Russinoff PROVIDES ABSOLUTELY NO WARRANTY.  THE EVENT SCRIPT IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE SCRIPT IS WITH YOU.  SHOULD THE SCRIPT PROVE DEFECTIVE, YOU
ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
IN NO EVENT WILL David Russinoff BE LIABLE TO YOU FOR ANY DAMAGES,
ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL
DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS SCRIPT (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
SUSTAINED BY THIRD PARTIES), EVEN IF YOU HAVE ADVISED US OF THE POSSIBILITY OF
SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
|#
; Work of David Russinoff.

Event: Start with the library "wilson" using the compiled version.

Event: For efficiency, compile those definitions not yet compiled.

Definition: squares (n, p) = if n ≃ 0 then list (0)

else cons ((n ∗ n) mod p, squares (n − 1, p)) endif

Definition: residue (a, p) = ((¬ divides (p, a)) ∧ ((a mod p) ∈ squares (p, p)))

Theorem: all-squares-1 ((p ≄ 0) ∧ (m ≤ n)) → (((m ∗ m) mod p) ∈ squares (n, p))

Theorem: all-squares-2 ((y ∗ y) mod p) = (((y mod p) ∗ (y mod p)) mod p)

Theorem: all-squares ((p ≄ 0) ∧ (x ∉ squares (p, p))) → (x ≠ ((y ∗ y) mod p))

Theorem: euler-1-1 (¬ divides (2, p)) → ((2 ∗ (p ÷ 2)) = (p − 1))

Theorem: euler-1-2 (¬ divides (2, p)) → (exp (i ∗ i, p ÷ 2) = exp (i, p − 1))

Theorem: euler-1-3 ((a mod p) = (b mod p)) → ((exp (a, c) mod p) = (exp (b, c) mod p))

Theorem: euler-1-4 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, i))) → ((exp (i ∗ i, p ÷ 2) mod p) = 1)

Theorem: euler-1-5 (prime (p) ∧ (¬ divides (p, a)) ∧ ((a mod p) = ((i ∗ i) mod p))) → (¬ divides (p, i))

Theorem: euler-1-6 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ ((a mod p) = ((i ∗ i) mod p))) → ((exp (a, p ÷ 2) mod p) = 1)

Theorem: euler-1-7 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ ((a mod p) ∈ squares (i, p))) → ((exp (a, p ÷ 2) mod p) = 1)

Theorem: euler-1 (prime (p) ∧ (¬ divides (2, p)) ∧ residue (a, p)) → ((exp (a, p ÷ 2) mod p) = 1)

Definition: complement (j , a, p) = ((inverse (j , p) ∗ a) mod p)

Event: Enable inverse; name this event ‘g0219’.

Theorem: complement-works (prime (p) ∧ (¬ divides (p, j ))) → (((j ∗ complement (j , a, p)) mod p) = (a mod p))

Theorem: bounded-complement (p ≄ 0) → (complement (j , a, p) < p)

Event: Enable complement; name this event ‘complement-off’.

Theorem: non-zerop-complement (prime (p) ∧ (¬ divides (p, j )) ∧ (¬ divides (p, a))) → (complement (j , a, p) ≄ 0)

Theorem: complement-is-unique (prime (p) ∧ (¬ divides (p, a)) ∧ (((j ∗ x) mod p) = (a mod p))) → (complement (j , a, p) = (x mod p))

Event: Enable squares; name this event ‘squares-off’.

Theorem: no-self-complement (prime (p) ∧ (¬ divides (p, j )) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p))) → (j ≠ complement (j , a, p))

Theorem: complement-of-complement (prime (p) ∧ (¬ divides (p, j )) ∧ (¬ divides (p, a))) → (complement (complement (j , a, p), a, p) = (j mod p))

Definition: comp-list (i, a, p) = if i ≃ 0 then nil

elseif i ∈ comp-list (i − 1, a, p) then comp-list (i − 1, a, p)

else cons (i, cons (complement (i, a, p), comp-list (i − 1, a, p))) endif

Theorem: all-non-zerop-comp-list (prime (p) ∧ (i < p) ∧ (¬ divides (p, a))) → all-non-zerop (comp-list (i, a, p))

Theorem: bounded-comp-list (i < p) → all-lesseqp (comp-list (i, a, p), p − 1)

Theorem: subsetp-positives-comp-list subsetp (positives (n), comp-list (n, a, p))

Theorem: comp-list-closed-1 (prime (p) ∧ (i ≄ 0) ∧ (i < p) ∧ (¬ divides (p, a)) ∧ (j ∈ comp-list (i, a, p))) → (complement (j , a, p) ∈ comp-list (i, a, p))

Theorem: comp-list-closed-2 (prime (p) ∧ (i ≄ 0) ∧ (j ≄ 0) ∧ (i < p) ∧ (j < p) ∧ (¬ divides (p, a)) ∧ (complement (j , a, p) ∈ comp-list (i, a, p))) → (j ∈ comp-list (i, a, p))

Theorem: all-distinct-comp-list-1 (prime (p) ∧ (i < p) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p)) ∧ all-distinct (comp-list (i − 1, a, p))) → all-distinct (comp-list (i, a, p))

Theorem: all-distinct-comp-list (prime (p) ∧ (i < p) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p))) → all-distinct (comp-list (i, a, p))

Theorem: perm-positives-comp-list (prime (p) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p))) → perm (positives (p − 1), comp-list (p − 1, a, p))

Theorem: comp-list-fact (prime (p) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p))) → (times-list (comp-list (p − 1, a, p)) = fact (p − 1))

Theorem: times-mod-4 (((i ∗ j ) mod p) = (a mod p)) → (((i ∗ (j ∗ k)) mod p) = ((a ∗ (k mod p)) mod p))

Theorem: times-comp-list-1 ((((i ∗ complement (i, a, p)) mod p) = (a mod p)) ∧ (i ≄ 0)

∧ (i ∉ comp-list (i − 1, a, p))) → ((times-list (comp-list (i, a, p)) mod p)

= ((a ∗ (times-list (comp-list (i − 1, a, p)) mod p)) mod p))

Theorem: times-comp-list-2 (prime (p) ∧ (¬ divides (p, i)) ∧ (i ∉ comp-list (i − 1, a, p))) → ((times-list (comp-list (i, a, p)) mod p)

= ((a ∗ (times-list (comp-list (i − 1, a, p)) mod p)) mod p))

Theorem: quotient-plus-1 ((n ≄ 0) ∧ (x ∈ N) ∧ (y = (x + n))) → ((y ÷ n) = (1 + (x ÷ n)))

Theorem: times-comp-list-3 ((i ≄ 0) ∧ (i ∉ comp-list (i − 1, a, p))) → ((length (comp-list (i, a, p)) ÷ 2)

= (1 + (length (comp-list (i − 1, a, p)) ÷ 2)))

Theorem: times-comp-list-4 (prime (p) ∧ (i ≄ 0) ∧ (i < p) ∧ ((times-list (comp-list (i − 1, a, p)) mod p)

= (exp (a, length (comp-list (i − 1, a, p)) ÷ 2) mod p))) → ((times-list (comp-list (i, a, p)) mod p)

= (exp (a, length (comp-list (i, a, p)) ÷ 2) mod p))

Theorem: times-comp-list-5 (i ≃ 0) → ((times-list (comp-list (i, a, p)) mod p)

= (exp (a, length (comp-list (i, a, p)) ÷ 2) mod p))

Theorem: times-comp-list (prime (p) ∧ (i < p)) → ((times-list (comp-list (i, a, p)) mod p)

= (exp (a, length (comp-list (i, a, p)) ÷ 2) mod p))

Theorem: sub1-length-delete (x ∈ b) → (length (delete (x, b)) = (length (b) − 1))

Theorem: equal-length-perm perm (a, b) → (length (a) = length (b))

Theorem: length-positives length (positives (n)) = fix (n)

Theorem: euler-2-1 (prime (p) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p))) → ((exp (a, length (comp-list (p − 1, a, p)) ÷ 2) mod p) = (p − 1))

Theorem: euler-2-2 (prime (p) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p))) → (length (comp-list (p − 1, a, p)) = (p − 1))

Theorem: euler-2-3 (p ≄ 0) → (divides (2, p) = (¬ divides (2, p − 1)))

Theorem: euler-2-4 (¬ divides (2, p)) → (((p − 1) ÷ 2) = (p ÷ 2))

Theorem: euler-2 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ (¬ residue (a, p))) → ((exp (a, p ÷ 2) mod p) = (p − 1))

Definition: res1 (n, a, p) = if n ≃ 0 then t

elseif (p ÷ 2) < ((a ∗ n) mod p) then ¬ res1 (n − 1, a, p)

else res1 (n − 1, a, p) endif

Definition: reflect (x, p) = (p − x)

Definition: reflect-list (n, a, p) = if n ≃ 0 then nil

elseif (p ÷ 2) < ((a ∗ n) mod p)

then cons (reflect ((a ∗ n) mod p, p), reflect-list (n − 1, a, p))

else cons ((a ∗ n) mod p, reflect-list (n − 1, a, p)) endif

Theorem: diff-mod-1 (b ≤ a) → (((a − (b mod p)) mod p) = ((a − b) mod p))

Theorem: rem-diff-times ((x < p) ∧ (x ≄ 0) ∧ (b ≄ 0)) → ((((b ∗ p) − x) mod p) = (p − x))

Theorem: reflect-commutes-with-times-1 (y ≤ p) → (((reflect (y, p) ∗ x) mod p) = (reflect ((y ∗ x) mod p, p) mod p))

Theorem: reflect-commutes-with-times-2 (y ≤ p) → (((x ∗ reflect (y, p)) mod p) = (reflect ((x ∗ y) mod p, p) mod p))

Theorem: times-exp-fact (n ≄ 0) → ((((a ∗ n) ∗ (exp (a, n − 1) ∗ fact (n − 1))) mod p)

= ((exp (a, n) ∗ fact (n)) mod p))

Theorem: rem-reflect-list-1 ((p ≄ 0) ∧ (n ≄ 0) ∧ ((p ÷ 2) ≮ ((a ∗ n) mod p)) ∧ ((times-list (reflect-list (n − 1, a, p)) mod p)

= ((exp (a, n − 1) ∗ fact (n − 1)) mod p))) → ((times-list (reflect-list (n, a, p)) mod p)

= ((exp (a, n) ∗ fact (n)) mod p))

Theorem: rem-reflect-list-2 ((p ≄ 0) ∧ (n ≄ 0) ∧ ((p ÷ 2) < ((a ∗ n) mod p)) ∧ ((times-list (reflect-list (n − 1, a, p)) mod p)

= ((exp (a, n − 1) ∗ fact (n − 1)) mod p))) → ((times-list (reflect-list (n, a, p)) mod p)

= (reflect ((exp (a, n) ∗ fact (n)) mod p, p) mod p))

Theorem: rem-reflect-list-3 ((p ≄ 0) ∧ (n ≄ 0) ∧ ((p ÷ 2) ≮ ((a ∗ n) mod p)) ∧ ((times-list (reflect-list (n − 1, a, p)) mod p)

= (reflect ((exp (a, n − 1) ∗ fact (n − 1)) mod p, p) mod p))) → ((times-list (reflect-list (n, a, p)) mod p)

= (reflect ((exp (a, n) ∗ fact (n)) mod p, p) mod p))

Theorem: double-reflect (a ≤ p) → ((reflect (reflect (a, p) mod p, p) mod p) = (a mod p))

Theorem: rem-reflect-list-4 ((p ≄ 0) ∧ (n ≄ 0) ∧ ((p ÷ 2) < ((a ∗ n) mod p)) ∧ ((times-list (reflect-list (n − 1, a, p)) mod p)

= (reflect ((exp (a, n − 1) ∗ fact (n − 1)) mod p, p) mod p))) → ((times-list (reflect-list (n, a, p)) mod p)

= ((exp (a, n) ∗ fact (n)) mod p))

Theorem: rem-reflect-list-base-case (n ≃ 0) → ((times-list (reflect-list (n, a, p)) mod p)

= ((exp (a, n) ∗ fact (n)) mod p))

Theorem: rem-reflect-list (p ≄ 0) → ((times-list (reflect-list (n, a, p)) mod p)

= if res1 (n, a, p) then (exp (a, n) ∗ fact (n)) mod p else reflect ((exp (a, n) ∗ fact (n)) mod p, p) mod p endif)

Theorem: length-reflect-list length (reflect-list (n, a, p)) = fix (n)

Theorem: all-lesseqp-reflect-list-1 ((p ÷ 2) < x) → ((p ÷ 2) ≮ reflect (x, p))

Theorem: all-lesseqp-reflect-list all-lesseqp (reflect-list (n, a, p), p ÷ 2)

Theorem: all-non-zerop-reflect-list (prime (p) ∧ (¬ divides (p, a)) ∧ (b < p)) → all-non-zerop (reflect-list (b, a, p))

Theorem: all-distinct-reflect-list-1 (prime (p) ∧ (j < i) ∧ (i < p) ∧ (¬ divides (p, a))) → (((a ∗ i) mod p) ≠ ((a ∗ j ) mod p))

Theorem: all-distinct-reflect-list-2 ((x ∈ N) ∧ (y ∈ N) ∧ (x < p) ∧ (y < p)) → (((p − x) = (p − y)) = (x = y))

Theorem: numberp-remainder (a mod p) ∈ N

Theorem: all-distinct-reflect-list-3 (prime (p) ∧ (j < i) ∧ (i < p) ∧ (¬ divides (p, a))) → (reflect ((a ∗ i) mod p, p) ≠ reflect ((a ∗ j ) mod p, p))

Theorem: plus-mod-1 (((x mod p) + y) mod p) = ((x + y) mod p)

Theorem: plus-mod-2 ((y + (x mod p)) mod p) = ((x + y) mod p)

Theorem: all-distinct-reflect-list-4 ((x = (p − y)) ∧ (y < p)) → (((x + y) mod p) = 0)

Theorem: all-distinct-reflect-list-5 ((((a ∗ i) mod p) = (p − ((a ∗ j ) mod p))) ∧ (p ≄ 0)) → (((a ∗ (i + j )) mod p) = 0)

Theorem: all-distinct-reflect-list-6 ((i ≤ (p ÷ 2)) ∧ (j < i)) → (((i + j ) ≄ 0) ∧ ((i + j ) < p))

Theorem: all-distinct-reflect-list-7 (prime (p) ∧ (¬ divides (p, a)) ∧ (i ≤ (p ÷ 2)) ∧ (j < i)) → (((a ∗ i) mod p) ≠ reflect ((a ∗ j ) mod p, p))

Theorem: all-distinct-reflect-list-8 (prime (p) ∧ (¬ divides (p, a)) ∧ (i ≤ (p ÷ 2)) ∧ (j < i)) → (reflect ((a ∗ i) mod p, p) ≠ ((a ∗ j ) mod p))

Theorem: all-distinct-reflect-list-9 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ (i ≤ (p ÷ 2)) ∧ (j < i)) → (((a ∗ i) mod p) ∉ reflect-list (j , a, p))

Theorem: all-distinct-reflect-list-10 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ (i ≤ (p ÷ 2)) ∧ (j < i)) → (reflect ((a ∗ i) mod p, p) ∉ reflect-list (j , a, p))

Theorem: all-distinct-reflect-list (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ (i ≤ (p ÷ 2))) → all-distinct (reflect-list (i, a, p))

Theorem: times-reflect-list (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a))) → (times-list (reflect-list (p ÷ 2, a, p)) = fact (p ÷ 2))

Theorem: plus-x-x-even ((x + x) mod 2) = 0 Theorem: res1-rem-1-1 ((x ≄ 0) ∧ (¬ divides (2, p))) → (((p − x) mod p) ≠ x)

Theorem: res1-rem-1 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ res1 (p ÷ 2, a, p)) → ((exp (a, p ÷ 2) mod p) = 1)

Theorem: remainder-lessp (a < p) → ((a mod p) = fix (a))

Theorem: res1-rem-2 (prime (p) ∧ (¬ divides (2, p)) ∧ (¬ divides (p, a)) ∧ (¬ res1 (p ÷ 2, a, p))) → ((exp (a, p ÷ 2) mod p) ≠ 1)

Theorem: two-even (¬ divides (2, p)) → ((p − 1) ≠ 1)

Theorem: gauss-lemma (prime (p) ∧ (¬ divides (p, a)) ∧ (¬ divides (2, p))) → (res1 (p ÷ 2, a, p) = residue (a, p))

Definition: plus-list (l) = if l ≃ nil then 0

else car (l) + plus-list (cdr (l)) endif

Definition: quot-list (n, a, p) = if n ≃ 0 then nil

else cons ((a ∗ n) ÷ p, quot-list (n − 1, a, p)) endif

Definition: rem-list (n, a, p) = if n ≃ 0 then nil

else cons ((a ∗ n) mod p, rem-list (n − 1, a, p)) endif

Theorem: rem-quot-list (a ∗ plus-list (positives (n))) = ((p ∗ plus-list (quot-list (n, a, p))) + plus-list (rem-list (n, a, p)))

Definition: even3 (x) = if x ≃ 0 then t

else ¬ even3 (x − 1) endif

Theorem: even3-plus even3 (a + b) = (even3 (a) = even3 (b))

Theorem: even3-diff (x ≤ p) → (even3 (p − x) = (even3 (p) = even3 (x)))

Theorem: even3-times even3 (a ∗ b) = (even3 (a) ∨ even3 (b))

Theorem: even3-rem (¬ even3 (p)) → (even3 (p − (x mod p)) = (¬ even3 (x mod p)))

Theorem: even3-rem-reflect (¬ even3 (p)) → (res1 (n, a, p)

= (even3 (plus-list (rem-list (n, a, p))) ↔ even3 (plus-list (reflect-list (n, a, p)))))

Theorem: perm-plus-list-1 (x ∈ m) → ((x + plus-list (delete (x, m))) = plus-list (m))

Theorem: perm-plus-list perm (l, m) → (plus-list (l) = plus-list (m))

Theorem: even3-even divides (2, p) = even3 (p)

Theorem: plus-reflect-list (prime (p) ∧ (¬ divides (p, a)) ∧ (¬ even3 (p))) → (plus-list (reflect-list (p ÷ 2, a, p))

= plus-list (positives (p ÷ 2)))

Theorem: equals-have-same-parity (x = y) → (even3 (x) = even3 (y))

Theorem: res1-quot-list (prime (p) ∧ (¬ even3 (p)) ∧ (¬ even3 (a)) ∧ (¬ divides (p, a))) → (res1 (p ÷ 2, a, p) = even3 (plus-list (quot-list (p ÷ 2, a, p))))

Definition: wins1 (x, l) = if l ≃ nil then 0

elseif car (l) < x then 1 + wins1 (x, cdr (l))

else wins1 (x, cdr (l)) endif Definition: wins (k, l) = if k ≃ nil then 0

else wins1 (car (k), l) + wins (cdr (k), l) endif

Definition: losses1 (x, l) = if l ≃ nil then 0

elseif x < car (l) then 1 + losses1 (x, cdr (l))

else losses1 (x, cdr (l)) endif

Definition: losses (k, l) = if k ≃ nil then 0

else losses1 (car (k), l) + losses (cdr (k), l) endif

Theorem: win-some-lose-some-1 ((x ∉ l) ∧ all-non-zerop (l)) → ((losses1 (x, l) + wins1 (x, l)) = length (l))

Theorem: win-some-lose-some-2 ((intersect (l, m) ≃ nil) ∧ all-non-zerop (l) ∧ all-non-zerop (m)) → ((wins (l, m) + losses (l, m)) = (length (l) ∗ length (m)))

Theorem: equal-losses-wins losses (l, m) = wins (m, l)

Theorem: a-winner-every-time ((intersect (l, m) ≃ nil) ∧ all-non-zerop (l) ∧ all-non-zerop (m)) → ((wins (l, m) + wins (m, l)) = (length (l) ∗ length (m)))

Definition: mults (n, p) = if n ≃ 0 then nil

else cons (n ∗ p, mults (n − 1, p)) endif

Theorem: length-mults length (mults (n, p)) = fix (n)

Theorem: leq-n-wins1 ((n ∗ p) < a) → (n ≤ wins1 (a, mults (n, p)))

Theorem: monotone-wins1 (n ≤ m) → (wins1 (a, mults (n, p)) ≤ wins1 (a, mults (m, p)))

Definition: quot-quot-induction (a, b, c, d) = if b ≃ 0 then t

elseif d ≃ 0 then t elseif a < d then t elseif c < b then t else quot-quot-induction (a − d, b, c − b, d) endif

Theorem: leq-times-quot ((b ≄ 0) ∧ ((a ∗ b) ≤ (c ∗ d))) → ((a ÷ d) ≤ (c ÷ b))

Theorem: leq-quot-times (((p ÷ 2) ∗ q) ÷ p) ≤ (q ÷ 2)

Definition: monotone-quot-induction (i, j , p) = if p ≃ 0 then t

elseif i < p then t elseif j < p then t else monotone-quot-induction (i − p, j − p, p) endif

Theorem: monotone-quot (j ≤ i) → ((j ÷ p) ≤ (i ÷ p))

Theorem: leq-quot-times-2 (j ≤ (p ÷ 2)) → (((j ∗ q) ÷ p) ≤ (q ÷ 2))

Theorem: leq-quot-wins1-1 (¬ divides (p, x)) → (((x ÷ p) ∗ p) < x)

Theorem: leq-quot-wins1-2 (prime (p) ∧ (¬ divides (p, q)) ∧ (q ≄ 0) ∧ (j ≄ 0) ∧ (j < p)) → ((((j ∗ q) ÷ p) ∗ p) < (j ∗ q))

Theorem: leq-quot-wins1 (prime (p) ∧ (¬ divides (p, q)) ∧ (j ≤ (p ÷ 2)) ∧ (j ≄ 0) ∧ (q ≄ 0)) → (((j ∗ q) ÷ p) ≤ wins1 (j ∗ q, mults (q ÷ 2, p)))

Definition: wins2 (a, n, p) = if n ≃ 0 then 0

elseif (n ∗ p) < a then n else wins2 (a, n − 1, p) endif Theorem: leq-wins2 (wins2 (a, n, p) ∗ p) ≤ a

Theorem: leq-wins1-n wins1 (a, mults (n, p)) ≤ n

Theorem: leq-wins1-wins2 wins1 (a, mults (n, p)) ≤ wins2 (a, n, p)

Theorem: leq-wins1 (wins1 (a, mults (n, p)) ∗ p) ≤ a

Theorem: leq-wins1-quot (p ≄ 0) → (wins1 (a, mults (n, p)) ≤ (a ÷ p))

Theorem: equal-quot-wins1 (prime (p) ∧ (¬ divides (p, q)) ∧ (j ≤ (p ÷ 2)) ∧ (j ≄ 0) ∧ (q ≄ 0)) → (wins1 (j ∗ q, mults (q ÷ 2, p)) = ((j ∗ q) ÷ p))

Theorem: equal-wins-plus-quot-list (prime (p) ∧ (¬ divides (p, q)) ∧ (q ≄ 0) ∧ (j ≄ 0) ∧ (j ≤ (p ÷ 2))) → (wins (mults (j , q), mults (q ÷ 2, p)) = plus-list (quot-list (j , q, p)))

Theorem: gauss-corollary (prime (p) ∧ prime (q) ∧ (p ≠ 2) ∧ (q ≠ 2) ∧ (p ≠ q)) → (res1 (p ÷ 2, q, p) = residue (q, p))

Theorem: residue-quot-list (prime (p) ∧ prime (q) ∧ (p ≠ q) ∧ (p ≠ 2) ∧ (q ≠ 2)) → ((residue (q, p) = residue (p, q))

= even3 (plus-list (quot-list (p ÷ 2, q, p)) + plus-list (quot-list (q ÷ 2, p, q))))

Theorem: all-non-zerop-mults (p ≄ 0) → all-non-zerop (mults (n, p))

Theorem: empty-intersect-mults-1 (prime (p) ∧ prime (q) ∧ (p ≠ q) ∧ (i < q) ∧ (j < p)) → ((i ∗ p) ∉ mults (j , q))

Theorem: empty-intersect-mults (prime (p) ∧ prime (q) ∧ (p ≠ q) ∧ (i < q)) → (¬ listp (intersect (mults (i, p), mults (p ÷ 2, q))))

Theorem: equal-plus-quot-list-wins (prime (p) ∧ prime (q) ∧ (p ≠ q)) → (plus-list (quot-list (p ÷ 2, q, p))

= wins (mults (p ÷ 2, q), mults (q ÷ 2, p)))

Theorem: law-of-quadratic-reciprocity (prime (p) ∧ prime (q) ∧ (p ≠ q) ∧ (p ≠ 2) ∧ (q ≠ 2)) → ((residue (q, p) = residue (p, q)) = even ((p ÷ 2) ∗ (q ÷ 2)))

Index

a-winner-every-time, 12 all-distinct, 4, 9 all-distinct-comp-list, 4 all-distinct-comp-list-1, 4 all-distinct-reflect-list, 9 all-distinct-reflect-list-1, 8 all-distinct-reflect-list-10, 9 all-distinct-reflect-list-2, 8 all-distinct-reflect-list-3, 8 all-distinct-reflect-list-4, 8 all-distinct-reflect-list-5, 9 all-distinct-reflect-list-6, 9 all-distinct-reflect-list-7, 9 all-distinct-reflect-list-8, 9 all-distinct-reflect-list-9, 9 all-lesseqp, 3, 8 all-lesseqp-reflect-list, 8 all-lesseqp-reflect-list-1, 8 all-non-zerop, 3, 8, 12, 14 all-non-zerop-comp-list, 3 all-non-zerop-mults, 14 all-non-zerop-reflect-list, 8 all-squares, 2 all-squares-1, 1 all-squares-2, 2

bounded-comp-list, 3 bounded-complement, 3

comp-list, 3–6 comp-list-closed-1, 4 comp-list-closed-2, 4 comp-list-fact, 4 complement, 2–4 complement-is-unique, 3 complement-of-complement, 3 complement-off, 3 complement-works, 3

delete, 5, 11 diff-mod-1, 6 divides, 1–6, 8–11, 13, 14 double-reflect, 7

empty-intersect-mults, 15 empty-intersect-mults-1, 14 equal-length-perm, 5 equal-losses-wins, 12 equal-plus-quot-list-wins, 15 equal-quot-wins1, 14 equal-wins-plus-quot-list, 14 equals-have-same-parity, 11 euler-1, 2 euler-1-1, 2 euler-1-2, 2 euler-1-3, 2 euler-1-4, 2 euler-1-5, 2 euler-1-6, 2 euler-1-7, 2 euler-2, 6 euler-2-1, 6 euler-2-2, 6 euler-2-3, 6 euler-2-4, 6 even, 15 even3, 11, 14 even3-diff, 11 even3-even, 11 even3-plus, 11 even3-rem, 11 even3-rem-reflect, 11 even3-times, 11 exp, 2, 5–8, 10

fact, 4, 7–9

g0219, 2

gauss-corollary, 14 gauss-lemma, 10

intersect, 12, 15

inverse, 2 law-of-quadratic-reciprocity, 15 length, 5, 6, 8, 12 length-mults, 12 length-positives, 5 length-reflect-list, 8 leq-n-wins1, 12 leq-quot-times, 13 leq-quot-times-2, 13 leq-quot-wins1, 13 leq-quot-wins1-1, 13 leq-quot-wins1-2, 13 leq-times-quot, 13 leq-wins1, 14 leq-wins1-n, 14 leq-wins1-quot, 14 leq-wins1-wins2, 14 leq-wins2, 14 losses, 12 losses1, 12

monotone-quot, 13 monotone-quot-induction, 13 monotone-wins1, 12 mults, 12–15

no-self-complement, 3 non-zerop-complement, 3 numberp-remainder, 8

perm, 4, 5, 11 perm-plus-list, 11 perm-plus-list-1, 11 perm-positives-comp-list, 4 plus-list, 10, 11, 14, 15 plus-mod-1, 8 plus-mod-2, 8 plus-reflect-list, 11 plus-x-x-even, 9 positives, 3–5, 10, 11 prime, 2–6, 8–11, 13–15

quot-list, 10, 11, 14, 15 quot-quot-induction, 13 quotient-plus-1, 5 reflect, 6–9 reflect-commutes-with-times-1, 6 reflect-commutes-with-times-2, 7 reflect-list, 6–9, 11 rem-diff-times, 6 rem-list, 10, 11 rem-quot-list, 10 rem-reflect-list, 8 rem-reflect-list-1, 7 rem-reflect-list-2, 7 rem-reflect-list-3, 7 rem-reflect-list-4, 7 rem-reflect-list-base-case, 8 remainder-lessp, 10 res1, 6, 8, 10, 11, 14 res1-quot-list, 11 res1-rem-1, 10 res1-rem-1-1, 10 res1-rem-2, 10 residue, 1–4, 6, 10, 14, 15 residue-quot-list, 14

squares, 1, 2 squares-off, 3 sub1-length-delete, 5 subsetp, 3 subsetp-positives-comp-list, 3

times-comp-list, 5 times-comp-list-1, 4 times-comp-list-2, 5 times-comp-list-3, 5 times-comp-list-4, 5 times-comp-list-5, 5 times-exp-fact, 7 times-list, 4, 5, 7–9 times-mod-4, 4 times-reflect-list, 9 two-even, 10

win-some-lose-some-1, 12 win-some-lose-some-2, 12 wins, 12, 14, 15 wins1, 11–14 wins2, 13, 14