Zulip Chat Archive

Stream: lean4

Topic: How to make induction tactic produce equality?


Andrey Yao (Nov 07 2024 at 22:47):

Say I have a list l and I want to do induction l with | nil => ... | cons hd tl IH => ..., how do I get Lean to produce the hypothesis l = cons hd tl in the second case? It would be similar to the induction ... eqn:E tactic from Coq, Thanks!

Kyle Miller (Nov 07 2024 at 22:50):

This feature doesn't exist yet for induction. If you use mathlib, induction' h : l would work, but then you don't get the with syntax. (For induction', the with clause takes a list of all the variable names. It's like in the Lean 3 version of induction.)

Kyle Miller (Nov 07 2024 at 22:52):

I think this simulates it:

example (p : List Nat  Prop) (l : List Nat) : p l := by
  generalize h : l = l'
  induction l' generalizing l with
  | nil => sorry
  | cons hd tl IH => sorry

Andrey Yao (Nov 07 2024 at 23:15):

That worked! Tysm


Last updated: May 02 2025 at 03:31 UTC