Skip to content
This repository was archived by the owner on Oct 14, 2023. It is now read-only.
This repository was archived by the owner on Oct 14, 2023. It is now read-only.

simp fails to handle recursors #2004

Description

@JasonGross

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

@[simp]
def fact (n : ℕ) : ℕ :=
  nat.rec
    1
    (λ n' fact_n', (nat.succ n') * fact_n')
    n

example : fact 5 = 5 :=
begin
  simp [fact,has_mul.mul,nat.mul],
  simp [nat.rec]
-- 11:3: invalid simplification lemma 'nat.rec' (use command 'set_option trace.simp_lemmas true' for more details)
-- state:
-- ⊢ nat.rec 1 (λ (n' : ℕ), nat.mul (nat.succ n')) 5 = 5
end

If I remove [nat.rec], then instead I get the error:

11:3: simplify tactic failed to simplify
state:
⊢ nat.rec 1 (λ (n' : ℕ), nat.mul (nat.succ n')) 5 = 5

How am I supposed to simplify recursion?

Expected behavior: simp reduces things like nat.rec, int.rec, list.rec, etc

Actual behavior: simp does not reduce these things

Reproduces how often: [What percentage of the time does it reproduce?] 100%

Versions

$ lean --version
Lean (version 3.4.2, commit cbd2b6686ddb, Release)
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.6 LTS
Release:        16.04
Codename:       xenial
$ uname -a
Linux jgross-Leopard-WS 4.4.0-161-generic #189-Ubuntu SMP Tue Aug 27 08:10:16 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions