Fermat modulo 7 and a composite boundary

On this page
  1. Goal and scope
  2. Givens and symbols
  3. Rules and sources
  4. Main derivation
  5. Substeps and lemmas
  6. Reverse audits
  7. Error controls and negative controls
  8. Result and limitations
  9. Verification and source binding

← Guide index · Original MKO

derivation-mko-fermat-little-theorem-01 · ocme-new142-reader-adoption-20261021

Goal and scope

(-2)^6 is congruent to 1 modulo 7; for multiples of 7, only the congruence a^7≡a modulo 7 applies; passing a Fermat test does not prove primality.

Explicit prime modulus 7, full multiplication permutation and exact squaring, with composite 341 separately.

Givens and symbols

  • calc
  • G1 — p=7,a=-2, normalized to 5 modulo 7; the theorem statements are congruences, not integer equalities.
  • p — qualified prime modulus
  • U_7 — all nonzero residues modulo 7

Rules and sources

  • calc · prerequisite — Assume exact integer arithmetic, division with remainder, and definitions of divisibility and gcd; every congruence has an explicit modulus. Explicitly assume the complete trial-division-to-square-root primality criterion.
  • mko_definition · cited — The theorem modulus is an explicit prime p≥2. The coprime form requires p not dividing a; the all-integer form also handles p dividing a without canceling a. Exact modular powers normalize negative bases. Composite examples such as561 show that passing a Fermat test does not prove primality. All residue equalities here have the declared modulo-p scope. · mko-fermat-little-theorem

Main derivation

S01 · implies

Before

p=7,\quad a=-2

After

7\text{ prime},\quad a\equiv5\pmod7,\quad7\nmid a

Conditions: none

Rule: calc · Uses: G1

Leaf basis: calc

A composite 7 would have a prime divisor at most sqrt(7); only 2 is possible and does not divide 7. The base is a unit.

S02 · implies

Before

U_7=\{1,2,3,4,5,6\}

After

5U_7\pmod7=(5,3,1,6,4,2)

Conditions: none

Rule: calc · Uses: G1, S01

Leaf basis: calc

Multiplying every nonzero residue by 5 produces each exactly once, a complete permutation.

S03 · implies

Before

\prod_{u\in U_7}(5u)\equiv\prod_{u\in U_7}u\pmod7

After

5^6\cdot720\equiv720\pmod7,\quad720\equiv6\pmod7

Conditions: none

Rule: calc · Uses: G1, S02

Leaf basis: calc

Permutation preserves the product; factoring out six copies of 5 yields the product to cancel.

S04 · implies

Before

5^6\cdot6\equiv6\pmod7

After

5^6\equiv1\pmod7\Rightarrow(-2)^6\equiv1\pmod7

Conditions: none

Rule: calc · Uses: G1, S01, S03

Leaf basis: calc

Multiply by 6 to cancel a unit and restore the original negative representative.

S05 · implies

Before

5^2\pmod7

After

5^2\equiv4,\quad5^4\equiv2,\quad5^6\equiv2\cdot4\equiv1\pmod7

Conditions: none

Rule: calc · Uses: G1, S04

Leaf basis: calc

Independent exact squaring and multiplication recheck the same result without floating-point powers.

S06 · implies

Before

a=7b,\quad b\in\mathbb Z

After

a^7\equiv0\equiv a\pmod7,\quad a^6\equiv0\not\equiv1\pmod7

Conditions: none

Rule: calc · Uses: G1, S01

Leaf basis: calc

If 7 divides a, the all-integer form still holds; the coprime form does not apply and a cannot be canceled.

S07 · implies

Before

n=341=11\cdot31,\quad2^{10}=1024

After

1024=3\cdot341+1\Rightarrow2^{340}=(2^{10})^{34}\equiv1\pmod{341}

Conditions: none

Rule: calc · Uses: G1

Leaf basis: calc

Composite 341 passes the base-2 Fermat congruence, directly refuting a primality converse.

S08 · implies

Before

p=7:\quad(-2)^6\equiv1,\quad a=7b:\ a^7\equiv a

After

\text{coprime and all-integer forms have different domains}

Conditions: none

Rule: mko_definition · Uses: G1, S04, S05, S06, S07

Leaf basis: mko_definition

Keep the two forms and composite counterexample separate, retaining the modulus on every equality.

Substeps and lemmas

No substeps in this guide.

Reverse audits

  • S08 · premise_audit · G1, S04, S05, S06, S07 — a^p=a is not an identity in Z; for example 2^7=128 is not 2.
  • S07 · premise_audit · G1 — 11 and 31 exceed 1, certifying compositeness; this does not refute the prime direction.
  • S06 · premise_audit · G1, S01 — 0^6 has a positive exponent and is zero, not a zero-division or 0^0 issue.
  • S05 · premise_audit · G1, S04 — Every product is reduced modulo 7; huge integer expansion is unnecessary.
  • S04 · premise_audit · G1, S01, S03 — Cancellation relies on an invertible product and cannot be copied to zero.
  • S03 · premise_audit · G1, S02 — The remainder 6 of 720 is nonzero and 6*6=1 modulo 7, hence invertible.
  • S02 · premise_audit · G1, S01 — All six inputs and outputs are listed, not a sample.
  • S01 · premise_audit · G1 — Primality and a nonzero base are qualified first, not inferred from passing Fermat.

Error controls and negative controls

Cancel units only

If p divides a, a cannot be canceled to obtain the coprime form.

Test direction

Certify primality before applying the theorem; a passing congruence does not certify primality.

  • 7^6=1 modulo 7. → reject — The base is zero modulo 7 and positive powers stay zero.
  • 2^340=1 mod 341 proves 341 prime. → reject — 341=11*31 is composite.
  • a^7=a as integers. → reject — For a=2,128 differs from 2; only their difference 126 is divisible by 7.

Result and limitations

(-2)^6 is congruent to 1 modulo 7; for multiples of 7, only the congruence a^7≡a modulo 7 applies; passing a Fermat test does not prove primality.

    Verification and source binding

    3 declared checks for this guide; only the listed expressions are covered.

    • source commit: b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f
    • adopted source SHA-256: 902aa6dadc0e15cc6307c24fbfeae81e06264151bfb3a4a53cd657582a78760a
    • original source SHA-256: df79da016f65691101971d594a3f3b8b5f4afcdf8a7607582a5050bee1841e02
    • Lean: NOT_RUN · independent AI: SCOPED_LEAD_AND_BILINGUAL_CONTEXT_REVIEW

    Same-source full JSON (formulas, ASTs, controls and revision log)