Skip to content

Commit

Permalink
Fix broken code example (leanprover#138)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vlad902 committed Dec 5, 2024
1 parent ce23823 commit bc20546
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions induction_and_recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def listAdd [Add α] : List α → List α → List α

You are encouraged to experiment with similar examples in the exercises below.

Local recursive declarations
Local Recursive Declarations
---------

You can define local recursive declarations using the `let rec` keyword.
Expand Down Expand Up @@ -633,7 +633,7 @@ theorem length_replicate (n : Nat) (a : α) : (replicate n a).length = n := by
: (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]
| n+1 => simp [replicate.loop, aux n, Nat.add_assoc, Nat.succ_add]
exact aux n []
```

Expand All @@ -655,7 +655,7 @@ where
: (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]
| n+1 => simp [replicate.loop, aux n, Nat.add_assoc, Nat.succ_add]
```

Well-Founded Recursion and Induction
Expand Down

0 comments on commit bc20546

Please sign in to comment.