Questions: Refinement Types

3 questions to test your understanding

Score: 0 / 3
Question 1 Multiple Choice

How does the refinement type {v : Int | v > 0 && v < 100} differ from a runtime assertion assert(v > 0 && v < 100)?

AThey check the same property but at different times: the refinement type checks statically at compile time, while the assertion checks at runtime. The refinement type guarantees the property holds on ALL executions, while the assertion only catches violations on executions that are actually run
BThe refinement type is less precise than the assertion
CThe assertion provides a formal proof while the refinement type does not
DThere is no meaningful difference; they are equivalent
Question 2 True / False

Liquid types achieve automatic type checking by restricting refinement predicates to decidable logics that SMT solvers can handle.

TTrue
FFalse
Question 3 Short Answer

Explain how refinement type checking reduces to SMT queries, using the example of checking that a function call div(x, y) is safe where div expects {v : Int | v != 0} as its second argument.

Think about your answer, then reveal below.