summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <f@mazzo.li>2013-06-23 15:07:05 +0100
committerFrancesco Mazzoli <f@mazzo.li>2013-06-23 15:07:05 +0100
commit27d8348b35af1e7d5b2bc92e299f075f7b8de8e9 (patch)
tree77fa860916d97a582c733a0800338f214f1c09dd
parent1c05989bcb505bdf7ae2fcac6cbf02e3f3a24436 (diff)
...
-rw-r--r--demo.ka41
1 files changed, 41 insertions, 0 deletions
diff --git a/demo.ka b/demo.ka
new file mode 100644
index 0000000..8e9ba5f
--- /dev/null
+++ b/demo.ka
@@ -0,0 +1,41 @@
+data Empty : * ⇒ {}
+
+absurd [A : *] [x : Empty] : A ⇒ (
+ Empty-Elim x (λ _ ⇒ A)
+)
+
+record Unit : * ⇒ tt {}
+
+data Nat : * ⇒ { zero : Nat | suc : Nat → Nat }
+
+data List : [A : *] → * ⇒
+ { nil : List A | cons : A → List A → List A }
+
+nonEmpty [A : *] [l : List A] : * ⇒ (
+ {| h1 |}
+)
+
+nonEmpty [A : *] [l : List A] : * ⇒ (
+ List-Elim l (λ _ ⇒ *) {|h1|} {|h2|}
+)
+
+nonEmpty [A : *] [l : List A] : * ⇒ (
+ List-Elim l (λ _ ⇒ *) Empty (λ _ _ _ ⇒ Unit)
+)
+
+head [A : *] [l : List A] : nonEmpty A l → A ⇒ (
+ List-Elim l (λ l ⇒ nonEmpty A l → A)
+ {|h1|} {|h2|}
+)
+
+head [A : *] [l : List A] : nonEmpty A l → A ⇒ (
+ List-Elim l (λ l ⇒ nonEmpty A l → A)
+ (λ p ⇒ {|h1 p|})
+ (λ x l pl pxl ⇒ {|h2 x l pl pxl|})
+)
+
+head [A : *] [l : List A] : nonEmpty A l → A ⇒ (
+ List-Elim l (λ l ⇒ nonEmpty A l → A)
+ (λ p ⇒ absurd A p)
+ (λ x l pl pxl ⇒ x)
+)