NNG4 Solutions
Website Hosted By Heinrich Heine University Düsseldorf
Assuming you have a basic understanding of Lean 4 — at least knowing what it is used for.
Tutorial World
Level 1. The rfl tactic
Introduce the first tactic called rfl, which proves all the theorems of the form X = X.
1 | example (x q : Nat) : 37 * x + q = 37 * x + q := by |
About
rfl:
rflis short for “reflexivity of equality”.- For pedagogical purposes, our
rflis weaker than the standard version in Lean. Mathematicians don’t distinguish between propositional equality and definitional equality — to them,zero_addandadd_zeroare just “facts”, and who cares about how addition is defined.- So in standard Lean,
2 + 2 = 4can be provide byrflbecause it’s a definitional equality. But in NNG4,2 + 2 = 4cannot be proved byrflalone.
Level 2. the rw tactic
The proof is simply to substitute h into the goal, which can be done by rw [h]. After rewriting, the goal becomes 2 * (x + 7) = 2 * (x + 7).
1 | example (x y : Nat) (h : y = x + 7) : 2 * y = 2 * (x + 7) := by |
About
rw:
- If
his a proof of an equalityX = Y, thenrw [h]will change allXs in the goal toYs. It’s the way to “substitute in”.
- 标题: NNG4 Solutions
- 作者: Gavin
- 创建于 : 2026-04-28 10:59:00
- 更新于 : 2026-04-28 12:05:00
- 链接: https://gavin-blog.pages.dev/2026/nng4-solutions/
- 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。