Created
June 17, 2026 04:42
-
-
Save kenji4569/9c1cc2e9b9d28ecf147363e8c03104f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 信号の色を表す型を定義する。 | |
| -- `inductive` は、場合の候補を並べて新しい型を作る。 | |
| inductive Light | |
| | red | |
| | yellow | |
| | green | |
| -- 次の信号の色を返す関数。 | |
| def next | |
| | Light.red => Light.green | |
| | Light.green => Light.yellow | |
| | Light.yellow => Light.red | |
| theorem red_never_direct_to_yellow : next Light.red ≠ Light.yellow := by | |
| -- `simp` は定義を展開して式を簡単にする。 | |
| simp [next] | |
| theorem next_three_times_returns_same (l : Light) : next (next (next l)) = l := by | |
| -- `cases l` は `l` を `red` `yellow` `green` の各場合に分ける。 | |
| -- `<;>` は、右側の tactic をすべてのゴールに適用する。 | |
| -- `rfl` は左右が定義上同じときに証明を閉じる。 | |
| cases l <;> rfl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment