Skip to content

Commit a1c0c39

Browse files
committed
Added lecture 3 notes and code
1 parent 4b4eb23 commit a1c0c39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+5783
-0
lines changed

Code/Lecture3/Exercise.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Today's exercise:
2+
3+
There are some holes in this version of TTImp.Elab.Term, in the rules for
4+
Pi and Lambda. Fill them in by following the typing rules.
5+
6+
You can find some of the answers in TinyIdris-v1. But there is also a hole
7+
for a Lambda with an unknown expected type. How can you handle this?
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
data Nat : Type where
2+
Z : Nat
3+
S : Nat -> Nat
4+
5+
plus : Nat -> Nat -> Nat
6+
pat y : Nat =>
7+
plus Z y = y
8+
pat k : Nat, y : Nat =>
9+
plus (S k) y = S (plus k y)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
data Nat : Type where
2+
Z : Nat
3+
S : Nat -> Nat
4+
5+
plus : Nat -> Nat -> Nat
6+
pat y : Nat =>
7+
plus Z y = y
8+
pat k : Nat, y : Nat =>
9+
plus (S k) y = S (plus k y)
10+
11+
data Vect : Nat -> Type -> Type where
12+
Nil : (a : Type) -> Vect Z a
13+
Cons : (a : Type) -> (k : Nat) ->
14+
a -> Vect k a -> Vect (S k) a
15+
16+
append : (a : Type) -> (n : Nat) -> (m : Nat) ->
17+
Vect n a -> Vect m a -> Vect (plus n m) a
18+
pat a : Type, k : Nat, ys : Vect k a =>
19+
append a Z k (Nil a) ys = ys
20+
pat a : Type, n : Nat, x : a, xs : Vect n a, k : Nat, ys : Vect k a =>
21+
append a (S n) k (Cons a n x xs) ys
22+
= Cons a (plus n k) x (append a n k xs ys)

0 commit comments

Comments
 (0)