Avigad.Chapter2 #
Dependent Type Theory
Exercise 1 #
Define the function Do_Twice
, as described in Section 2.4.
Equations
- Avigad.Chapter2.ex1.double x = x + x
Instances For
Equations
- Avigad.Chapter2.ex1.doTwice f x = f (f x)
Instances For
Equations
- Avigad.Chapter2.ex2.curry f α β = f (α, β)
Instances For
Equations
- Avigad.Chapter2.ex2.uncurry f x = f x.fst x.snd
Instances For
Exercise 3 #
Above, we used the example vec α n
for vectors of elements of type α
of
length n
. Declare a constant vec_add
that could represent a function that
adds two vectors of natural numbers of the same length, and a constant
vec_reverse
that can represent a function that reverses its argument. Use
implicit arguments for parameters that can be inferred. Declare some variables
nd check some expressions involving the constants that you have declared.
Exercise 4 #
Similarly, declare a constant matrix
so that matrix α m n
could represent
the type of m
by n
matrices. Declare some constants to represent functions
on this type, such as matrix addition and multiplication, and (using vec)
multiplication of a matrix by a vector. Once again, declare some variables and
check some expressions involving the constants that you have declared.