lambdaclass / lambdaclass/lambda_compiler_kit

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

オープン
#18 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Lean
スター
2
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Lck/Json/Parser.lean で SortedKVs.ofListWithPolicy、hasDuplicateKeysList、ofList、ofListLastWins を読んで始めます。次に、Syntax.lean にある既存の構造と、Proofs.lean にある関連する証明を調べます。rejectDuplicates、firstWins、lastWins に対して1回の mergeSort パスを可能にする fromSortedList ヘルパーが追加され、対応する証明と O(n log n) の動作が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

領域
compilers, performance
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。