Jude: SMT Formal Mathematical Verification
Eliminate runtime assertion overhead by mathematically proving system invariants at compile-time. Embed first-order logic pre/post-condition contracts discharged by Z3 and CVC5 SMT solvers.
.jude
•
Compiler Flag: nyxc --verify
•
SMT Backends: Z3 • CVC5
•
Runtime Overhead: 0.00 ns (Erased at Compile Time)
1. The Power of Jude
In safety-critical systems (flight control, medical firmware, banking transaction settling, and defense infrastructure), runtime checks (e.g. assert() or panics) happen too late.
Jude proves correctness before the binary is even compiled:
The compiler converts your @verify contract into SMT-LIB2 queries, invokes the Z3/CVC5 solver, and emits a cryptographically signed .jude.cert audit file. If the proof cannot be discharged, compilation halts with a counter-example trace.
2. Syntax & Verification Contracts
In Jude, functions declare mathematical pre-conditions (requires) and post-conditions (ensures):
// file: flight_control.jude
// Compile with: nyxc --verify flight_control.jude -o flight.exe
@verify(
requires: pitch_rate >= -45.0 && pitch_rate <= 45.0 && delta_time > 0.0,
ensures: result.elevator_angle >= -30.0 && result.elevator_angle <= 30.0
)
pub fn calculate_elevator(pitch_rate: f64, delta_time: f64) -> ActuatorCommand {
let desired_trim = pitch_rate * delta_time * 0.85;
let clamped_angle = clamp(desired_trim, -30.0, 30.0);
ActuatorCommand { elevator_angle: clamped_angle }
}
3. Cryptographic Proof Certificates (.jude.cert)
Every successful verification pass outputs a reproducible audit certificate:
[SMT-SOLVER] Z3 v4.12.2 • 0 counter-examples.
[CERTIFICATE] Emitted:
flight_control.jude.cert (SHA-256: 8f4a9b2c3d4e5f6...)
4. Concrete Industrial Use Cases
Use Case 1: DO-178C Level-A Aerospace Autothrottle Safety Governor
Commercial aircraft engines require rigorous proof that digital engine controllers (FADEC) never command thrust exceeding structural limits or dropping below aerodynamic stall thresholds:
import avionics.safety;
struct EngineState {
n1_rpm_percent: f64,
altitude_feet: f64,
airspeed_knots: f64,
}
@verify(
requires: state.airspeed_knots >= 80.0 && state.altitude_feet <= 45000.0,
ensures: result.thrust_percentage >= 15.0 && result.thrust_percentage <= 100.0
)
pub fn compute_autothrottle_demand(state: EngineState, pilot_command: f64) -> ThrottleDemand {
let unconstrained = pilot_command * 1.05;
// Provably clamped within aerodynamic envelope
let safe_thrust = if unconstrained < 15.0 {
15.0 // Anti-stall minimum flight idle
} else if unconstrained > 100.0 {
100.0 // Maximum takeoff thrust limit
} else {
unconstrained
};
ThrottleDemand { thrust_percentage: safe_thrust }
}
Use Case 2: ISO 26262 ASIL-D Automotive Brake-by-Wire Deceleration Governor
Electric vehicle regenerative braking must never exceed road-tire friction limits ($\mu \cdot g$) to prevent unrecoverable skids:
import automotive.safety;
@verify(
requires: wheel_speed >= 0.0 && mu_friction >= 0.1 && mu_friction <= 1.2,
ensures: result.braking_force_newtons <= (mu_friction * 9.81 * vehicle_mass_kg)
)
pub fn compute_anti_skid_braking(
requested_force: f64,
wheel_speed: f64,
mu_friction: f64,
vehicle_mass_kg: f64
) -> BrakeActuatorCommand {
let max_friction_force = mu_friction * 9.81 * vehicle_mass_kg;
let safe_force = if requested_force > max_friction_force {
max_friction_force
} else {
requested_force
};
BrakeActuatorCommand { braking_force_newtons: safe_force }
}
Use Case 3: DeFi & RTGS Banking Zero-Overflow Invariant Ledger
Financial settlement engines must mathematically guarantee non-negative balances and strict conservation of funds across multi-party debits and credits:
import fintech.ledger;
struct Account {
balance_kobo: u64,
}
@verify(
requires: sender.balance_kobo >= amount_kobo && amount_kobo > 0,
ensures: result.sender.balance_kobo == sender.balance_kobo - amount_kobo &&
result.receiver.balance_kobo == receiver.balance_kobo + amount_kobo
)
pub fn execute_atomic_transfer(
mut sender: Account,
mut receiver: Account,
amount_kobo: u64
) -> TransferResult {
sender.balance_kobo -= amount_kobo;
receiver.balance_kobo += amount_kobo;
TransferResult { sender, receiver }
}
Use Case 4: Medical Infusion Pump Continuous Dosage Rate Prover
Intravenous drug pumps must satisfy absolute dosage bounds to prevent toxic overdoses regardless of UI input glitches:
import medical.device;
@verify(
requires: patient_weight_kg >= 2.0 && patient_weight_kg <= 250.0 && input_rate_ml_hr >= 0.0,
ensures: result.dispense_rate_ml_hr <= (patient_weight_kg * 0.5) // Safe upper toxicity ceiling
)
pub fn calculate_iv_infusion_rate(patient_weight_kg: f64, input_rate_ml_hr: f64) -> PumpCommand {
let max_safe_rate = patient_weight_kg * 0.5;
let actual_rate = if input_rate_ml_hr > max_safe_rate {
max_safe_rate
} else {
input_rate_ml_hr
};
PumpCommand { dispense_rate_ml_hr: actual_rate }
}