Consider the following function elem
and the lemma that the result of elem
does not depend on the proof of l <> nil
.
Program Definition elem {A: Type} (l: list A) (nn: l <> nil): A :=
match l with
| nil => _
| (a::_) => a
end.
Lemma elem_proof_irrelevant: forall A (l: list A) nn1 nn2, elem l nn1 = elem l nn2.
Proof.
intros. destruct l; [congruence | now unfold elem].
Qed.
My understanding of universes is very limited, but I believe that, in Coq, you cannot define something in Set
whose value depends on something in Prop
. At least, I believe that the result of elem
cannot depend on nn
for universe-related reasons.
So is there a more general way to prove elem_proof_irrelevant
- i.e. that elem only depends on its first parameter - that does not inspect elem
and would work on arbitrary functions, without assuming proof_irrelevance
or other axioms?