Skip to main content

manual_proof

Macro manual_proof 

Source
macro_rules! manual_proof {
    ($(#[doc = $doc:expr])+hook = $hook:expr $(,)?) => { ... };
    ($(#[doc = $doc:expr])+) => { ... };
}
Expand description

Fulfills a proof parameter by declaring a human-written justification for why the algebraic property (e.g. commutativity, idempotence) holds.

The argument must be a doc comment explaining why the property is satisfied.

ยงExamples

// stream: [1, 2, 3] (unordered)
stream
    .fold(
        q!(|| 0),
        q!(
            |acc, x| *acc += x,
            commutative = manual_proof!(/** integer addition is commutative */)
        ),
    )
    .into_stream()

An optional trailing hook = ... argument attaches a simulator ordering hook to a commutativity proof (see hydro_lang::sim::hooks). The simulator does not trust manual proofs โ€” it still explores the input ordering โ€” so the hook lets a simulation test script that exploration:

โ“˜
commutative = manual_proof!(/** set insert is commutative */ hook = my_ordering_hook)