Zulip Chat Archive

Stream: batteries

Topic: why do these cumbersome hypotheses keep showing up?


Bulhwi Cha (Oct 15 2024 at 16:50):

Bulhwi Cha said:

When I proved that the theorem String.splitOnAux_of_valid terminates, I had to hide more than ten illegible hypotheses from each goal: https://github.com/leanprover-community/batteries/pull/743/files#diff-38e93b9f694cdc66d675df840d70c3c0d47cc4b5a1813c4aa7d4d7744efff544R487-R510.

I wonder why these unwanted hypotheses show up. Here's the hypothesis _₀ of the first goal:

Hypothesis

Today, I had to clean up twenty-seven hypotheses while writing the termination proof for one of my new theorems in Batteries#987:

See the last theorem of my code

Kyle Miller (Oct 15 2024 at 17:17):

One way to avoid this to prove it without any recursion or induction:

theorem not_prefix_and_not_prefix_symm_iff {l₁ l₂ p t₁ t₂ : List α} (hp : commonPrefix l₁ l₂ = p)
    (h₁ : l₁ = p ++ t₁) (h₂ : l₂ = p ++ t₂) : ¬l₁ <+: l₂  ¬l₂ <+: l₁  t₁  []  t₂  [] 
      t₁.head?  t₂.head? := by
  subst_vars
  rw [prefix_append_right_inj, prefix_append_right_inj]
  rw [commonPrefix_append_append, append_right_eq_self] at hp
  cases t₁ <;> cases t₂
  · simp
  · simp
  · simp
  · simp only [commonPrefix, ite_eq_right_iff, reduceCtorEq, imp_false] at hp
    simp [Ne.symm hp, hp]

Bulhwi Cha (Oct 15 2024 at 17:36):

Thanks! Then, what should I do when I have to use recursion or induction to prove a theorem like String.splitOnAux_of_valid?


Last updated: May 02 2025 at 03:31 UTC