CertiK Prover
Login

CertiK Prover user guide

Quick reference

Every specification form this guide teaches, what it means, where you write it, and the chapter that explains it.

Writing specifications

FormMeaningWhereLearn more
//@ clause;One specification line. The space after //@ is required.Directly above what it describesBasics
/*@ clause; clause; @*/Several clauses in one comment block.Directly above what it describesBasics

Function clauses

FormMeaningWhereLearn more
requires P;A condition callers must guarantee. It is assumed while the function is checked and proved at every call.Above a functionYour first specification
ensures P;A condition that holds when the function returns successfully.Above a functionYour first specification
assignable x, m[k];The only storage the function may change; everything else stays the same.Above a functionYour first specification
reverts_when P;If P holds at the start, the call reverts.Above a functionYour first specification
reverts_only_when P;If the call reverts, P held at the start.Above a functionYour first specification
reverts_when_and_only_when P;The call reverts exactly when P holds at the start.Above a functionYour first specification
alsoStarts another case. Every case whose requires holds must be satisfied.Above a functionCases and modifiers
let (T x) = E;Captures a value once, before the cases start.Above a functionCases and modifiers

Inside conditions

FormMeaningWhereLearn more
\old(e)The value of e when the call started.Inside any conditionYour first specification
\resultThe value the function returns.In ensuresYour first specification
\nothingNo storage may change.In assignableYour first specification
P ==> QIf P holds, Q must hold.Inside any conditionLogic and quantifiers
P <==> QP and Q are both true or both false.Inside any conditionLogic and quantifiers
\forall (T x) PP holds for every value x of type T.Inside any conditionLogic and quantifiers
\exists (T x) PP holds for at least one value x of type T.Inside any conditionLogic and quantifiers
a + bExact integer arithmetic (mathint): it never overflows or wraps.Inside any conditionLogic and quantifiers
\sum_of(m)The sum of every numeric entry of a mapping or array; \sum_of(a[i:j]) sums a range.Inside any conditionContract-wide properties

Contract-wide properties

FormMeaningWhereLearn more
invariant P;Holds before and after every top-level transaction.In the contract bodyContract-wide properties
constraint P;Holds when a public or external call returns, comparing with its start through \old.In the contract bodyContract-wide properties
always P;Holds whenever any function starts or finishes.In the contract bodyContract-wide properties
\prev_tx(x)The value of x after the previous transaction.In an invariantContract-wide properties

Modifiers

FormMeaningWhereLearn more
establishes P;Holds just before _ runs the wrapped function.Above a modifierCases and modifiers
expects P;Holds just after the wrapped function returns to _.Above a modifierCases and modifiers

Loops

FormMeaningWhereLearn more
maintaining P;Holds before the first repetition and after every repetition.Above a loopLoops
assigning x, y;The only variables the loop may change. Required on every loop.Above a loopLoops
decreasing e;Shrinks on every repetition and never goes below zero, so the loop ends.Above a loopLoops

Commands

FormMeaningWhereLearn more
csol File.solChecks one entry file and every file it imports.TerminalQuick start
csol-projectChecks every entry listed in csol-project.yaml.TerminalQuick start
exit 0 · 1 · 2 · 3Passed · counterexample found · error · inconclusive.TerminalQuick start

Run the full examples

Every form on this page appears in a complete, verified example in the CertiK Prover Server Tutorial project, organized by chapter under user-guide/. Sign in to open it.