coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jonathan Leivent <jonikelee AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] General Advice about When to Use Prop and When to use bool
- Date: Wed, 21 Jun 2017 14:08:58 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt0-f171.google.com
- Ironport-phdr: 9a23:HFHjvBEfjkKvfF2GN8w7MJ1GYnF86YWxBRYc798ds5kLTJ7zpsmwAkXT6L1XgUPTWs2DsrQf2rWQ6/iocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbQhFgDiwbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjDQhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VjO+4qplShLlhj4LOyI2/WrKjsB9jL5XrBenqhdiwYDbfZuVOeJjcK3Dc9MURWlPUMhfWCNOAIyzc4QBAvEdPetatYTxu0cCoBW8CASqGejhyiVIhnjz3aAi1+ohFgfG0xY8H9IOqnvUqsj+OqEMXuC00qnH0zPDb+9L0jr66ojIdRYhofCPXb1udcre11cgGhjKjlWVs4PlPjeV2v4RvGic6uptTOSigHMppQF2pzig3MYsio/Ri4IO1lDL7zl2wIUyJd2mVkF7e9CkEJ9XtyCULYd5XsQiQ2RutS0nybMGoYa2cDYWxJkj3RLSaPyKf5KW7h7+VeudOyp0iXB4dL6nmRq//lKsx+zhWsWu01tHrzBJnsTQun0P0RHY99KJReFn/ki73DaCzwDT5f9AIUAzjafbLoQuwr80lpYKqETDAjP6lFz4jKOLdEgo5/Kk6+vgYrXhqZ+cM5F7hhviPaQpn8yzGeU4Mg4QUGiH4emwyqHv8EnjTLhJjvA6iLfVvI3bKMgBu6K0ARJZ3p4m6xmlDjem1NoYnWMALFJAYB+HjY/pO1fPIPD7E/i/h0qjnylwyvDJO73uGJTNLnzZnLj9erZ97lZQyBAvwtBH+5JUFrYBLervVU/2rdzUFwM2Mwipw+n8E9h9zYMfWWeXAqCDKq/SsFmI5vguI+aWfoMVtiz9eLAZ4KvlimZ8klsAd4Go24EWYTa2BKdIOUKcNFjrhN4dEW4M9i4zTfLnjkHKBTxUYXexUqYx6xk0DYunCcHIQYX70+/J5zuyApADPjMOMVuLC3q9Kt2J
I think the general answer is that bools can convey information, Props can't. Props are most useful for expressing invariants, while bools are data.
This distinction is important in two places: within proofs and in extraction results. Within proofs, if Props are used, they can be case analyzed, but only when the conclusion is itself a Prop (or when the Prop being case analyzed is not potentially informative, as when it has zero or one constructor with no informative fields). Bools have no such case analysis restrictions.
For extraction, the fact that Props can't convey information is used by Coq to erase all Props. This is very useful when one wishes to generate code (such as OCaml code) from Coq definitions such that the generated code does not carry any "proof burden" in terms of resource-consuming activity that does not alter the definition's external behavior. Such proof burden can be prohibitively high if not erased. Note, however, that if Coq had a much better extraction erasure algorithm (as in, for example, Idris), one could potentially get the same extraction behavior using bools instead of Props.
My advice is that if you are formalizing software in Coq, especially with the goal of extraction, then use Props for invariants. Even when you don't have the goal of extraction, it is often useful to have an enforced separation between data and invariants as a way to make your intentions clearer.
-- Jonathan
On 06/21/2017 01:18 PM, John L. Singleton wrote:
I posted the following question on Stackoverflow:
https://stackoverflow.com/questions/44638724/general-advice-about-when-to-use-prop-and-when-to-use-bool/
On the suggestion of one of the commenters I am also asking this question
here.
I am formalizing a grammar which is essentially one over boolean expressions. In Coq, you can get boolean-like things in Prop or more explicitly in bool.
So for example, I could write:
true && true
Or
True /\ True
The problem is that in proofs (which is what I really care about) I can do a
case analysis in domain bool, but in Prop this is not possible (since all
members are not enumerable, I suppose). Giving up this tactic and similar
rewriting tactics seems like a huge drawback even for very simple proofs.
In general, what situations would one choose Prop over bool for formalizing?
I realize this is a broad question, but I feel like this is not addressed in
the Coq manual sufficiently. I am interested in real world experience people
have had going down both routes.
Thanks,
JLS
- [Coq-Club] General Advice about When to Use Prop and When to use bool, John L. Singleton, 06/21/2017
- Re: [Coq-Club] General Advice about When to Use Prop and When to use bool, John Wiegley, 06/21/2017
- Re: [Coq-Club] General Advice about When to Use Prop and When to use bool, Jonathan Leivent, 06/21/2017
Archive powered by MHonArc 2.6.18.