{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-fermat-little-theorem-01",
  "mko_id": "mko-fermat-little-theorem",
  "title": {
    "zh-Hant": "模7的Fermat證書與合數邊界",
    "en": "Fermat modulo 7 and a composite boundary"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-fermat-little-theorem-01",
    "source": {
      "mko_id": "mko-fermat-little-theorem",
      "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
      "sha256": "8ba0aab812152c67f3df53e149427ab6d311dab16d274314d1ad46b4ee3114d7",
      "english_sha256": "26ee5d2d09455781b206bf52404c98ec56346bdfa0f20829131a82e3e7481aba"
    },
    "mode": "worked_example",
    "audience_prerequisites": [
      "calc"
    ],
    "goal": {
      "zh-Hant": "(−2)^6≡1 mod7；倍數7只可用a^7≡a版本；通過測試不證質數。",
      "en": "(-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."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "p=7，a=−2，先正規化a≡5 mod7；定理形式為同餘而非整數等式。",
          "en": "p=7,a=-2, normalized to 5 modulo 7; the theorem statements are congruences, not integer equalities."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1"
        ],
        "before_tex": "p=7,\\quad a=-2",
        "after_tex": "7\\text{ prime},\\quad a\\equiv5\\pmod7,\\quad7\\nmid a",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "若7合數有不超√7的質因數，唯一候選2不整除7；故prime，且base是unit。",
          "en": "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."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1"
          ],
          "explanation": {
            "zh-Hant": "prime檢查與base非零先完成，不由Fermat通過反證prime。",
            "en": "Primality and a nonzero base are qualified first, not inferred from passing Fermat."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S02",
        "uses": [
          "G1",
          "S01"
        ],
        "before_tex": "U_7=\\{1,2,3,4,5,6\\}",
        "after_tex": "5U_7\\pmod7=(5,3,1,6,4,2)",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "全部非零代表乘5後各出現一次，所以形成完整排列。",
          "en": "Multiplying every nonzero residue by 5 produces each exactly once, a complete permutation."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01"
          ],
          "explanation": {
            "zh-Hant": "六個輸入輸出均列，未只核少數pairs。",
            "en": "All six inputs and outputs are listed, not a sample."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S03",
        "uses": [
          "G1",
          "S02"
        ],
        "before_tex": "\\prod_{u\\in U_7}(5u)\\equiv\\prod_{u\\in U_7}u\\pmod7",
        "after_tex": "5^6\\cdot720\\equiv720\\pmod7,\\quad720\\equiv6\\pmod7",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "排列使乘積不變，抽出六個5後得到可消去的乘積。",
          "en": "Permutation preserves the product; factoring out six copies of 5 yields the product to cancel."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02"
          ],
          "explanation": {
            "zh-Hant": "720的餘數6非零，且6·6≡1 mod7，故可逆。",
            "en": "The remainder 6 of 720 is nonzero and 6*6=1 modulo 7, hence invertible."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S04",
        "uses": [
          "G1",
          "S01",
          "S03"
        ],
        "before_tex": "5^6\\cdot6\\equiv6\\pmod7",
        "after_tex": "5^6\\equiv1\\pmod7\\Rightarrow(-2)^6\\equiv1\\pmod7",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "兩側乘6消去unit，回到原負base的同餘。",
          "en": "Multiply by 6 to cancel a unit and restore the original negative representative."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01",
            "S03"
          ],
          "explanation": {
            "zh-Hant": "消去依乘積可逆，不允許在0上照做。",
            "en": "Cancellation relies on an invertible product and cannot be copied to zero."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S05",
        "uses": [
          "G1",
          "S04"
        ],
        "before_tex": "5^2\\pmod7",
        "after_tex": "5^2\\equiv4,\\quad5^4\\equiv2,\\quad5^6\\equiv2\\cdot4\\equiv1\\pmod7",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "獨立exact平方乘法再核同一結果，無浮點冪。",
          "en": "Independent exact squaring and multiplication recheck the same result without floating-point powers."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S04"
          ],
          "explanation": {
            "zh-Hant": "每次積後都取mod7，巨大整數展開並非必要。",
            "en": "Every product is reduced modulo 7; huge integer expansion is unnecessary."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S06",
        "uses": [
          "G1",
          "S01"
        ],
        "before_tex": "a=7b,\\quad b\\in\\mathbb Z",
        "after_tex": "a^7\\equiv0\\equiv a\\pmod7,\\quad a^6\\equiv0\\not\\equiv1\\pmod7",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "若7整除a，全整數形式仍成立；互質形式不適用，不能消去a。",
          "en": "If 7 divides a, the all-integer form still holds; the coprime form does not apply and a cannot be canceled."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01"
          ],
          "explanation": {
            "zh-Hant": "0^6有正指數且等0，不是除零或0^0問題。",
            "en": "0^6 has a positive exponent and is zero, not a zero-division or 0^0 issue."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S07",
        "uses": [
          "G1"
        ],
        "before_tex": "n=341=11\\cdot31,\\quad2^{10}=1024",
        "after_tex": "1024=3\\cdot341+1\\Rightarrow2^{340}=(2^{10})^{34}\\equiv1\\pmod{341}",
        "relation": "implies",
        "rule": "calc",
        "conditions": [],
        "explanation": {
          "zh-Hant": "合數341也通過base2 Fermat congruence，直接否證測試的prime converse。",
          "en": "Composite 341 passes the base-2 Fermat congruence, directly refuting a primality converse."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1"
          ],
          "explanation": {
            "zh-Hant": "11與31都大於1，合數性由因數而非猜測；這不違反prime方向。",
            "en": "11 and 31 exceed 1, certifying compositeness; this does not refute the prime direction."
          }
        },
        "leaf_basis": "calc"
      },
      {
        "id": "S08",
        "uses": [
          "G1",
          "S04",
          "S05",
          "S06",
          "S07"
        ],
        "before_tex": "p=7:\\quad(-2)^6\\equiv1,\\quad a=7b:\\ a^7\\equiv a",
        "after_tex": "\\text{coprime and all-integer forms have different domains}",
        "relation": "implies",
        "rule": "mko_definition",
        "conditions": [],
        "explanation": {
          "zh-Hant": "將兩形式與合數反例分層，所有等式均保留模數範圍。",
          "en": "Keep the two forms and composite counterexample separate, retaining the modulus on every equality."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S04",
            "S05",
            "S06",
            "S07"
          ],
          "explanation": {
            "zh-Hant": "沒有把a^p=a當Z中恆等式；例如2⁷=128不等2。",
            "en": "a^p=a is not an identity in Z; for example 2^7=128 is not 2."
          }
        },
        "leaf_basis": "mko_definition"
      }
    ],
    "result": {
      "zh-Hant": "(−2)^6≡1 mod7；倍數7只可用a^7≡a版本；通過測試不證質數。",
      "en": "(-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."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "7^6≡1 mod7。",
          "en": "7^6=1 modulo 7."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "base為0類，正冪仍0。",
          "en": "The base is zero modulo 7 and positive powers stay zero."
        }
      },
      {
        "claim": {
          "zh-Hant": "2^340≡1 mod341證341質數。",
          "en": "2^340=1 mod 341 proves 341 prime."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "341=11·31合數。",
          "en": "341=11*31 is composite."
        }
      },
      {
        "claim": {
          "zh-Hant": "a^7=a是整數等式。",
          "en": "a^7=a as integers."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "a=2時128≠2，僅差126可被7整除。",
          "en": "For a=2,128 differs from 2; only their difference 126 is divisible by 7."
        }
      }
    ],
    "status": "candidate",
    "gaps": [],
    "verification": {
      "structure": "checked_local_script",
      "mathematics": "candidate_argument",
      "formalization": "not_formalized"
    },
    "rule_glossary": [
      {
        "id": "calc",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "假設精確整數算術、帶餘除法、整除與gcd的定義；同餘等式始終綁定明示模數。明示假設完整trial division至平方根的prime判準。",
          "en": "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."
        }
      },
      {
        "id": "mko_definition",
        "kind": "cited",
        "statement": {
          "zh-Hant": "模數p須明示為prime且p>=2。coprime版本僅在p不整除a時使用；p整除a仍可用all-integer版本但不得消去a。exact modular exponentiation正規化負底數，並以561等合數邊界展示Fermat test converse失敗。",
          "en": "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."
        },
        "source": {
          "mko_id": "mko-fermat-little-theorem",
          "sha256": "8ba0aab812152c67f3df53e149427ab6d311dab16d274314d1ad46b4ee3114d7",
          "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f"
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": [
      {
        "id": "power",
        "lhs": "5**6%7",
        "rhs": "1",
        "step": "S05"
      },
      {
        "id": "composite",
        "lhs": "11*31",
        "rhs": "341",
        "step": "S07"
      },
      {
        "id": "pseudoprime_small",
        "lhs": "(2**10)%341",
        "rhs": "1",
        "step": "S07"
      }
    ]
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "明示prime modulus7、完整乘法排列及exact平方乘法，另列合數341。",
      "en": "Explicit prime modulus 7, full multiplication permutation and exact squaring, with composite 341 separately."
    },
    "md_symbols": [
      [
        "p",
        "已核prime modulus",
        "qualified prime modulus"
      ],
      [
        "U_7",
        "全部非零mod7代表",
        "all nonzero residues modulo 7"
      ]
    ],
    "md_error_controls": [
      {
        "title": "消去unit / Cancel units only",
        "zh": "a被p整除時不可消去a來取得互質形式。",
        "en": "If p divides a, a cannot be canceled to obtain the coprime form."
      },
      {
        "title": "測試方向 / Test direction",
        "zh": "先認證prime再套定理；通過同餘不反證prime。",
        "en": "Certify primality before applying the theorem; a passing congruence does not certify primality."
      }
    ],
    "md_open_items": []
  },
  "revision": {
    "id": "ocme-new142-reader-adoption-20261021",
    "collection": "coverage-20261021",
    "source_commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
    "adopted_source_sha256": "902aa6dadc0e15cc6307c24fbfeae81e06264151bfb3a4a53cd657582a78760a",
    "original_source_sha256": "df79da016f65691101971d594a3f3b8b5f4afcdf8a7607582a5050bee1841e02",
    "owner_adopted": true,
    "bilingual_sync": "complete_source_bound",
    "formal_Lean": "NOT_RUN",
    "reader_review": "142_of_142_source_bound",
    "wording_review": "original_Lead_decisions_resolved",
    "glossary_reader_paraphrases": [],
    "independent_AI_concurrence": "SCOPED_LEAD_AND_BILINGUAL_CONTEXT_REVIEW",
    "issue_ids": [
      "BR142-P033",
      "BR142-P034"
    ],
    "parent_manifest_sha256": "d29f4cae8229ebd24f60d496cb1d3cd4ad8c0a4dca9d44daab0c3245c544283a",
    "scope": "Owner-adopted reader revision. Lead and bilingual review concern the recorded text and premises; no new universal or Lean proof, canonical promotion or historical-label rewrite."
  }
}
