clock-dbm 0.1.0

Difference bound matrices (DBMs) over packed i32 bounds for timed-automata zones
Documentation

clock-dbm

License: Apache-2.0 OR MIT

clock-dbm is a Rust library for representing zones of timed automata using canonical difference-bound matrices (DBMs). Clock values are nonnegative real numbers; constraints use strict or non-strict integer bounds stored in packed i32 entries.

The library provides canonical zone construction, constraints and batch constraints, time elapse, reset, free, intersection, inclusion, maximal-constant extrapolation (ExtraM), and copy-on-write shared zones.

The core DBM operations are formally verified using Creusot against their specified zone semantics. See verification status for the exact coverage and trusted assumptions.

Quick start

The constraint! macro writes clock guards in the usual notation: single-clock bounds such as x >= 2 and clock differences such as y - x < 3.

use clock_dbm::{constraint, Clock, Dbm, SharedDbm, Workspace};

fn main() -> Result<(), clock_dbm::Error> {
    let x = Clock::new(1).unwrap();
    let y = Clock::new(2).unwrap();
    let mut ws = Workspace::new();

    // 2 <= x <= 10 and y - x < 3
    let zone = Dbm::try_from_constraints(2, &[
        constraint!(x >= 2)?,
        constraint!(x <= 10)?,
        constraint!(y - x < 3)?,
    ], &mut ws)?;

    let saved = SharedDbm::from(zone);
    let smaller = saved.clone().try_constrain(constraint!(x < 4)?)?;
    assert!(smaller.is_subset_of(&saved)?);
    Ok(())
}

A successful operation always returns a canonical or empty zone. Inconsistent constraints return Ok with an empty zone, not an error. Error::Range means exact finite arithmetic encountered an unrepresentable bound; it must not be treated as emptiness.

Documentation

The generated Rustdoc contains the complete public API reference, including mathematical meaning, errors, complexity, and usage examples:

cargo doc --no-deps --open

For developers and verification researchers, further technical documents are included in Rustdoc and maintained as Markdown in the repository:

The copy-on-write layer is checked relative to documented trusted specifications of selected Rc operations; hashing is not machine-checked. See the proof-status reference for the precise verified subset.

Build and test

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test --all-targets
cargo test --doc
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps

The Rust toolchain configuration is in rust-toolchain.toml, and the minimum supported Rust version is declared in Cargo.toml. Verification uses the separately pinned environment documented under verification/.

Development

This project has been developed with assistance from AI coding agents, including Claude Code and OpenAI Codex. The project maintainer remains responsible for the design, implementation, and maintenance of the software.

The implementation builds on established DBM algorithms described by, for example, Bengtsson and Yi (2004). Its mathematical specifications are informed by the Isabelle AFP formalization of difference-bound matrices, associated with Wimmer and Lammich (2018). UDBM was consulted as a design and performance reference, particularly for packed-bound representations and efficient incremental closure.

Another Creusot-based verification of DBM operations is VerifiedDBM, which focuses on a simplified DBM representation and selected operations.

License

Licensed under either the Apache License, Version 2.0 or the MIT license, at your option.