-
Notifications
You must be signed in to change notification settings - Fork 454
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
Proving length of large array by rfl hangs #5502
Comments
Using example : MyVector Nat 33 :=
⟨#[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1], by rfl⟩ |
Some more context for open Lean Meta Elab Command Term
elab tk:"check_defeq " ker?:(&"kernel ")? synth?:(&"synth ")? a:term " =?= " b:term : command => liftTermElabM do
let mut x ← elabTerm a none
let mut y ← elabTerm b none
if synth?.isSome then
synthesizeSyntheticMVarsUsingDefault
x ← instantiateMVars x
y ← instantiateMVars y
let success ←
if ker?.isSome then
ofExceptKernelException (Kernel.isDefEq (← getEnv) {} x y)
else
isDefEq x y
if success then
logInfoAt tk "defeq"
else
logErrorAt tk "not defeq"
check_defeq kernel synth #[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1].size =?= (33 : Nat)
-- defeq
check_defeq synth #[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1].size =?= (33 : Nat)
-- defeq
check_defeq #[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1].size =?= (33 : Nat)
-- error: timeout Interestingly, the following succeeds -- works
notation "z" => Nat.zero
check_defeq #[z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z].size =?= (33 : Nat) This works for the MyVector case as well -- works
notation "z" => Nat.zero
example : MyVector Nat 33 :=
⟨#[z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z], rfl⟩ But, strangely, using a local variable instead of this notation causes a timeout, so it's not just a matter of somehow avoiding OfNat instance problems. -- times out
example (n : Nat) : MyVector Nat 33 :=
⟨#[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n], rfl⟩ |
Both of my code snippets seem to work on the latest master, so closing. |
Prerequisites
Please put an X between the brackets as you perform the following steps:
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
The following snippet summarizes the issue:
Context
This is affecting batteries, as the
v#
notation doesn't work with vectors of length 33 or above. See Zulip.Steps to Reproduce
Expected behavior: The code typechecks with no issues
Actual behavior: The code hangs indefinitely
Versions
4.12.0-rc1
Additional Information
by simp
works just fine in these proofs.There's a seemingly related issue I've found relating to this code snippet:
Adding one more instance of
l[0]
makes this typecheck noticeably slower. In my production code wherel
was some more complicated list, adding this extra entry made Lean eat all of my remaining 5GB of RAM (whereas it was running on only 1GB beforehand)Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: