// Bool // ---- Bool : Type True : Bool False : Bool Bool.not (a: Bool) : Bool Bool.not True = False Bool.not False = True Bool.and (a: Bool) (b: Bool) : Bool Bool.and True True = True Bool.and True False = False Bool.and False True = False Bool.and False False = False Bool.not_not_theorem (a: Bool) : (Equal Bool a (Bool.not (Bool.not a))) Bool.not_not_theorem True = (Refl Bool True) Bool.not_not_theorem False = (Refl Bool False) // Nat // --- Nat : Type Zero : Nat Succ (pred: Nat) : Nat Nat.double (x: Nat) : Nat Nat.double (Succ x) = (Succ (Succ (Nat.double x))) Nat.double (Zero) = (Zero) Nat.add (a: Nat) (b: Nat) : Nat Nat.add (Succ a) b = (Succ (Nat.add a b)) Nat.add Zero b = b Nat.comm.a (a: Nat) : (Equal Nat a (Nat.add a Zero)) Nat.comm.a Zero = Refl Nat.comm.a (Succ a) = (Equal.apply @x(Succ x) (Nat.comm.a a)) Nat.comm.b (a: Nat) (b: Nat): (Equal Nat (Nat.add a (Succ b)) (Succ (Nat.add a b))) Nat.comm.b Zero b = Refl Nat.comm.b (Succ a) b = (Equal.apply @x(Succ x) (Nat.comm.b a b)) Nat.comm (a: Nat) (b: Nat) : (Equal Nat (Nat.add a b) (Nat.add b a)) Nat.comm Zero b = (Nat.comm.a b) Nat.comm (Succ a) b = let e0 = (Equal.apply @x(Succ x) (Nat.comm a b)) let e1 = (Equal.mirror (Nat.comm.b b a)) (Equal.chain e0 e1) Nat.to_u60 (n: Nat) : U60 Nat.to_u60 Zero = #0 Nat.to_u60 (Succ n) = (+ #1 (Nat.to_u60 n)) // List // ---- List (a: Type) : Type List.nil : (List a) List.cons (x: a) (xs: (List a)) : (List a) List.negate (xs: (List Bool)) : (List Bool) List.negate (List.cons Bool x xs) = (List.cons Bool (Bool.not x) (List.negate xs)) List.negate (List.nil Bool) = (List.nil Bool) List.tail (xs: (List a)) : (List a) List.tail a (List.cons t x xs) = xs List.map (x: (List a)) (f: (x: a) b) : (List b) List.map a b (List.nil t) f = List.nil List.map a b (List.cons t x xs) f = (List.cons (f x) (List.map xs f)) List.concat (xs: (List a)) (ys: (List a)) : (List a) List.concat a (List.cons u x xs) ys = (List.cons u x (List.concat a xs ys)) List.concat a (List.nil u) ys = ys List.flatten (xs: (List (List a))) : (List a) List.flatten a (List.cons u x xs) = (List.concat x (List.flatten xs)) List.flatten a (List.nil u) = List.nil List.bind (xs: (List a)) (f: a -> (List b)) : (List b) List.bind a b xs f = (List.flatten b (List.map xs f)) List.pure (x: t) : (List t) List.pure t x = (List.cons t x (List.nil t)) List.range.go (lim: Nat) (res: (List Nat)) : (List Nat) List.range.go Zero res = res List.range.go (Succ n) res = (List.range.go n (List.cons n res)) List.sum (xs: (List Nat)) : Nat List.sum (List.nil t) = Zero List.sum (List.cons t x xs) = (Nat.add x (List.sum xs)) // Equal // ----- Equal (a: t) (b: t) : Type Refl : (Equal t a a) Equal.mirror (e: (Equal t a b)) : (Equal t b a) Equal.mirror t a b (Refl u k) = (Refl u k) Equal.apply (f: t -> t) (e: (Equal t a b)) : (Equal t (f a) (f b)) Equal.apply t u a b f (Refl v k) = (Refl v (f k)) Equal.rewrite (a: t) (b: t) (e: (Equal t a b)) (p: t -> Type) (x: (p a)) : (p b) Equal.rewrite t a b (Refl u k) p x = {x :: (p k)} Equal.chain (e0: (Equal t a b)) (e1: (Equal t b c)) : (Equal t a c) Equal.chain t a b c e0 (Refl u x) = {e0 :: (Equal t a x)} // Monad // ----- Monad (f: Type -> Type) : Type Monad.new (f: Type -> Type) (pure: (a: Type) (x: a) (Monad (f a))) (bind: (a: Type) (b: Type) (x: (Monad a)) (y: a -> (Monad b)) (Monad b)) : (Monad f) // Examples // -------- The (x: U60) : Type Val (x: U60) : (The x) // FIXME: won't work til HVM's flattening update U60.to_nat (x: U60) : Nat U60.to_nat #0 = Zero U60.to_nat n = (Succ (U60.to_nat (- n #1))) Main : (List (List U60)) { do List { ask x = [ #1, #2, #3] ask y = [#10, #20, #30] return [x, y] } }