lean4-htt/tests/bench/cbv/dedup.lean
Wojciech Różowski d2176cb5fb
test: add tests and benchmarks for cbv tactic (#12345)
This PR adds two benchmarks (sieve of Eratosthenes, removing duplicates
from the list) and one test (a function with sublinear complexity
defined via well-founded recursion evaluated on large naturals with up
to `60` digits).

The tests have been suggested by @b-mehta.
2026-02-06 11:41:03 +00:00

16 lines
393 B
Text

import Std
set_option cbv.warning false
def dedup (l : List Nat) : List Nat := Id.run do
let mut S : Std.TreeSet Nat := ∅
for i in l do
S := S.insert i
return S.toList
example : dedup [1] = [1] := by conv => lhs; cbv
example : dedup [1,2] = [1,2] := by conv => lhs; cbv
example : dedup [1,1] = [1] := by conv => lhs; cbv
example : dedup [1,2,2] = [1,2] := by conv => lhs; cbv