lean4-htt/tests/lean/run/grind_canon_bug_2.lean
Leonardo de Moura d898c9ed17
fix: grind canonicalizer (#10469)
This PR fixes an incorrect optimization in the `grind` canonicalizer.
See the new test for an example that exposes the problem.
2025-09-20 01:24:54 +00:00

21 lines
749 B
Text

import Std.Data.ExtHashMap
open Std
set_option warn.sorry false
-- The following trace should contain only one `m[k]` and `(m.insert 1 3)[k]`
/--
trace: [grind.cutsat.model] k := 101
[grind.cutsat.model] (ExtHashMap.filter (fun k x => decide (101 ≤ k)) (m.insert 1 3))[k] := 4
[grind.cutsat.model] (m.insert 1 2)[k] := 4
[grind.cutsat.model] (m.insert 1 3)[k] := 4
[grind.cutsat.model] m[k] := 4
[grind.cutsat.model] (m.insert 1 2).getKey k ⋯ := 101
[grind.cutsat.model] m.getKey k ⋯ := 101
-/
#guard_msgs in
example (m : ExtHashMap Nat Nat) :
(m.insert 1 2).filter (fun k _ => k > 1000) = (m.insert 1 3).filter fun k _ => k > 100 := by
ext1 k
set_option trace.grind.cutsat.model true in
fail_if_success grind (splits := 4)
sorry