Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

perf: refactor rejectDuplicates in Parser.lean to avoid redundant sort and O(n²) insertion

Open
#18 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale

Research direction

Start in Lck/Json/Parser.lean by reading SortedKVs.ofListWithPolicy, hasDuplicateKeysList, ofList, and ofListLastWins. Then inspect the existing structure in Syntax.lean and related proofs in Proofs.lean. Done means a fromSortedList helper enables one mergeSort pass for rejectDuplicates, firstWins, and lastWins while preserving the corresponding proofs and O(n log n) behavior.

Written by the indexing model from the issue text.

Description

Problem

SortedKVs.ofListWithPolicy .rejectDuplicates in Lck/Json/Parser.lean does two passes:

  1. hasDuplicateKeysList: sorts the list (mergeSort, O(n log n)) then scans adjacent pairs
  2. SortedKVs.ofList: builds the sorted structure via repeated insert (O(n) each → O(n²) total)

Total cost is O(n log n) + O(n²) = O(n²) with a hidden constant from sorting twice.

Suggested Fix

Add a SortedKVs.fromSortedList helper that builds the sorted structure from a pre-sorted list in O(n), then combine the duplicate check and structure construction into a single pass over the mergeSort output. This would bring the rejectDuplicates path to O(n log n) overall.

The same refactor would help firstWins and lastWins paths in ofList/ofListLastWins.

Complexity

Moderate: requires a new Syntax.lean helper and corresponding proof in Proofs.lean.

Dominant language
Lean
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lambdaclass/lambda_compiler_kit

All issues in lambdaclass/lambda_compiler_kit

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.