Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken length_replicate proof (chapter 8) #138

Open
ketilwright opened this issue Nov 23, 2024 · 1 comment
Open

Broken length_replicate proof (chapter 8) #138

ketilwright opened this issue Nov 23, 2024 · 1 comment

Comments

@ketilwright
Copy link

In the "Induction and Recursion" chapter, the last proof in "Local recursive declaration" doesn't work:

theorem length_replicate (n : Nat) (a : α) : (replicate n a).length = n := by
  exact aux n []
where
  aux (n : Nat) (as : List α)
      : (replicate.loop a n as).length = n + as.length := by
    match n with
    | 0   => simp [replicate.loop]
    | n+1 => simp [replicate.loop, aux n, Nat.add_succ, Nat.succ_add]

I was able to fix it by invoking add_succ and such_add from rw:

theorem length_replicate (n : Nat) (a : α) : (replicate n a).length = n := by
  exact aux n []
where
  aux (n : Nat) (as : List α)
      : (replicate.loop a n as).length = n + as.length := by
    match n with
    | 0   => simp [replicate.loop]
    | n+1 => simp [replicate.loop, aux n]; rw [Nat.add_succ, Nat.succ_add]

@ketilwright
Copy link
Author

lean --version says Lean (version 4.12.0, x86_64-apple-darwin22.6.0, commit dc2533473114, Release)

vlad902 added a commit to vlad902/theorem_proving_in_lean4 that referenced this issue Dec 5, 2024
As noted in leanprover#138, Nat.add_succ now leads to infinite recursion with
simp. Use Nat.add_assoc instead to close out the goal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant