## Code Snippet: Lean 4 Theorem Proofs
### Overview
The image is a screenshot of a code editor or terminal window displaying three mathematical theorem statements and their proofs written in the Lean 4 programming language and proof assistant. The window has a dark theme with syntax highlighting.
### Components/Axes
* **Window Frame:** A dark gray rectangular window with rounded corners, centered on a light gray background.
* **Title Bar:** Contains three colored circles (from left to right: red, yellow, green) in the top-left corner, typical of a macOS window control interface.
* **Main Content Area:** A dark charcoal background containing the code text. The text uses a monospaced font with syntax highlighting:
* Keywords (`theorem`, `by`, `simp`, `rw`, `apply`, `exact`) are in a salmon/pink color.
* Theorems names (`scalar_div_one`, `scalar_min_zero_one`, `id_rule`) are in a light blue/teal color.
* Variables (`x`, `R`, `X`) and function names (`min`, `invFun`, `Function.invFun_comp`, `Function.injective_id`) are in a light purple/lavender color.
* Operators (`:=`, `:`, `=`, `/`, `=>`) and punctuation are in a light gray or white color.
* Numeric literals (`0`, `1`) are in a light orange color.
### Detailed Analysis
The image contains three distinct theorem blocks. The language is Lean 4.
**1. Theorem: `scalar_div_one`**
* **Statement:** `theorem scalar_div_one (x : R) : x / 1 = x := by`
* **Proof:** `simp`
* **Transcription & Translation:**
* **Lean Code:** `theorem scalar_div_one (x : R) : x / 1 = x := by simp`
* **English Translation:** This theorem states that for any element `x` of type `R` (likely a ring or field), dividing `x` by the multiplicative identity `1` yields `x`. The proof is solved by the simplifier tactic (`simp`), which applies known simplification rules.
**2. Theorem: `scalar_min_zero_one`**
* **Statement:** `theorem scalar_min_zero_one : min (0 : R) (1 : R) = 0 := by`
* **Proof:**
* `rw [min_comm]`
* `simp`
* **Transcription & Translation:**
* **Lean Code:** `theorem scalar_min_zero_one : min (0 : R) (1 : R) = 0 := by rw [min_comm] simp`
* **English Translation:** This theorem states that the minimum of `0` and `1` (both explicitly typed as elements of `R`) is `0`. The proof first rewrites (`rw`) the goal using the commutativity of the minimum function (`min_comm`), which swaps the arguments, and then solves the resulting goal with the simplifier (`simp`).
**3. Theorem: `id_rule`**
* **Statement:** `theorem id_rule : invFun (fun (x : X) => x) = fun x => x := by`
* **Proof:**
* `apply Function.invFun_comp`
* `exact Function.injective_id`
* **Transcription & Translation:**
* **Lean Code:** `theorem id_rule : invFun (fun (x : X) => x) = fun x => x := by apply Function.invFun_comp exact Function.injective_id`
* **English Translation:** This theorem states that the inverse function (`invFun`) of the identity function on type `X` (`fun (x : X) => x`) is itself the identity function (`fun x => x`). The proof applies a lemma about the composition of a function with its inverse (`Function.invFun_comp`) and then provides the exact proof that the identity function is injective (`Function.injective_id`) to close the goal.
### Key Observations
* The code demonstrates basic properties in algebra (division by one, minimum of zero and one) and function theory (inverse of the identity function).
* The proofs are concise, leveraging built-in tactics (`simp`) and library lemmas (`min_comm`, `Function.invFun_comp`, `Function.injective_id`).
* The syntax highlighting is consistent, aiding readability by distinguishing language constructs from user-defined names.
* The theorems are named in a snake_case convention (`scalar_div_one`).
### Interpretation
This image is a technical artifact from the domain of formal verification and interactive theorem proving. It showcases how mathematical truths are encoded and proven within a dependently typed language like Lean 4.
* **What it demonstrates:** The theorems are foundational, almost axiomatic, statements. Their formal proof, even for simple facts like `x / 1 = x`, is crucial for building a reliable mathematical library. The `id_rule` theorem is fundamental in category theory and functional programming, establishing that the identity function is its own inverse.
* **How elements relate:** Each block follows the pattern: `theorem [name] : [statement] := by [proof script]`. The proof scripts show a hierarchy of automation: `simp` for simple algebraic facts, `rw` for rewriting with lemmas, and `apply`/`exact` for more structured, manual proof steps.
* **Notable patterns:** The use of type ascriptions (`(0 : R)`) in the second theorem ensures clarity and avoids ambiguity. The progression from a one-line `simp` proof to a two-step proof using a rewrite rule and then `simp` illustrates different proof strategies within the same system. The image serves as a clear example of the "source code" of formal mathematics.