[Typo] Section 8.5 recursion on wrong var in Nat.plusR rhs

Open
#160 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Domain
documentation

Research direction

Open Section 8.5 and inspect the Nat.plusR example shown in the issue. Correct the recursive right-hand side as indicated, then verify that the example no longer reports the displayed termination error.

Written by the indexing model from the issue text.

Description

Typo
def Nat.plusR : Nat → Nat → Nat
  | n, 0 => n
  | n, k + 1 => plusR n k + 1

The recursion doesn't reduce the size of either Nat and generates a "Failed to show termination" error. I believe the last line should be

  | n, k + 1 => plusRinbook (n + 1) k 

Full error text:

▶ 8:5-8:14: error:
fail to show termination for
  Nat.plusR
with errors
failed to infer structural recursion:
Cannot use parameter #1:
  failed to eliminate recursive application
    n.plusR (k + 1)
Cannot use parameter #2:
  failed to eliminate recursive application
    n.plusR (k + 1)

Could not find a decreasing measure.
The arguments relate at each recursive call as follows:
(<, ≤, =: relation proved, ? all proofs failed, _: no proof attempted)
            x1 x2
1) 10:16-31  =  =
Please use `termination_by` to specify a decreasing measure.
Dominant language
Lean
Stars
211
Forks
83
Avg merge
8m
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from leanprover/fp-lean

All issues in leanprover/fp-lean

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.