Files
NNG/Game/Levels/Tutorial/Level_2.lean
2023-08-11 15:06:01 +02:00

45 lines
1.4 KiB
Lean4
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Game.Metadata
import Game.MyNat.Multiplication
World "Tutorial"
Level 2
Title "the rw tactic"
Introduction
"
In this level, you also get \"Assumptions\" about your objects. These are hypotheses of which
you assume (or know) that they are true.
The \"rewrite\" tactic `rw` is the way to \"substitute in\" the value of a variable.
If you have a hypothesis of the form `A = B`, and your goal mentions
the left hand side `A` somewhere,
then the rewrite tactic will replace the `A` in your goal with a `B`.
Here is a theorem which cannot be proved using rfl -- you need a rewrite first.
"
/-- If $x$ and $y$ are natural numbers, and $y = x + 7$, then $2y = 2(x + 7)$. -/
Statement
(x y : ) (h : y = x + 7) : 2 * y = 2 * (x + 7) := by
Hint "You can use `rw [h]` to replace the `{y}` with `x + 7`.
Note that the assumption `h` is written
inside square brackets: `[h]`."
rw [h]
Hint "Not all hints are directly shown. If you are stuck and need more help
finishing the proof, click on \"More Help\" below!"
Hint (hidden := true)
"Now both sides are identical, so you can use `rfl` to close the goal."
rfl
NewTactic rw
Conclusion
"
If you want to inspect the proof you created, toggle \"Editor mode\" above.
There you can also move your cursor around the proof to see the \"state\" of the proof at this point.
Each tactic is written on a new line and Lean is sensitive to indentation (i.e. there must be no
spaces before any of the tactics)
"