You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lean4game/server/nng/NNG/Levels/Tutorial/Level_2.lean

47 lines
1.5 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import NNG.Metadata
import NNG.MyNat.Multiplication
Game "NNG"
World "Tutorial"
Level 2
Title "the rewrite (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 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`.
*(Note: For this game, `rw` is a shorthand for `rewrite`. Out in the real world, `rw` tries to call
`rfl` automatically afterwards.)*
"
Statement
"If $x$ and $y$ are natural numbers, and $y = x + 7$, then $2y = 2(x + 7)$."
(x y : ) (h : y = x + 7) : 2 * y = 2 * (x + 7) := by
Hint "You can use `rewrite [h]` to replace the `{y}` with `x + 7`.
Note that the assumption `h` is written
inside square brackets: `[h]`."
rw [h]
Hint "In this game not all hints are directly shown. If you need 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 rewrite rw
Conclusion
"
If you want to see the entire 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)
"