2022-07-17 06:50:50 +03:00
|
|
|
// Bool
|
|
|
|
// ----
|
|
|
|
|
2022-07-16 01:42:43 +03:00
|
|
|
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
|
|
|
|
|
2022-07-16 07:27:52 +03:00
|
|
|
Bool.not_not_theorem (a: Bool) : (Equal Bool a (Bool.not (Bool.not a)))
|
2022-07-17 06:44:44 +03:00
|
|
|
Bool.not_not_theorem True = (Refl Bool True)
|
|
|
|
Bool.not_not_theorem False = (Refl Bool False)
|
2022-07-16 06:52:56 +03:00
|
|
|
|
2022-07-17 06:50:50 +03:00
|
|
|
// Nat
|
|
|
|
// ---
|
|
|
|
|
|
|
|
Nat : Type
|
|
|
|
Zero : Nat
|
|
|
|
Succ (pred: Nat) : Nat
|
|
|
|
|
2022-07-16 06:52:56 +03:00
|
|
|
Nat.double (x: Nat) : Nat
|
|
|
|
Nat.double (Succ x) = (Succ (Succ (Nat.double x)))
|
|
|
|
Nat.double (Zero) = (Zero)
|
|
|
|
|
2022-07-17 06:50:50 +03:00
|
|
|
// List
|
|
|
|
// ----
|
|
|
|
|
|
|
|
List (a: Type) : Type
|
|
|
|
Nil <a> : (List a)
|
|
|
|
Cons <a> (x: a) (xs: (List a)) : (List a)
|
|
|
|
|
2022-07-16 01:42:43 +03:00
|
|
|
List.negate (xs: (List Bool)) : (List Bool)
|
|
|
|
List.negate (Cons Bool x xs) = (Cons Bool (Bool.not x) (List.negate xs))
|
|
|
|
List.negate (Nil Bool) = (Nil Bool)
|
|
|
|
|
2022-07-17 06:01:57 +03:00
|
|
|
List.tail <a> (xs: (List a)) : (List a)
|
2022-07-16 06:52:56 +03:00
|
|
|
List.tail a (Cons t x xs) = xs
|
|
|
|
|
2022-07-17 06:01:57 +03:00
|
|
|
List.map <a> <b> (x: (List a)) (f: (x: a) b) : (List b)
|
2022-07-16 02:10:59 +03:00
|
|
|
List.map a b (Nil t) f = (Nil b)
|
|
|
|
List.map a b (Cons t x xs) f = (Cons b (f x) (List.map a b xs f))
|
|
|
|
|
2022-07-17 06:50:50 +03:00
|
|
|
// Equal
|
|
|
|
// -----
|
|
|
|
|
|
|
|
Equal <t> (a: t) (b: t) : Type
|
|
|
|
Refl <t> (a: t) : (Equal t a a)
|
|
|
|
|
2022-07-17 06:01:57 +03:00
|
|
|
Equal.mirror <t> (a: t) (b: t) (e: (Equal t a b)) : (Equal t b a)
|
2022-07-16 01:42:43 +03:00
|
|
|
Equal.mirror t a b (Refl u k) = (Refl u k)
|
|
|
|
|
2022-07-17 06:01:57 +03:00
|
|
|
Equal.apply <t> <u> (a: t) (b: t) (f: t -> t) (e: (Equal t a b)) : (Equal t (f a) (f b))
|
2022-07-16 01:42:43 +03:00
|
|
|
Equal.apply t u a b f (Refl v k) = (Refl v (f k))
|
|
|
|
|
2022-07-17 06:01:57 +03:00
|
|
|
Equal.rewrite <t> (a: t) (b: t) (e: (Equal t a b)) (p: t -> Type) (x: (p a)) : (p b)
|
2022-07-16 01:42:43 +03:00
|
|
|
Equal.rewrite t a b (Refl u k) p x = {x :: (p k)}
|
|
|
|
|
2022-07-17 06:50:50 +03:00
|
|
|
// Examples
|
|
|
|
// --------
|
2022-07-17 04:35:48 +03:00
|
|
|
|
2022-07-17 06:01:57 +03:00
|
|
|
Id <t> (x: t) : t
|
|
|
|
Id t x = x
|
2022-07-16 20:26:38 +03:00
|
|
|
|
2022-07-17 06:50:50 +03:00
|
|
|
Example.hole : (List Bool) {
|
|
|
|
(Cons True (Cons False (Cons True Nil)))
|
|
|
|
}
|
|
|
|
|
2022-07-17 06:44:44 +03:00
|
|
|
Main : Nat {
|
|
|
|
(Nat.double (Nat.double (Succ (Succ Zero))))
|
2022-07-17 06:01:57 +03:00
|
|
|
}
|