{
  "artifactId": "artifact.library.mathlib.quadratic-reciprocity.v001",
  "candidateOnly": false,
  "category": "Number theory",
  "claimBoundary": "This page states Mathlib's Legendre-symbol formulation for primes supplied through Fact instances, with explicit exclusions p ≠ 2, q ≠ 2, and p ≠ q. It does not present the Jacobi-symbol variants or remove those hypotheses.",
  "collectionSlug": "landmark-theorems-in-mathlib",
  "exactFormalStatement": "theorem legendreSym.quadratic_reciprocity {p q : ℕ} [Fact (Nat.Prime p)] [Fact (Nat.Prime q)] (hp : p ≠ 2) (hq : q ≠ 2) (hpq : p ≠ q) : legendreSym q ↑p * legendreSym p ↑q = (-1) ^ (p / 2 * (q / 2))",
  "family": "Quadratic residues",
  "id": "library.mathlib.quadratic-reciprocity.v001",
  "links": {
    "collection": "/collections/landmark-theorems-in-mathlib/",
    "collectionData": "/data/collections/mathlib-landmarks.json",
    "entry": "/library-theorems/quadratic-reciprocity/",
    "entryData": "/data/library-theorems/quadratic-reciprocity.json",
    "evidence": "/proofs/artifact.library.mathlib.quadratic-reciprocity.v001.html",
    "evidenceData": "/data/proofs/artifact.library.mathlib.quadratic-reciprocity.v001.evidence.json",
    "source": "/sources/upstream/quadratic-reciprocity/"
  },
  "landmark": {
    "completeFormalType": "legendreSym.quadratic_reciprocity {p q : ℕ} [Fact (Nat.Prime p)] [Fact (Nat.Prime q)] (hp : p ≠ 2) (hq : q ≠ 2) (hpq : p ≠ q) : legendreSym q ↑p * legendreSym p ↑q = (-1) ^ (p / 2 * (q / 2))",
    "concepts": [
      "prime numbers",
      "quadratic residues",
      "Legendre symbols",
      "reciprocity"
    ],
    "plainLanguage": "For two distinct odd primes p and q, whether q is a square modulo p and whether p is a square modulo q are linked. Their Legendre symbols multiply to a sign determined by the parities encoded by p divided by 2 and q divided by 2.",
    "poster": {
      "alt": "An ivory theorem poster links distinct odd-prime medallions p and q with reciprocal arcs, displays the exact Legendre-symbol product and natural-division exponent, and gives the parity-controlled sign rule.",
      "byteSize": 2072186,
      "caption": "The reciprocal Legendre-symbol product has one exact parity-controlled sign, with p divided by 2 and q divided by 2 interpreted by natural-number floor division.",
      "description": "Green and blue prime medallions face each other across reciprocal arcs. A central formula gives the Legendre-symbol product and its sign exponent. Below it, the poster explicitly says natural division rounds down and separates the both-3-mod-4 minus case from the otherwise-plus case.",
      "derivatives": [
        {
          "byteSize": 88554,
          "height": 960,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/theorem-poster-v1-640.webp",
          "sha256": "sha256:69c9faaeaafa91c717c70854665105e836bb3ba3105345cd25cf506f60ef7a66",
          "width": 640
        },
        {
          "byteSize": 163922,
          "height": 1536,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/theorem-poster-v1-1024.webp",
          "sha256": "sha256:da03832bbe976c9e6b8b19d4acd48db07fd5df15a770ac0129d2b36ff558792b",
          "width": 1024
        }
      ],
      "generatedAt": "2026-07-18T16:15:27.450Z",
      "height": 1536,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/quadratic-reciprocity/theorem-poster-v1.png",
      "sha256": "sha256:81c08887bd6860423dfbf4ab5ff64b49898db2f14e479922d1d81a927b177638",
      "title": "Quadratic Reciprocity at a glance",
      "width": 1024,
      "kind": "theorem_poster",
      "transcript": "NUMBER THEORY · QUADRATIC RESIDUES\nQUADRATIC RECIPROCITY\np, q DISTINCT ODD PRIMES\nlegendreSym q p · legendreSym p q\n= (−1)^(p/2 · q/2)\np / 2 AND q / 2 USE NATURAL DIVISION\nROUND DOWN\nSIGN RULE\np ≡ 3 mod 4 AND q ≡ 3 mod 4 · −1\nOTHERWISE · +1\nRECIPROCAL QUESTIONS · ONE EXACT SIGN\nEXACT SCOPE\nLegendre symbols only, with primality, oddness, and distinctness."
    },
    "visual": {
      "alt": "Emerald and cobalt residue circles exchange two gold arrows, with aligned and parity-reversed echoes below.",
      "byteSize": 2533023,
      "caption": "Quadratic residue information in two odd distinct primes is linked in both directions, with a parity-controlled sign.",
      "description": "Two large symmetric residue circles face each other across reciprocal gold arrows. Smaller paired circles below show one aligned exchange and one restrained red reversal cue, suggesting the parity-dependent sign without rendering notation.",
      "derivatives": [
        {
          "byteSize": 33296,
          "height": 427,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/theorem-schematic-v1-640.webp",
          "sha256": "sha256:fa574b2e78ddbb4f5544c16f763a465e33fde28f3f55b454a0cf88a2ec2f3ed2",
          "width": 640
        },
        {
          "byteSize": 88758,
          "height": 800,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/theorem-schematic-v1-1200.webp",
          "sha256": "sha256:2b2dce2c6a942cff1585812736396024f6bc8407a55f2c9a89d6b0850387d37a",
          "width": 1200
        }
      ],
      "generatedAt": "2026-07-17T20:03:02Z",
      "height": 1024,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/quadratic-reciprocity/theorem-schematic-v1.png",
      "sha256": "sha256:7905689114c05db95a877d4d0a5234a7bd4e0f86474486f23b6eaf8f7d19f78b",
      "title": "Quadratic residue reciprocity schematic",
      "width": 1536
    },
    "walkthrough": {
      "introduction": "Mathlib's checked route prepares odd-prime field inputs, invokes its finite-field quadratic-character reciprocity identity, cancels the squared nonzero character factor, and evaluates the remaining parity signs.",
      "pages": [
        {
          "alt": "Matching green and blue prime-field wheels pass restrained red exceptional beads outside their odd residue orbits.",
          "byteSize": 3188911,
          "caption": "The non-two hypotheses supply the oddness and characteristic facts required by the quadratic-character identity.",
          "description": "Primality together with p ≠ 2 and q ≠ 2 supplies oddness for both primes, while the ZMod characteristic calculation supplies the non-characteristic-two input used later. The distinctness hypothesis is retained for the cross-field nonzero argument.",
          "derivatives": [
            {
              "byteSize": 42276,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-01-v1-640.webp",
              "sha256": "sha256:578cac3080ac2f637217298067b2e0c981e55c3475b5dbef55eecb08348942c4",
              "width": 640
            },
            {
              "byteSize": 181870,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-01-v1-1200.webp",
              "sha256": "sha256:052d9ff9581580b9055b628acf1f731418821b7a4069422fda5a7236413c99dc",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-20T18:27:37Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-01-v1.png",
          "sha256": "sha256:356f8498154c41fc5af237a112274859ca7f00ec9f5138a0ee387171c3b4a158",
          "title": "Prepare the odd-prime inputs",
          "width": 1536,
          "equation": "Odd p ∧ Odd q ∧ ringChar (ZMod q) ≠ 2",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 1
        },
        {
          "alt": "The same prime-field wheels exchange paired green and blue character ribbons through a glass lens around the gold sign rosette.",
          "byteSize": 3155770,
          "caption": "Mathlib's finite-field quadratic-character reciprocity lemma supplies the central cross-field relation.",
          "description": "The proof applies quadraticChar_odd_prime to ZMod p and the odd prime q, using p ≠ q to keep the transported element nonzero. After rewriting the cardinality of ZMod p, this becomes the relation that the remaining rewrites normalize.",
          "derivatives": [
            {
              "byteSize": 46650,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-02-v1-640.webp",
              "sha256": "sha256:ad92da5780dd670f86e38d7dde9cf461e5688b74bb4de3c34f446b0fe7f010a3",
              "width": 640
            },
            {
              "byteSize": 185694,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-02-v1-1200.webp",
              "sha256": "sha256:55ebfe4f5539b326289706da12ce29c9657d51a8c13fc9e6518c416817a2a5c8",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-20T18:31:50Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-02-v1.png",
          "sha256": "sha256:2d14f777a927e32bd6c93ebf07ec41e66ade83560aaf101b32f6cf2d25781c2d",
          "title": "Invoke quadratic-character reciprocity",
          "width": 1536,
          "equation": "h := quadraticChar_odd_prime ...",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 2
        },
        {
          "alt": "Layered versions of the recurring field wheels expose character structure while a doubled gold loop on the blue wheel closes at a noncentral bead.",
          "byteSize": 3057580,
          "caption": "Unfolding the Legendre symbols exposes multiplicative quadratic characters, and the squared nonzero character factor collapses to one.",
          "description": "The final rewrite chain expands both Legendre symbols, aligns the natural and integer casts, substitutes the reciprocity relation, rotates the product, and uses quadraticChar_sq_one with prime_ne_zero. This algebraic cancellation leaves only parity-controlled sign factors.",
          "derivatives": [
            {
              "byteSize": 46468,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-03-v1-640.webp",
              "sha256": "sha256:cfa31a8167d4925ac56b5dce4c40e3d907240cc8eae0f546cfd6830856218f6c",
              "width": 640
            },
            {
              "byteSize": 179008,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-03-v1-1200.webp",
              "sha256": "sha256:61ed014f86251dacf40cbf5f8bb8594ac2c4bda2e98dcf16e6dd101b0f223490",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-20T18:33:01Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-03-v1.png",
          "sha256": "sha256:c580eb8d5e44aa1d6effb228ec869c0fb00372256af399f6cc679bfe93c2f5a3",
          "title": "Normalize and cancel the square",
          "width": 1536,
          "equation": "quadraticChar (ZMod q) p ^ 2 = 1",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 3
        },
        {
          "alt": "The full green and blue wheels close a symmetric reciprocal circuit above a smaller parity echo with one restrained red half-turn on its gold rosette.",
          "byteSize": 3136451,
          "caption": "Oddness evaluates the two character signs and leaves exactly the parity-controlled sign in quadratic reciprocity.",
          "description": "The proof uses χ₄'s odd-input evaluation for p and q together with quadraticChar_neg_one in ZMod q. The exponent rewrites combine the two parity contributions and close the exact Legendre-symbol product stated by quadratic_reciprocity.",
          "derivatives": [
            {
              "byteSize": 46414,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-04-v1-640.webp",
              "sha256": "sha256:83b287423811ee195443769b1df1f8213613257b3cbf2a8052fbf1e301733fdf",
              "width": 640
            },
            {
              "byteSize": 180758,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-04-v1-1200.webp",
              "sha256": "sha256:6cacf4fb1f72dd896e07f32004aae40b1c9c49f97b8c05a3bee46cef3283044d",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-20T18:34:40Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/quadratic-reciprocity/proof-walkthrough-04-v1.png",
          "sha256": "sha256:2743cc0f7e5fdea3aca06aeaa2de4db7996f48626998a33f24d5fc8e9e941b04",
          "title": "Evaluate the reciprocity sign",
          "width": 1536,
          "equation": "legendreSym q p * legendreSym p q = (-1) ^ (p / 2 * (q / 2))",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 4
        }
      ],
      "title": "How quadratic characters yield reciprocity"
    },
    "whyLandmark": "Quadratic reciprocity is a central symmetry law of elementary number theory. It turns one quadratic-residue question into another, with an exact sign correction."
  },
  "nonClaims": [
    "Proof Atlas did not originate quadratic reciprocity or Mathlib's declaration.",
    "The displayed sign uses Mathlib's exact p / 2 * (q / 2) exponent form.",
    "The page does not claim a new proof or a stronger reciprocity law."
  ],
  "publicExportEligible": true,
  "relationship": "upstream_direct",
  "schemaVersion": "library-theorem-entry-data.v1",
  "statementId": "statement.library.mathlib.quadratic-reciprocity.v001",
  "statusAxes": {
    "acceptedAtlasResult": "Not recorded for the preferred artifact",
    "locallyReproduced": "Exact upstream declaration replayed",
    "reviewedPage": "Current public presentation reviewed",
    "upstreamIndexed": "Pinned source bytes verified locally"
  },
  "summary": "For distinct odd primes, the two Legendre symbols are related by the quadratic-reciprocity sign.",
  "targetId": "target.library.mathlib.quadratic-reciprocity.v001",
  "title": "Quadratic Reciprocity",
  "upstreamOrigin": {
    "declarationName": "legendreSym.quadratic_reciprocity",
    "immutableSourceUrl": "https://github.com/leanprover-community/mathlib4/blob/5e932f97dd25535344f80f9dd8da3aab83df0fe6/Mathlib/NumberTheory/LegendreSymbol/QuadraticReciprocity.lean#L107",
    "packageName": "mathlib",
    "repositoryUrl": "https://github.com/leanprover-community/mathlib4",
    "sourceArtifactHash": "sha256:24ffbf256f6f6f7a2617901323c2d532e2d7871c826a8b11f0580b283e994302",
    "sourceByteLength": 6562,
    "sourceCommit": "5e932f97dd25535344f80f9dd8da3aab83df0fe6",
    "sourceFile": "Mathlib/NumberTheory/LegendreSymbol/QuadraticReciprocity.lean",
    "sourceLine": 107,
    "verificationKind": "git_worktree"
  },
  "publicPresentationReview": {
    "status": "reviewed"
  }
}
