Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Subtype argument, precondition or sumor return type? Which to choose?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Subtype argument, precondition or sumor return type? Which to choose?


Chronological Thread 
  • From: Michiel Helvensteijn <mhelvens AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: [Coq-Club] Subtype argument, precondition or sumor return type? Which to choose?
  • Date: Sun, 14 Jul 2013 13:59:30 +0200

Hi all!

Let's take the following inductive type (simplified example):

Inductive Op :=
| add (_:nat) : Op
| remove : Op
| replace (_:nat) : Op.

I want to write a partial function which can take only an 'add' or
'replace' operation and returns a value of type T. I've found (at
least) three ways of specifying it:

Definition do_stuff (a: Op) : T + { a = remove }.
... Defined.

Definition do_stuff' (a: Op) : (a <> remove) -> T.
... Defined.

Definition do_stuff'' (a: {o: Op | o <> remove}) : T.
... Defined.

I believe all three are equivalent. Do you agree?

I'm trying to decide which to go ahead with. In your experience, what
are the advantages and disadvantages of each of these choices in
practice? Which do you prefer?

Thanks!

--
www.mhelvens.net



Archive powered by MHonArc 2.6.18.

Top of Page