Zulip Chat Archive

Stream: mathlib4

Topic: indentation


Kevin Buzzard (Nov 09 2022 at 13:33):

@[elab_as_elim]
theorem trans_induction_on {P :  {a b : α}, TransGen r a b  Prop} {a b : α} (h : TransGen r a b)
    (base :  {a b} (h : r a b), P (single h))
    (ih :  {a b c} (h₁ : TransGen r a b) (h₂ : TransGen r b c), P h₁  P h₂  P (h₁.trans h₂)) :
    P h := by
  induction h
  case single a h => exact base h
  case tail b c hab hbc h_ih => exact ih hab (single hbc) h_ih (base hbc)

Have I understood the conventions yet? 4 spaces for the continuation of the statement of the theorem, colon at the end, still 4 spaces for the type, two spaces for the proof, don't need any more indentation even though there are two goals after induction.

Mario Carneiro (Nov 09 2022 at 13:38):

only thing I would mention is that it is preferable to use

  induction h with
  | single a h => exact base h
  | tail b c hab hbc h_ih => exact ih hab (single hbc) h_ih (base hbc)

instead of induction; case when it's just listing all the cases

Kevin Buzzard (Nov 09 2022 at 13:42):

I blame the guy who wrote the porting program for that one.

Mario Carneiro (Nov 09 2022 at 13:46):

ooh, that would be pretty fancy if we could try to apply that transformation. It's possible to do the syntactic transformation, but we basically have no idea whether the tactic will work

Mario Carneiro (Nov 09 2022 at 13:48):

the more common pattern in mathlib uses induction h with _ _ _ a b _ c and this kind of thing is pretty hopeless to transform into a well structured induction without type info

Mario Carneiro (Nov 09 2022 at 13:49):

I'm hoping that we will eventually get auto-applicable linters that will just recommend to replace working induction' proofs with correctly structured induction proofs


Last updated: Dec 20 2023 at 11:08 UTC