Say what must be true.
Put preconditions, postconditions, and data invariants beside the code they describe. They become obligations the compiler checks.
Evergreen brings explicit contracts, checked invariants, and control over memory into one language. Write down what must hold. Let the compiler check that it does.
Try Evergreentype NonZero struct {data: usize} where data != 0;
impl NonZero {
fn new(x: usize) -> Self
where x != 0
{
return NonZero {data: x};
}
}
fn main() -> usize {
let my_nonzero = NonZero::new(10);
0
}
The constructor requires a nonzero input.
The compiler checks the invariant when the value is built.
The Core Idea
Put preconditions, postconditions, and data invariants beside the code they describe. They become obligations the compiler checks.
Work with explicit layouts, ownership, and borrowed references. Evergreen tracks when a memory plane is live and which uses remain valid.
Proofs and ideal computations are erased after checking. Executable code keeps the work it needs to do.
The real Evergreen compiler, compiled to WebAssembly. Edit an example, check its proofs, and run the resulting Wasm. Everything happens on your device.
Ready when you are. Run the example to see its output here.
External console behavior is provided by the host. Evergreen records this boundary as an explicit trustme assumption.