A next-gen functional language
Go to file
2024-07-05 13:00:18 -03:00
book auto fix files - sonnet 2024-07-05 13:00:18 -03:00
docs fix typo in equality docs 2024-04-18 11:21:37 -03:00
formal fix equalSimilar not following described algo 2024-03-14 10:31:04 -03:00
src auto fix files - sonnet 2024-07-05 13:00:18 -03:00
.gitignore U60 to U48, use let to make match expr, WIPs 2024-07-05 10:06:49 -03:00
build.rs use compiled GHC checker only 2024-06-22 23:11:07 -03:00
Cargo.lock use compiled GHC checker only 2024-06-22 23:11:07 -03:00
Cargo.toml use compiled GHC checker only 2024-06-22 23:11:07 -03:00
README.md U60 to U48, use let to make match expr, WIPs 2024-07-05 10:06:49 -03:00
SYNTAX.md initial syntax guide 2024-07-05 01:09:41 -03:00

Kind2: a parallel proof & programming language

Kind2 is a minimalist proof language based on Self types, a simple extension to the Calculus of Constructions that allows encoding inductive types without a complex, hardcoded datatype system. It compiles to Bend.

Usage

  1. Install Rust and (optionally) Haskell in your system.

  2. Clone this repository and install it:

    git clone https://github.com/HigherOrderCO/Kind2
    cargo install --path .
    
  3. Type-check a Kind2 definition:

    kind2 check name_here
    
  4. Test it with the interpreter:

    kind2 run name
    
  5. Compile and run in parallel, powered by HVM!

    kind2 compile name
    ./name
    

Examples

// The Fibonacci function
fib (n: U48) : U48 =
  switch n {
    0: 0
    1: 1
    _: (+ (fib (- n 1)) (fib (- n 2)))
  }

Datatypes (ADTs):

// Polymorphic Lists
data List T
| cons (head: T) (tail: (List T))
| nil

// Applies a function to all elements of a list
map <A> <B> (xs: (List A)) (f: A -> B) : (List B) =
  fold xs {
    ++: (f xs.head) ++ xs.tail
    []: []
  }

Theorems and Proofs:

use Nat/{succ,zero,half,double}

// Proof that `∀n. n*2/2 = n`
bft (n: Nat) : (half (double n)) == n =
  match n {
    succ: (Equal/apply succ (bft n.pred))
    zero: {=}
  }

More Examples:

There are countless examples on the Book/ directory.