Questions: Dependent Types and Value-Level Type Constraints

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A dependently-typed language defines a function with signature: `matMul : Matrix<m, k> → Matrix<k, n> → Matrix<m, n>`. A programmer calls `matMul A B` where A has type `Matrix<3, 4>` and B has type `Matrix<5, 2>`. What happens?

AThe program compiles but throws a dimension mismatch exception at runtime
BThe program fails to type-check at compile time, because 4 ≠ 5 (the inner dimensions don't match)
CThe program compiles; the type system cannot track numeric values like matrix dimensions
DThe behavior depends on whether the compiler performs value inference
Question 2 Multiple Choice

Why do dependently typed languages like Agda and Idris require all functions used in types to be provably terminating (total functions)?

ATotality is a convenience requirement to make programs easier to read, not a formal requirement
BWithout guaranteed termination, type checking could loop forever trying to evaluate type-level computations
CPartial functions cannot be expressed in dependent type systems due to syntactic restrictions
DTotality is required only for standard library functions, not user-defined functions
Question 3 True / False

A function with type `safeHead : Vec<T, S n> → T` in a dependently-typed language provides a compile-time guarantee that the input list is non-empty.

TTrue
FFalse
Question 4 True / False

Dependent types are a generalization of generic types (parametric polymorphism): instead of parameterizing types over other types, you parameterize them over values.

TTrue
FFalse
Question 5 Short Answer

In dependent type theory, it is said that 'writing a well-typed program is the same as constructing a proof.' What does this mean concretely, and why does it eliminate certain categories of bugs?

Think about your answer, then reveal below.