You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reduced the issue to a self-contained, reproducible test case.
Description
simp sometimes generates a proof that doesn't typecheck
Steps to Reproduce
prelude-- optionalimport Init.WF
import Init.WFTactics
import Init.Data.Nat.Basic
namespace Nat
protecteddefmodCore (y : Nat) : Nat → Nat → Nat
| Nat.zero, x => x
| Nat.succ fuel, x => if0 < y ∧ y ≤ x then Nat.modCore y fuel (x - y) else x
protecteddefmod' (x y : @& Nat) : Nat :=
Nat.modCore y x x
@[simp]theoremzero_mod' (b : Nat) : Nat.mod' 0 b = 0 := rfl
end Nat
namespace Nat
privatedefgcdF' (x : Nat) : (∀ x₁, x₁ < x → Nat → Nat) → Nat → Nat :=
match x with
| 0 => fun _ y => y
| succ x => fun f y => f (Nat.mod' y (succ x)) sorry (succ x)
noncomputabledefgcd' (a b : Nat) : Nat :=
WellFounded.fix (measure id).wf gcdF' a b
@[simp]theoremgcd'_zero_left (y : Nat) : gcd' 0 y = y :=
rfl
theoremgcd'_succ (x y : Nat) : gcd' (succ x) y = gcd' (Nat.mod' y (succ x)) (succ x) :=
rfl -- replace with `id rfl` and everything is ok-- VVVVVVVVVVVVVVV error here@[simp]theoremgcd'_zero_right (n : Nat) : gcd' n 0 = n := by
cases n <;> simp [gcd'_succ]
end Nat
Expected behavior:simp should either succeed, or give a tactic failure
Actual behavior:simp succeeds, but the kernel rejects the proof with
application type mismatch
@Eq.ndrec Nat (succ n✝) (fun n => gcd' n 0 = n) (of_eq_true (eq_self (succ n✝)))
argument has type
succ n✝ = succ n✝
but function has type
(fun n => gcd' n 0 = n) (succ n✝) → ∀ {b : Nat}, succ n✝ = b → (fun n => gcd' n 0 = n) b
Any additional information, configuration or data that might be necessary to reproduce the issue.
The text was updated successfully, but these errors were encountered:
eric-wieser
changed the title
simp produces a term that doesn't typechecksimp produces a term that doesn't typecheck when used with WellFounded.fixJan 8, 2023
Prerequisites
Description
simp
sometimes generates a proof that doesn't typecheckSteps to Reproduce
Expected behavior:
simp
should either succeed, or give a tactic failureActual behavior:
simp
succeeds, but the kernel rejects the proof withReproduces how often: 100%
Versions
$ ~/.elan/bin/lean --version Lean (version 4.0.0-nightly-2023-01-08, commit 74b3d101e967, Release)
Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.
The text was updated successfully, but these errors were encountered: