Skip to content

Add Std.Queue (キュー) introduction#2322

Merged
Seasawher merged 8 commits into
mainfrom
copilot/introduce-std-queue
May 26, 2026
Merged

Add Std.Queue (キュー) introduction#2322
Seasawher merged 8 commits into
mainfrom
copilot/introduce-std-queue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Introduces Std.Queue, a persistent functional FIFO queue backed by two Lists, as a new entry in the Type section.

Changes

  • LeanByExample/Type/Queue.lean — New file covering:

    • Internal structure (eList/dList and the invariant dList ++ eList.reverse)
    • Basic ops: isEmpty, enqueue, dequeue? with #guard_msgs-verified outputs
    • Dot-notation gotcha for enqueue (argument order)
    • do-notation chaining via popTwo example
    • Complexity notes (O(1) enqueue, amortized O(1) dequeue)
    • BFS on a binary tree as a canonical use case
  • booksrc/SUMMARY.md — Added Queue: キュー entry between Prop and Quotient

-- dequeue? chains naturally with do-notation
def popTwo : Option (Nat × Nat) := do
  let q := ((∅ : Queue Nat).enqueue 10).enqueue 20
  let (x, q) ← q.dequeue?
  let (y, _) ← q.dequeue?
  return (x, y)
-- some (10, 20)

Copilot AI linked an issue May 19, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Introduce Std.Queue with basic operations Add Std.Queue (キュー) introduction May 19, 2026
Copilot AI requested a review from Seasawher May 19, 2026 04:25
@Seasawher Seasawher marked this pull request as ready for review May 26, 2026 15:56
@Seasawher Seasawher merged commit e6f18c0 into main May 26, 2026
3 checks passed
@Seasawher Seasawher deleted the copilot/introduce-std-queue branch May 26, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Std.Queue (キュー) を紹介する

2 participants