\n
## Code Snippet: Formal Proof of Quadratic Reciprocity
### Overview
The image displays a screenshot of a code editor or terminal window with a dark theme. It contains a single, complete line of formal code representing a mathematical theorem and its proof. The code is written in a language that appears to be a proof assistant (like Lean), using formal logic and type theory to state and prove the law of quadratic reciprocity.
### Components/Axes
* **Window Frame:** A dark gray rectangular window with rounded corners. The top-left corner contains three circular window control buttons (red, yellow, green), characteristic of a macOS interface.
* **Code Content:** The main body of the window contains a single, multi-part statement written in a monospaced font with syntax highlighting. The text is left-aligned.
* **Syntax Highlighting Colors:**
* Keywords (`theorem`, `by`, `exact`): Light pink/salmon.
* Theorem/Function names (`quadratic_reciprocity_2`, `legendre_sym`, `book.quadratic_reciprocity.quadratic_reciprocity_1`): Light blue/cyan.
* Variables and parameters (`p`, `q`, `hp`, `hq`): Light orange/peach.
* Types and constants (`ℕ`, `Nat.Prime`, `Fact`): Light green.
* Operators and punctuation (`:`, `≠`, `*`, `^`, `/`, `:=`): White or light gray.
* Numeric literals (`2`, `1`): Light purple.
### Detailed Analysis
The code is a formal theorem statement and proof. Here is the precise transcription:
**Line 1:** `theorem quadratic_reciprocity_2 (p q : ℕ) (hp : p ≠ 2) (hq : q ≠ 2)`
* Declares a theorem named `quadratic_reciprocity_2`.
* Takes four parameters:
* `p` and `q`, which are of type `ℕ` (the natural numbers).
* `hp`, which is a proof (or hypothesis) that `p` is not equal to 2.
* `hq`, which is a proof that `q` is not equal to 2.
**Line 2:** `[Fact (Nat.Prime p)] [Fact (Nat.Prime q)] :`
* This line provides additional typeclass instances or facts.
* `[Fact (Nat.Prime p)]`: Asserts the fact that `p` is a prime number.
* `[Fact (Nat.Prime q)]`: Asserts the fact that `q` is a prime number.
* The colon `:` ends the parameter and hypothesis list, leading to the theorem's statement.
**Line 3:** `(legendre_sym p q) * (legendre_sym q p) = -1 ^ (((p-1) / 2 * (q - 1) / 2 ) := by`
* This is the core statement of the theorem.
* `(legendre_sym p q)`: Represents the Legendre symbol `(p/q)`.
* `(legendre_sym q p)`: Represents the Legendre symbol `(q/p)`.
* The statement claims that the product of these two symbols equals `-1` raised to the power of `((p-1)/2 * (q-1)/2)`.
* `:= by` indicates that the proof of this statement follows.
**Line 4:** `exact book.quadratic_reciprocity.quadratic_reciprocity_1 p q hp hq`
* This is the proof tactic.
* `exact`: A tactic that solves the goal by providing a exact term that matches the goal type.
* `book.quadratic_reciprocity.quadratic_reciprocity_1`: References a previously proven theorem (likely from a formalized library or "book") named `quadratic_reciprocity_1`.
* `p q hp hq`: The parameters passed to this referenced theorem, which matches the hypotheses of the current theorem.
### Key Observations
1. **Formal Verification:** The code is not executable in the traditional sense but is a formal, machine-checkable proof of a fundamental theorem in number theory.
2. **Theorem Dependency:** This theorem (`quadratic_reciprocity_2`) is a direct corollary or restatement of a more fundamental theorem (`quadratic_reciprocity_1`), as evidenced by the `exact` tactic.
3. **Hypothesis Constraints:** The proof explicitly requires that `p` and `q` are odd primes (not equal to 2), which is a standard condition for the most common formulation of the law of quadratic reciprocity.
4. **Mathematical Content:** The equation `(p/q)*(q/p) = (-1)^{((p-1)/2 * (q-1)/2)}` is the classic statement of the law of quadratic reciprocity, which describes the relationship between the solvability of the quadratic congruences `x² ≡ p mod q` and `x² ≡ q mod p`.
### Interpretation
This image captures a moment in the formalization of mathematics. It shows how a deep, classical result from 18th-century number theory (first proved by Gauss) is encoded in a 21st-century proof assistant. The code demonstrates the **Peircean investigative** process of moving from a general law (quadratic reciprocity) to a specific, verifiable instance (`quadratic_reciprocity_2`) by applying known facts (p and q are odd primes) and leveraging existing formal knowledge (`quadratic_reciprocity_1`).
The significance lies in the **translation of human mathematical insight into a rigid, logical structure** that a computer can validate. This process eliminates ambiguity and provides an absolute guarantee of correctness for the theorem under the given hypotheses. The snippet is a microcosm of modern formal mathematics: building complex, trusted results upon a foundation of previously verified code.