slow typeclass synthesis: takes 19000 heartbeats to fail on `AddMonoidHomClass (AddGroupSeminorm ℂ) ℂ ℝ`
semorrison opened this issue · comments
Kim Morrison commented
import Mathlib
open Complex Filter Bornology
/--
error: failed to synthesize
AddMonoidHomClass (AddGroupSeminorm ℂ) ℂ ℝ
(deterministic) timeout at 'typeclass', maximum number of heartbeats (19000) has been reached (use 'set_option synthInstance.maxHeartbeats <num>' to set the limit)
-/
#guard_msgs in
set_option synthInstance.maxHeartbeats 19000 in
#synth AddMonoidHomClass (AddGroupSeminorm ℂ) ℂ ℝ
-- This then results in a near failure (or failure on nightly-testing) of the simpNF linter on
-- `Complex.comap_exp_cobounded` and `Complex.map_exp_comap_re_atTop`:
/--
error: failed to synthesize
AddMonoidHomClass (AddGroupSeminorm ℂ) ℂ ℝ
(deterministic) timeout at 'typeclass', maximum number of heartbeats (19000) has been reached (use 'set_option synthInstance.maxHeartbeats <num>' to set the limit)
-/
#guard_msgs in
set_option synthInstance.maxHeartbeats 19000 in
example : comap exp (cobounded ℂ) = comap re atTop := by simp
Output of
set_option trace.Meta.synthInstance true in
#synth AddMonoidHomClass (AddGroupSeminorm ℂ) ℂ ℝ
Matthew Robert Ballard commented
Also fixed by leanprover/lean4#4085
Johan Commelin commented
I confirm that this is fixed:
import Mathlib
/-!
# Test against slow typeclass synthesis
This file tests against regression in typeclass synthesis speed.
See https://github.com/leanprover-community/mathlib4/issues/12226
for the initial issue, that was fixed by
https://github.com/leanprover/lean4/pull/4085
-/
open Complex Filter Bornology
/--
error: failed to synthesize
AddMonoidHomClass (AddGroupSeminorm ℂ) ℂ ℝ
-/
#guard_msgs in
set_option synthInstance.maxHeartbeats 3000 in
#synth AddMonoidHomClass (AddGroupSeminorm ℂ) ℂ ℝ
-- This then results in a near failure (or failure on nightly-testing) of the simpNF linter on
-- `Complex.comap_exp_cobounded` and `Complex.map_exp_comap_re_atTop`:
set_option synthInstance.maxHeartbeats 3000 in
example : comap exp (cobounded ℂ) = comap re atTop := by simp