ReductionBounds
reduction_bounds is an experimental Elixir library for deriving symbolic
cost bounds for supported Erlang and Elixir functions and checking them
in Lean. Relating those bounds to reductions charged by a concrete BEAM
runtime remains separate work.
Installation
Use a Mix project with Elixir 1.20 or later in the 1.x series and a
compatible Erlang/OTP version. Install Elan,
Lean's toolchain manager, and ensure lean and lake are on PATH.
Add the Hex package to deps/0 in your project's mix.exs:
{:reduction_bounds, "~> 0.1.0"}
From your project's root, fetch dependencies and install the exact Lean toolchain required by the resolved Lynx package:
mix deps.get
export ELAN_TOOLCHAIN="$(cat deps/lynx/lean-toolchain)"
elan toolchain install "$ELAN_TOOLCHAIN"
lean --version
lake --version
mix compile
Set ELAN_TOOLCHAIN from that file in each shell used for building or
proof checking, unless your project has a matching lean-toolchain file.
See toolchain maintenance for Elan and Lynx updates
and instructions for working in this repository.
Verify proofs from within the consuming Mix project. See toolchain compatibility for the release check configuration. The 0.1 series is experimental, and future minor releases may change APIs and proof models.
Getting started and Case Studies
Follow Getting Started to install the toolchain, check your first bound, and read the result's proof scope.
The Case Studies provide compiled-source and IEx routes for constants, branches, recursion, list traversal and conditional reversal, integer sizes and contract reuse, CRC/variance kernels, maps, periodic rules, ring buffers, Port and RPC workflows. The examples index links to detailed API guides.
The proof reference explains the checked theorems, assumptions, and reproduction commands. Future directions are in the roadmap.
Limitations
- Analysis requires Core Erlang recoverable from BEAM debug information. Stripped binaries and unsupported source constructs are outside the current scope.
- Target modules normally need readable
.beamfiles on the code path. For modules compiled in IEx or withCode.compile_string/1, retain and pass their binaries usingbeam_binaries, including dependencies that exist only in memory. - Paths that use Lynx translation are subject to its supported constructs
and dependency-cycle checks. Translating
Enum.map/2can encounter a cyclic module dependency even when intended inputs are lists. See the verification guide. - A successful result applies to its mathematical model under the reported
input and callee conditions. Contract labels such as
:jitdo not prove runtime applicability. Concrete reduction accounting, wall-clock timing, and scheduling guarantees require separate evidence.
License
Copyright 2026 University of Kitakyushu.
Licensed under the Apache License, Version 2.0. See LICENSE.md.