Silk

Systems language with formal verification built in.

Write native tools and libraries with practical modules, typed failures, and contracts the compiler checks.

A checked withdrawal
Walkthrough

Formal Silk proves the numeric contract at compile time. Parse CLI input and validate it before this call.

#require balance >= 0;
#require amount >= 0 && amount <= balance;
#assure result == balance - amount;
#assure result >= 0;
fn withdraw (balance: int, amount: int) -> int {
  return balance - amount;
}

fn main () -> int {
  let remaining = withdraw(100, 30);
  #assert remaining == 70;
  return 0;
}

Quick links

Type to search across the site. Use the up and down arrow keys to choose a result, Enter to open it, and Escape to close.