SHEET-003 // dbc

Design by Contract Start — Preconditions & Postconditions

Foundational Design-by-Contract cheat sheet pairing YAML/TOML invariants with pure-Rust falsifiable assertions and boundary checks.

Design by Contract Start — Preconditions & Postconditions cheat sheet preview
Verified CLI Version
pv 0.76.0 (9db57b24f) (aprender provable-contracts verifier)
Receipt SHA-256
39aa31d4a4c796e2925fe7c96d81a64d15673fc14ae92a2e7255481df22a570d

Verified Companion Code

pub fn bounded_ratio(num: f64, den: f64) -> Result<f64, &'static str> {
    if den <= 0.0 { return Err("precondition: den > 0"); }
    let out = num / den;
    if !out.is_finite() { return Err("postcondition: finite"); }
    Ok(out)
}

sheet.contract.toml

[sheet]
id = "SHEET-003"
topic = "dbc-start"
invariants = ["precondition-checked", "postcondition-checked", "zero-panics"]

Verified Output & SHA-256 Receipt

$ pv validate sheets/dbc-start/contract.yaml --test
pv: SHEET-003 CONFORMS (precondition + postcondition invariants verified)