Set_bool.v 5.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
(* This file is generated by Why3's Coq driver *)
(* Beware! Only edit allowed sections below    *)
Require Import ZArith.
Require Import Rbase.
Add Rec LoadPath "/home/cmarche/recherche/why3/share/theories".
Add Rec LoadPath "/home/cmarche/recherche/why3/share/modules".

Inductive set_ (X:Type) : Type := mk_set: (X -> bool) -> set_ X.

Definition set : forall (a:Type), Type.
(* YOU MAY EDIT THE PROOF BELOW *)
exact set_.
(*
exact (fun (X: Type) => X -> Prop).
*)
Defined.
(* DO NOT EDIT BELOW *)

Definition mem: forall (a:Type), a -> (set a) -> Prop.
(* YOU MAY EDIT THE PROOF BELOW *)
intros X x s.
destruct s.
exact (match (b x) with true => True | false => False end).
Defined.
(* DO NOT EDIT BELOW *)

Implicit Arguments mem.

Definition infix_eqeq (a:Type)(s1:(set a)) (s2:(set a)): Prop :=
  forall (x:a), (mem x s1) <-> (mem x s2).
Implicit Arguments infix_eqeq.

(* YOU MAY EDIT THE CONTEXT BELOW *)
Hint Unfold mem.
Notation "x == y" := (infix_eqeq x y) (at level 70, no associativity).

Require Import FunctionalExtensionality.
(*
MARCHE Claude's avatar
MARCHE Claude committed
39 40 41
Require Classical.
Require ClassicalFacts.
Require PredicateExtensionality.
42 43
Require ProofIrrelevance.
*)
MARCHE Claude's avatar
MARCHE Claude committed
44

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
(* DO NOT EDIT BELOW *)

Lemma extensionality : forall (a:Type), forall (s1:(set a)) (s2:(set a)),
  (infix_eqeq s1 s2) -> (s1 = s2).
(* YOU MAY EDIT THE PROOF BELOW *)
intros.
destruct s1 as (b1).
destruct s2 as (b2).
apply f_equal.
extensionality x.
red in H.
unfold mem in H.
generalize (H x); clear H.
intro H.
destruct (b1 x); destruct (b2 x); tauto.
Qed.
(* DO NOT EDIT BELOW *)

Definition subset (a:Type)(s1:(set a)) (s2:(set a)): Prop := forall (x:a),
  (mem x s1) -> (mem x s2).
Implicit Arguments subset.

(* YOU MAY EDIT THE CONTEXT BELOW *)
(*Hint Unfold subset.*)
(* DO NOT EDIT BELOW *)

Lemma subset_trans : forall (a:Type), forall (s1:(set a)) (s2:(set a))
  (s3:(set a)), (subset s1 s2) -> ((subset s2 s3) -> (subset s1 s3)).
(* YOU MAY EDIT THE PROOF BELOW *)
unfold subset; intuition.
Qed.
(* DO NOT EDIT BELOW *)

Definition empty: forall (a:Type), (set a).
(* YOU MAY EDIT THE PROOF BELOW *)
exact (fun X => mk_set X (fun _ => false)).
Defined.
(* DO NOT EDIT BELOW *)

Set Contextual Implicit.
Implicit Arguments empty.
Unset Contextual Implicit.

Definition is_empty (a:Type)(s:(set a)): Prop := forall (x:a), ~ (mem x s).
Implicit Arguments is_empty.

(* YOU MAY EDIT THE CONTEXT BELOW *)
(*Print Implicit empty.*)
(* DO NOT EDIT BELOW *)

Lemma empty_def1 : forall (a:Type), (is_empty (empty:(set a))).
(* YOU MAY EDIT THE PROOF BELOW *)
unfold is_empty; intuition.
Qed.
(* DO NOT EDIT BELOW *)

Definition add: forall (a:Type), a -> (set a) -> (set a).
(* YOU MAY EDIT THE PROOF BELOW *)
intros X x s.
destruct s.
exact (mk_set _ (fun y => if b y then true else y=x)).
Defined.
(* DO NOT EDIT BELOW *)

Implicit Arguments add.

(* YOU MAY EDIT THE CONTEXT BELOW *)

(* DO NOT EDIT BELOW *)

Lemma add_def1 : forall (a:Type), forall (x:a) (y:a), forall (s:(set a)),
  (mem x (add y s)) <-> ((x = y) \/ (mem x s)).
(* YOU MAY EDIT THE PROOF BELOW *)
intros; destruct s.
unfold mem,add; intuition.
Qed.
(* DO NOT EDIT BELOW *)

Definition remove: forall (a:Type), a -> (set a) -> (set a).
(* YOU MAY EDIT THE PROOF BELOW *)
intros X x s.
destruct s.
exact (mk_set _ (fun y => y<>x /\ P y)).
Defined.
(* DO NOT EDIT BELOW *)

Implicit Arguments remove.

(* YOU MAY EDIT THE CONTEXT BELOW *)

(* DO NOT EDIT BELOW *)

Lemma remove_def1 : forall (a:Type), forall (x:a) (y:a) (s:(set a)), (mem x
  (remove y s)) <-> ((~ (x = y)) /\ (mem x s)).
(* YOU MAY EDIT THE PROOF BELOW *)
intros; destruct s.
unfold mem,remove; intuition.
Qed.
(* DO NOT EDIT BELOW *)

(* YOU MAY EDIT THE CONTEXT BELOW *)

(* DO NOT EDIT BELOW *)

Lemma subset_remove : forall (a:Type), forall (x:a) (s:(set a)),
  (subset (remove x s) s).
(* YOU MAY EDIT THE PROOF BELOW *)
intros; destruct s.
unfold subset, remove, mem; intuition.
Qed.
(* DO NOT EDIT BELOW *)

Definition union: forall (a:Type), (set a) -> (set a) -> (set a).
(* YOU MAY EDIT THE PROOF BELOW *)
intros X s1 s2.
destruct s1; destruct s2.
exact (mk_set _ (fun y => P y \/ P0 y)).
Defined.
(* DO NOT EDIT BELOW *)

Implicit Arguments union.

(* YOU MAY EDIT THE CONTEXT BELOW *)

(* DO NOT EDIT BELOW *)

Lemma union_def1 : forall (a:Type), forall (s1:(set a)) (s2:(set a)) (x:a),
  (mem x (union s1 s2)) <-> ((mem x s1) \/ (mem x s2)).
(* YOU MAY EDIT THE PROOF BELOW *)
intros; destruct s1; destruct s2.
unfold union,mem; intuition.
Qed.
(* DO NOT EDIT BELOW *)

Definition inter: forall (a:Type), (set a) -> (set a) -> (set a).
(* YOU MAY EDIT THE PROOF BELOW *)
intros X s1 s2.
destruct s1; destruct s2.
exact (mk_set _ (fun y => P y /\ P0 y)).
Defined.
(* DO NOT EDIT BELOW *)

Implicit Arguments inter.

(* YOU MAY EDIT THE CONTEXT BELOW *)

(* DO NOT EDIT BELOW *)

Lemma inter_def1 : forall (a:Type), forall (s1:(set a)) (s2:(set a)) (x:a),
  (mem x (inter s1 s2)) <-> ((mem x s1) /\ (mem x s2)).
(* YOU MAY EDIT THE PROOF BELOW *)
intros; destruct s1; destruct s2.
unfold inter, mem; intuition.
Qed.
(* DO NOT EDIT BELOW *)

Definition diff: forall (a:Type), (set a) -> (set a) -> (set a).
(* YOU MAY EDIT THE PROOF BELOW *)
intros X s1 s2.
destruct s1; destruct s2.
exact (mk_set _ (fun y => P y /\ ~(P0 y))).
Defined.
(* DO NOT EDIT BELOW *)

Implicit Arguments diff.

(* YOU MAY EDIT THE CONTEXT BELOW *)

(* DO NOT EDIT BELOW *)

Lemma diff_def1 : forall (a:Type), forall (s1:(set a)) (s2:(set a)) (x:a),
  (mem x (diff s1 s2)) <-> ((mem x s1) /\ ~ (mem x s2)).
(* YOU MAY EDIT THE PROOF BELOW *)
intros; destruct s1; destruct s2.
unfold diff, mem; intuition.
Qed.
(* DO NOT EDIT BELOW *)

(* YOU MAY EDIT THE CONTEXT BELOW *)

(* DO NOT EDIT BELOW *)

Lemma subset_diff : forall (a:Type), forall (s1:(set a)) (s2:(set a)),
  (subset (diff s1 s2) s1).
(* YOU MAY EDIT THE PROOF BELOW *)
intros; destruct s1; destruct s2.
unfold subset, diff, mem; intuition.
Qed.
(* DO NOT EDIT BELOW *)