Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coq: Prop versus Set in Type(n)

I want to consider the following three (related?) Coq definitions.

Inductive nat1: Prop :=
  | z1 : nat1
  | s1 : nat1 -> nat1.

Inductive nat2 : Set := 
  | z2 : nat2
  | s2 : nat2 -> nat2.

Inductive nat3 : Type :=
  | z3 : nat3
  | s3 : nat3 -> nat3.

All three types give induction principles to prove a proposition holds.

nat1_ind
     : forall P : Prop, P -> (nat1 -> P -> P) -> nat1 -> P

nat2_ind
     : forall P : nat2 -> Prop,
       P z2 -> (forall n : nat2, P n -> P (s2 n)) -> forall n : nat2, P n

nat3_ind
     : forall P : nat3 -> Prop,
       P z3 -> (forall n : nat3, P n -> P (s3 n)) -> forall n : nat3, P n

The set and type versions also contain induction principles for definitions over set and type (rec and rect respectively). This is the extent of my knowledge about the difference between Prop and Set; Prop has a weaker induction.

I have also read that Prop is impredicative while Set is predicative, but this seems like a property rather than a defining quality.

While some practical (moral?) differences between Set and Prop are clear, the exact, defining differences between Set and Prop, as well as where they fit into the universe of types is unclear (running check on Prop and Set gives Type (* (Set) + 1*)), and I'm not exactly sure how to interpret this...

like image 593
Jonathan Gallagher Avatar asked Mar 28 '15 20:03

Jonathan Gallagher


People also ask

What is prop in Coq?

The language of Coq Coq objects are sorted into two categories: the Prop sort and the Type sort: Prop is the sort for propositions, i.e. well-formed propositions are of type Prop. Typical propositions are: ∀ A B : Prop, A /\ B -> B \/ B ∀ x y : Z, x * y = 0 -> x = 0 \/ y = 0.

What is set in Coq?

Set means rather different things in Coq and HoTT. In Coq, every object has a type, including types themselves. Types of types are usually referred to as sorts, kinds or universes. In Coq, the (computationally relevant) universes are Set , and Type_i , where i ranges over natural numbers (0, 1, 2, 3, ...).


1 Answers

Type : Type is inconsistent.

Impredicative Set with excluded middle implies proof irrelevance, so impredicative Set with proof relevance, e.g. true <> false, refutes excluded middle, which intuitionism isn't supposed to do.

Therefore we leave impredicativity in Prop and the rest of the type hierarchy gives us predicativity.

By the way,

forall P : nat1 -> Prop, P z1 -> (forall n : nat1, P n -> P (s1 n)) -> forall n : nat1, P n

is provable. Don't ask me what's the benefit of Coq only automatically proving that other weaker induction principle...

Also, have you read this chapter of CPDT?

like image 82
gen Avatar answered Oct 29 '22 20:10

gen