While this submission is a draft, it cannot be used by other submissions.

Persistent queues — definitions

Lax755887.PersistentQueue · concepts/Lax755887/PersistentQueue.lean · lax-755887

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    Repeated calls may reuse one queue and spend its potential more than once. The telescoping contract deliberately omits compatibility of adjacent potentials.

    Concept map
    1 concept; 3 descendants hidden
    100%
    Proven claimOpen claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Mathlib
    2
    3/-!
    4---
    5title: Persistent queues — definitions
    6type: definition
    7---
    8Repeated calls may reuse one queue and spend its potential more than once. The telescoping contract deliberately omits compatibility of adjacent potentials.
    9-/
    10
    11namespace Lax755887.PersistentQueue
    12
    13structure Charge where
    14 work : ℕ
    15 before : ℕ
    16 after : ℕ
    17
    18def amortized (s : Charge) : ℤ := s.work + s.after - s.before
    19
    20def totalWork (trace : List Charge) : ℕ := (trace.map Charge.work).sum
    21
    22def dequeue (n : ℕ) : Charge := ⟨n + 1, n, 0⟩
    23
    24end Lax755887.PersistentQueue
    25

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…