1

I just learnt that 'record' keyword can be used to define a Prop type, for example in:

Record Equivalence (A : Type) (R : relation A) : Prop := Build_Equivalence
  { Equivalence_Reflexive : Reflexive R;
    Equivalence_Symmetric : Symmetric R;
    Equivalence_Transitive : Transitive R }

But when I tried to define a Proposition using Record, as in:

Record proprecord : Prop := Build_proprecord
{
 Baa : nat; 
 Boo : Prop
}.

I get the following message by Coq:

proprecord is defined
Baa cannot be defined because it is informative and proprecord is not.
[cannot-define-projection,records]
Boo cannot be defined because it is informative and proprecord is not.
[cannot-define-projection,records]

Can anyone explain what Coq is complaining about - and how to fix it?

Anon
  • 381
  • 1
  • 2
  • 13

1 Answers1

2

You only get projection functions (functions that take the whole record and return a single field, like fst and snd for prod) for fields whose types are in Prop, with the reason being that you can only get things in Prop out of a Prop (with some caveats around what is called singleton elimination). So Coq is warning you that it can't write the functions Baa : proprecord -> nat or Boo proprecord -> Prop.

If you want your record to behave like the exists quantifier, you can safely ignore or silence these warnings.

You can squash types into Prop by using inhabited, so you could write

Record proprecord : Prop := Build_proprecord
{
 Baa : inhabited nat; 
 Boo : inhabited Prop
}.

and get projections Baa : proprecord -> inhabited nat and Boo : proprecord -> inhabited Prop, if that is what you want.

Jasper Hugunin
  • 486
  • 2
  • 8
  • Could you explain the term 'projection functions'? – Anon Sep 02 '20 at 16:50
  • 1
    @Kaind see [this edit](https://stackoverflow.com/posts/63710026/revisions), projection functions take the whole record and return a single field, like `fst` and `snd` do for `prod`. – Jasper Hugunin Sep 02 '20 at 16:54