mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-08-16 22:50:26 +03:00
A next-gen functional language
dependent-typesformalityfunctional-programminglambda-calculusmoonadproof-languageproof-languagesstarred-higherorderco-repostarred-repotheorem-provertype-theory
book | ||
docs | ||
formal | ||
src | ||
.gitignore | ||
build.rs | ||
Cargo.lock | ||
Cargo.toml | ||
README.md | ||
SYNTAX.md |
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
-
Clone this repository and install it:
git clone https://github.com/HigherOrderCO/Kind2 cargo install --path .
-
Type-check a Kind2 definition:
kind2 check name_here
-
Test it with the interpreter:
kind2 run name
-
Compile and run in parallel, powered by HVM!
kind2 compile name ./name
Examples
// The Fibonacci function
fib (n: U60) : U60 =
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.