File tree Expand file tree Collapse file tree 1 file changed +26
-13
lines changed
LeanByExample/Declarative Expand file tree Collapse file tree 1 file changed +26
-13
lines changed Original file line number Diff line number Diff line change 66-/
77mutual
88
9- /-- 偶数 -/
10- def even (n : Nat) : Bool :=
11- match n with
12- | 0 => true
13- | n + 1 => odd n
14-
15- /-- 奇数 -/
16- def odd (n : Nat) : Bool :=
17- match n with
18- | 0 => false
19- | n + 1 => even n
9+ /-- 偶数であることを表す述語 -/
10+ inductive Even : Nat → Prop where
11+ | zero : Even 0
12+ | succ {n : Nat} (h : Odd n) : Even (n + 1 )
2013
14+ /-- 奇数であることを表す述語 -/
15+ inductive Odd : Nat → Prop where
16+ | succ {n : Nat} (h : Even n) : Odd (n + 1 )
2117end
18+ /-
19+ 相互再帰を使って定義された概念に対して証明を行う場合、定理も相互再帰的にする必要が生じることがあります。
20+ -/
21+ mutual
2222
23- #guard even 4
23+ theorem Even.exists {n : Nat} (h : Even n) : ∃ a, n = 2 * a := by
24+ cases h with
25+ | zero => exists 0
26+ | @succ n h =>
27+ obtain ⟨a, ha⟩ := h.exists
28+ exists (a + 1 )
29+ grind
2430
25- #guard odd 5
31+ theorem Odd.exists {n : Nat} (h : Odd n) : ∃ a, n = 2 * a + 1 := by
32+ cases h with
33+ | @succ n h =>
34+ obtain ⟨a, ha⟩ := Even.exists h
35+ exists a
36+ grind
37+
38+ end
You can’t perform that action at this time.
0 commit comments