AFTD Auto-Formalizing Theoretical Domains

Online.OnlineAlgorithm.run

defimported Lean

Drive the machine across the requests, halting at the first step that emits an output. When the genuine requests are exhausted without a commitment, the machine is given the end-of-input step step _ none — its last chance to decide, since it never knew which request was last — and its (state, output) pair *is* the result. So (run s rs).1 is the terminal state and (run s rs).2 is the decision.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
variable {α σ β : Type*} in
def Online.OnlineAlgorithm.run (alg : OnlineAlgorithm α σ β) : σ → List α → σ × Option β
Defined in
EconCSLib, `Online.OnlineAlgorithm.run`
Lean proof
By Claude (from the file's git history), from github.com/gametheoryinlean/EconCSLib at 1a88f809b538 (Copyright (c) 2026 EconCSLib contributors. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.30.0.
Verified
08 Oct 2026
Axioms
none listed
Built on 1
  • Online.OnlineAlgorithmA deterministic online algorithm as a state machine. The state State summarises the relevant past; step consumes the current state and…
Used by 6

Lean source view module on GitHub

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
variable {α σ β : Type*} in
/-- Drive the machine across the requests, halting at the **first** step that emits an output. When the genuine requests are exhausted without a commitment, the machine is given the **end-of-input** step `step _ none` — its last chance to decide, since it never knew which request was last — and its `(state, output)` pair *is* the result. So `(run s rs).1` is the terminal state and `(run s rs).2` is the decision. -/
def Online.OnlineAlgorithm.run (alg : OnlineAlgorithm α σ β) : σ → List α → σ × Option β
  | s, []      => alg.step s none
  | s, r :: rs =>
      match alg.step s (some r) with
      | (s', some o) => (s', some o)
      | (s', none)   => alg.run s' rs
See it in the graphDiscuss this resultChallenge it