diff options
author | 2008-12-14 16:34:43 +0000 | |
---|---|---|
committer | 2008-12-14 16:34:43 +0000 | |
commit | c74f11d65b693207cdfa6d02f697e76093021be7 (patch) | |
tree | b32866140d9f5ecde0bb719c234c6603d44037a8 /theories/Classes/EquivDec.v | |
parent | 2f63108dccc104fe32344d88b35193d34a88f743 (diff) |
Generalized binding syntax overhaul: only two new binders: `() and `{},
guessing the binding name by default and making all generalized
variables implicit. At the same time, continue refactoring of
Record/Class/Inductive etc.., getting rid of [VernacRecord]
definitively. The AST is not completely satisfying, but leaning towards
Record/Class as restrictions of inductive (Arnaud, anyone ?).
Now, [Class] declaration bodies are either of the form [meth : type] or
[{ meth : type ; ... }], distinguishing singleton "definitional" classes
and inductive classes based on records. The constructor syntax is
accepted ([meth1 : type1 | meth1 : type2]) but raises an error
immediately, as support for defining a class by a general inductive type
is not there yet (this is a bugfix!).
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@11679 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'theories/Classes/EquivDec.v')
-rw-r--r-- | theories/Classes/EquivDec.v | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/theories/Classes/EquivDec.v b/theories/Classes/EquivDec.v index b530cc098..91c417ce3 100644 --- a/theories/Classes/EquivDec.v +++ b/theories/Classes/EquivDec.v @@ -1,4 +1,3 @@ -(* -*- coq-prog-args: ("-emacs-U" "-nois") -*- *) (************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *) @@ -15,8 +14,7 @@ (* $Id$ *) -Set Implicit Arguments. -Unset Strict Implicit. +Set Manual Implicit Arguments. (** Export notations. *) @@ -29,12 +27,12 @@ Require Import Coq.Logic.Decidable. Open Scope equiv_scope. -Class [ equiv : Equivalence A ] => DecidableEquivalence := +Class DecidableEquivalence `(equiv : Equivalence A) := setoid_decidable : forall x y : A, decidable (x === y). (** The [EqDec] class gives a decision procedure for a particular setoid equality. *) -Class [ equiv : Equivalence A ] => EqDec := +Class EqDec A R {equiv : Equivalence R} := equiv_dec : forall x y : A, { x === y } + { x =/= y }. (** We define the [==] overloaded notation for deciding equality. It does not take precedence @@ -54,7 +52,7 @@ Open Local Scope program_scope. (** Invert the branches. *) -Program Definition nequiv_dec [ EqDec A ] (x y : A) : { x =/= y } + { x === y } := swap_sumbool (x == y). +Program Definition nequiv_dec `{EqDec A} (x y : A) : { x =/= y } + { x === y } := swap_sumbool (x == y). (** Overloaded notation for inequality. *) @@ -62,10 +60,10 @@ Infix "<>" := nequiv_dec (no associativity, at level 70) : equiv_scope. (** Define boolean versions, losing the logical information. *) -Definition equiv_decb [ EqDec A ] (x y : A) : bool := +Definition equiv_decb `{EqDec A} (x y : A) : bool := if x == y then true else false. -Definition nequiv_decb [ EqDec A ] (x y : A) : bool := +Definition nequiv_decb `{EqDec A} (x y : A) : bool := negb (equiv_decb x y). Infix "==b" := equiv_decb (no associativity, at level 70). @@ -77,15 +75,15 @@ Require Import Coq.Arith.Peano_dec. (** The equiv is burried inside the setoid, but we can recover it by specifying which setoid we're talking about. *) -Program Instance nat_eq_eqdec : ! EqDec nat eq := +Program Instance nat_eq_eqdec : EqDec nat eq := equiv_dec := eq_nat_dec. Require Import Coq.Bool.Bool. -Program Instance bool_eqdec : ! EqDec bool eq := +Program Instance bool_eqdec : EqDec bool eq := equiv_dec := bool_dec. -Program Instance unit_eqdec : ! EqDec unit eq := +Program Instance unit_eqdec : EqDec unit eq := equiv_dec x y := in_left. Next Obligation. @@ -94,7 +92,7 @@ Program Instance unit_eqdec : ! EqDec unit eq := reflexivity. Qed. -Program Instance prod_eqdec [ EqDec A eq, EqDec B eq ] : +Program Instance prod_eqdec `(EqDec A eq, EqDec B eq) : ! EqDec (prod A B) eq := equiv_dec x y := let '(x1, x2) := x in @@ -106,8 +104,8 @@ Program Instance prod_eqdec [ EqDec A eq, EqDec B eq ] : Solve Obligations using unfold complement, equiv ; program_simpl. -Program Instance sum_eqdec [ EqDec A eq, EqDec B eq ] : - ! EqDec (sum A B) eq := +Program Instance sum_eqdec `(EqDec A eq, EqDec B eq) : + EqDec (sum A B) eq := equiv_dec x y := match x, y with | inl a, inl b => if a == b then in_left else in_right @@ -121,7 +119,7 @@ Program Instance sum_eqdec [ EqDec A eq, EqDec B eq ] : Require Import Coq.Program.FunctionalExtensionality. -Program Instance bool_function_eqdec [ EqDec A eq ] : ! EqDec (bool -> A) eq := +Program Instance bool_function_eqdec `(EqDec A eq) : ! EqDec (bool -> A) eq := equiv_dec f g := if f true == g true then if f false == g false then in_left @@ -138,7 +136,7 @@ Program Instance bool_function_eqdec [ EqDec A eq ] : ! EqDec (bool -> A) eq := Require Import List. -Program Instance list_eqdec [ eqa : EqDec A eq ] : ! EqDec (list A) eq := +Program Instance list_eqdec `(eqa : EqDec A eq) : ! EqDec (list A) eq := equiv_dec := fix aux (x : list A) y { struct x } := match x, y with |