File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
LeanByExample/Reference/Tactic Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,35 @@ def bar : Nat → Nat
186186#guard_msgs (drop warning) in --#
187187#check_failure bar.induct
188188
189+ /- ## よくあるエラー
190+ `induction` タクティクを使ったときに、`index in target's type is not a variable` というエラーが出ることがあります。
191+ -/
192+
193+ /-- 偶数であることを表す帰納的述語 -/
194+ inductive MyEven : Nat → Prop where
195+ | zero : MyEven 0
196+ | succ : {n : Nat} → MyEven n → MyEven (n + 2 )
197+
198+ /--
199+ error: index in target's type is not a variable (consider using the `cases` tactic instead)
200+ 0
201+ -/
202+ #guard_msgs in
203+ example (h : MyEven 0 ) : True := by
204+ induction h
205+
206+ /- これは型族の添え字が変数ではないから起こることです。その証拠に、変数にするとエラーにならなくなります。-/
207+
208+ example (n m : Nat) (h : MyEven (n + m)) : True := by
209+ /-
210+ index in target's type is not a variable (consider using the `cases` tactic instead)
211+ n + m
212+ -/
213+ generalize n + m = x at h
214+ induction h
215+ · trivial
216+ · trivial
217+
189218/-
190219[ ^recursive ] : [ lean公式ブログの Functional induction についての記事 ] (https://lean-lang.org/blog/2024-5-17-functional-induction/) で recursive theorem という言葉が使われています。
191220-/
You can’t perform that action at this time.
0 commit comments