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
universes u v w ℓ
axiomf : ℕ → ℕ
axiomg : ℕ → ℕ
@[simp]defcomp_pow {A : Type u} (f : A → A) : ℕ → A → A
| 0 x := x
| (nat.succ n) x := f (comp_pow n x)
@[simp]defgoal100 : Σ' P, P = (∀ x, comp_pow f 100 x = comp_pow g 100 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal200 : Σ' P, P = (∀ x, comp_pow f 200 x = comp_pow g 200 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal300 : Σ' P, P = (∀ x, comp_pow f 300 x = comp_pow g 300 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal400 : Σ' P, P = (∀ x, comp_pow f 400 x = comp_pow g 400 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal500 : Σ' P, P = (∀ x, comp_pow f 500 x = comp_pow g 500 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal600 : Σ' P, P = (∀ x, comp_pow f 600 x = comp_pow g 600 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal700 : Σ' P, P = (∀ x, comp_pow f 700 x = comp_pow g 700 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal800 : Σ' P, P = (∀ x, comp_pow f 800 x = comp_pow g 800 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal900 : Σ' P, P = (∀ x, comp_pow f 900 x = comp_pow g 900 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
@[simp]defgoal1000 : Σ' P, P = (∀ x, comp_pow f 1000 x = comp_pow g 1000 x) :=
by { eapply psigma.mk, simp only [comp_pow] }
running lean --profile (Lean (version 3.4.2, commit cbd2b66, Release)) on this gives the times
n
time (s)
100
0.033
200
0.055
300
0.081
400
0.115
500
0.153
600
0.193
700
0.251
800
0.356
900
0.358
1000
0.46
which is quadratic:
Steps to Reproduce
See above
Expected behavior: Linear performance of reduction
Actual behavior: Quadratic performance of reduction
I don't think this should be considered a bug. The term is traversed completely at every pass of simp and every pass meets only one opportunity for rewrite. I pointed out one way in leanprover-community/mathlib3#3500 (comment) to reduce the number of passes. Another possibility is to increase the number of opportunity to rewrite at each pass with lemmas of this shape
lemmacomp_pow_bit0 : comp_pow f (bit0 n) x = comp_pow f n (comp_pow f n x) := ...
The number of passes should be logarithmic and the amount of work should be roughly linear. That's no my favorite solution for this specific problem but it's something worth considering when speeding up your rewrites.
Here apply is called by relation_tactic following simplification. It successfully applies eq.refl, but in the process the proof term (which has quadratic tree size) will be traversed, and without sufficiently precise caching to avoid scaling in the tree size.
Prerequisites
or feature requests.
Description
running
lean --profile
(Lean (version 3.4.2, commit cbd2b66, Release)) on this gives the timeswhich is quadratic:
Steps to Reproduce
See above
Expected behavior: Linear performance of reduction
Actual behavior: Quadratic performance of reduction
Reproduces how often: 100% of the time
Versions
Lean (version 3.4.2, commit cbd2b66, Release)
Additional Information
The profile for the biggest example is
The text was updated successfully, but these errors were encountered: