CrossCheck I: Cost Bounds of Imperative Programs as Constrained Optimization, with a Sound Cost Logic and a Verified Certificate Checker

Static analysis of imperative programs often relies on iterative fixed-point approximations or concrete path exploration. We show that structured imperative control flow—while loops, linear recursion and branching recursion—can be mapped into constrained optimization problems over the free monoid of execution traces and the free algebra of computation trees. Ordering traces and trees by an intensional order-by-composition (⊑), halting is characterized as finding the minimal trace or tree that satisfies the exit condition, and we prove that this characterization coincides with the standard big-step semantics. Exact state recurrences are undecidable in general, so we relax them into cost envelopes, using ranking potentials and the tropical (max, +) reading of the timing schema, and obtain sound upper bounds on execution cost. The bounds compose over whole programs in a cost logic for a small language with nondeterministic actions, procedures, recursion and assumed contracts, which we prove sound for terminating and non-terminating executions. A linear instance of the logic has certificates—programs annotated with invariants, potentials and Farkas multipliers—and a checker that validates them with integer arithmetic only; an accepted certificate bounds the cost of every execution. All results, the checker and the worked examples are machine-checked in Lean 4. A companion paper describes a Clang plugin that produces such certificates and its evaluation.Lean 4 formalization and tools: https://doi.org/10.5281/zenodo.24425069. Companion paper (CrossCheck II): https://doi.org/10.5281/zenodo.24444646.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-11-22
DOI
https://doi.org/10.5281/zenodo.24444575
Citations
1
Primary Topic
Logic, programming, and type systems
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

CrossCheck I: Cost Bounds of Imperative Programs as Constrained Optimization, with a Sound Cost Logic and a Verified Certificate Checker

L Dall'Olio
1 citations
Zenodo (CERN European Organization for Nuclear Research)
Logic, programming, and type systems
preprint

CrossCheck I: Cost Bounds of Imperative Programs as Constrained Optimization, with a Sound Cost Logic and a Verified Certificate Checker

L Dall'Olio
preprint en
1 citations

Abstract

Static analysis of imperative programs often relies on iterative fixed-point approximations or concrete path exploration. We show that structured imperative control flow—while loops, linear recursion and branching recursion—can be mapped into constrained optimization problems over the free monoid of execution traces and the free algebra of computation trees. Ordering traces and trees by an intensional order-by-composition (⊑), halting is characterized as finding the minimal trace or tree that satisfies the exit condition, and we prove that this characterization coincides with the standard big-step semantics. Exact state recurrences are undecidable in general, so we relax them into cost envelopes, using ranking potentials and the tropical (max, +) reading of the timing schema, and obtain sound upper bounds on execution cost. The bounds compose over whole programs in a cost logic for a small language with nondeterministic actions, procedures, recursion and assumed contracts, which we prove sound for terminating and non-terminating executions. A linear instance of the logic has certificates—programs annotated with invariants, potentials and Farkas multipliers—and a checker that validates them with integer arithmetic only; an accepted certificate bounds the cost of every execution. All results, the checker and the worked examples are machine-checked in Lean 4. A companion paper describes a Clang plugin that produces such certificates and its evaluation.Lean 4 formalization and tools: https://doi.org/10.5281/zenodo.24425069. Companion paper (CrossCheck II): https://doi.org/10.5281/zenodo.24444646.

Zenodo (CERN European Organization for Nuclear Research)
Logic, programming, and type systems
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon