aboutsummaryrefslogtreecommitdiffhomepage
path: root/theories/Init/Datatypes.v
diff options
context:
space:
mode:
authorGravatar herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7>2007-04-28 10:30:25 +0000
committerGravatar herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7>2007-04-28 10:30:25 +0000
commitef486799ac73c533e0a5b5cdd2662eb68a2636cb (patch)
treefe1e0b64e1d583aa4554d47202ce1b9a742ea59b /theories/Init/Datatypes.v
parentb61d0df2899f5de9c20ee4a2c4b79deb0714b162 (diff)
Déplacement des opérations sur bool dans l'état initial
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@9803 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'theories/Init/Datatypes.v')
-rw-r--r--theories/Init/Datatypes.v36
1 files changed, 35 insertions, 1 deletions
diff --git a/theories/Init/Datatypes.v b/theories/Init/Datatypes.v
index ab6469ad9..912192b26 100644
--- a/theories/Init/Datatypes.v
+++ b/theories/Init/Datatypes.v
@@ -26,6 +26,35 @@ Inductive bool : Set :=
Add Printing If bool.
+Delimit Scope bool_scope with bool.
+
+Bind Scope bool_scope with bool.
+
+(** Basic boolean operators *)
+
+Definition andb (b1 b2:bool) : bool := if b1 then b2 else false.
+
+Definition orb (b1 b2:bool) : bool := if b1 then true else b2.
+
+Definition implb (b1 b2:bool) : bool := if b1 then b2 else true.
+
+Definition xorb (b1 b2:bool) : bool :=
+ match b1, b2 with
+ | true, true => false
+ | true, false => true
+ | false, true => true
+ | false, false => false
+ end.
+
+Definition negb (b:bool) := if b then false else true.
+
+Infix "||" := orb (at level 50, left associativity) : bool_scope.
+Infix "&&" := andb (at level 40, left associativity) : bool_scope.
+
+(** Interpretation of booleans as propositions *)
+
+Inductive eq_true : bool -> Prop := is_eq_true : eq_true true.
+
(** [nat] is the datatype of natural numbers built from [O] and successor [S];
note that the constructor name is the letter O.
Numbers in [nat] can be denoted using a decimal notation;
@@ -70,7 +99,7 @@ Definition option_map (A B:Type) (f:A->B) o :=
end.
(** [sum A B], written [A + B], is the disjoint sum of [A] and [B] *)
-(* Syntax defined in Specif.v *)
+
Inductive sum (A B:Type) : Type :=
| inl : A -> sum A B
| inr : B -> sum A B.
@@ -82,6 +111,7 @@ Notation "x + y" := (sum x y) : type_scope.
Inductive prod (A B:Type) : Type :=
pair : A -> B -> prod A B.
+
Add Printing Let prod.
Notation "x * y" := (prod x y) : type_scope.
@@ -135,6 +165,8 @@ Definition CompOpp (r:comparison) :=
| Gt => Lt
end.
+(* begin hide *)
+
(* Compatibility *)
Notation prodT := prod (only parsing).
@@ -146,3 +178,5 @@ Notation fstT := fst (only parsing).
Notation sndT := snd (only parsing).
Notation prodT_uncurry := prod_uncurry (only parsing).
Notation prodT_curry := prod_curry (only parsing).
+
+(* end hide *)