Draft — mutable and not usable as a dependency; its citation marks the draft state.

Lax489179.Algorithms

Deterministic and bounded-error algorithms

concepts/Lax489179/Algorithms.lean · lax-489179

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.

    Concept map

    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Definition

    We distinguish deterministic algorithms from randomized algorithms with two-sided error at most 1/31/3 and a worst-case running-time bound. For a computation of at most tt steps, all 2t2^t strings of independent fair bits are equally likely. Every string must lead to termination; at least two thirds must give a correct answer. Unused bits are ignored.

    Both machine models below have finite programs. In deterministic mode the program cannot use randomness. The hypotheses themselves are propositions, available as explicit premises in later theorems.

    Lean source view on GitHub

    1import Mathlib.SetTheory.Cardinal.Finite
    2import Mathlib.Data.Fintype.Pi
    3
    4/-!
    5---
    6title: Deterministic and bounded-error algorithms
    7type: definition
    8---
    9We distinguish deterministic algorithms from randomized algorithms with
    10two-sided error at most 1/31/3 and a worst-case running-time bound.
    11For a computation of at most tt steps, all 2t2^t strings of independent
    12fair bits are equally likely. Every string must lead to termination;
    13at least two thirds must give a correct answer. Unused bits are ignored.
    14
    15Both machine models below have finite programs. In deterministic mode
    16the program cannot use randomness. The hypotheses themselves are
    17propositions, available as explicit premises in later theorems.
    18-/
    19
    20namespace Lax489179.Algorithms
    21
    22inductive Mode
    23 | deterministic
    24 | randomized
    25 deriving DecidableEq
    26
    27/-- Deterministic mode restricts the program; randomized mode allows it. -/
    28def Allowed (mode : Mode) (isDeterministic : Prop) : Prop :=
    29 mode = .deterministic → isDeterministic
    30
    31/-- Every random tape terminates, and at least two thirds return a
    32correct result. `none` means that the computation has not terminated. -/
    33def CorrectWithin {α : Type} (t : ℕ)
    34 (result : (Fin t → Bool) → Option α) (correct : α → Prop) : Prop :=
    35 (∀ r, (result r).isSome = true) ∧
    36 2 * 2 ^ t ≤ 3 * Nat.card {r : Fin t → Bool //
    37 ∃ y, result r = some y ∧ correct y}
    38
    39end Lax489179.Algorithms
    40

    Community review

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.

    0 comments

    Loading discussion…