1
<html xmlns="http://www.w3.org/1999/xhtml">
3
<meta http-equiv="Content-Type" content="text/html; charset="><link rel="stylesheet" href="style.css" type="text/css"><title>Coq.Sets.Multiset</title>
8
<h1>Library Coq.Sets.Multiset</h1>
11
<code class="keyword">Require</code> <code class="keyword">Import</code> Permut.<br/>
14
Set <code class="keyword">Implicit</code> Arguments.<br/>
17
<code class="keyword">Section</code> multiset_defs.<br/>
20
<code class="keyword">Variable</code> A : Set.<br/>
21
<code class="keyword">Variable</code> eqA : A -> A -> Prop.<br/>
22
<code class="keyword">Hypothesis</code> Aeq_dec : forall x y:A, {eqA x y} + {~ eqA x y}.<br/>
25
<code class="keyword">Inductive</code> <a name="multiset"></a>multiset : Set :=<br/>
26
<a name="Bag"></a>Bag : (A -> <a href="Coq.Init.Datatypes.html#nat">nat</a>) -> multiset.<br/>
29
<code class="keyword">Definition</code> <a name="EmptyBag"></a>EmptyBag := <a href="Coq.Sets.Multiset.html#Bag">Bag</a> (fun a:A => 0).<br/>
30
<code class="keyword">Definition</code> <a name="SingletonBag"></a>SingletonBag (a:A) :=<br/>
31
<a href="Coq.Sets.Multiset.html#Bag">Bag</a> (fun a':A => match Aeq_dec a a' with<br/>
32
| <a href="Coq.Init.Specif.html#left">left</a> _ => 1<br/>
33
| <a href="Coq.Init.Specif.html#right">right</a> _ => 0<br/>
34
end).<br/>
37
<code class="keyword">Definition</code> <a name="multiplicity"></a>multiplicity (m:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>) (a:A) : <a href="Coq.Init.Datatypes.html#nat">nat</a> := let (f) := m in f a.<br/>
42
<table width="100%"><tr class="doc"><td>
46
<code class="keyword">Definition</code> <a name="meq"></a>meq (m1 m2:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>) :=<br/>
47
forall a:A, <a href="Coq.Sets.Multiset.html#multiplicity">multiplicity</a> m1 a = <a href="Coq.Sets.Multiset.html#multiplicity">multiplicity</a> m2 a.<br/>
50
<code class="keyword">Hint</code> Unfold meq multiplicity.<br/>
53
<code class="keyword">Lemma</code> <a name="meq_refl"></a>meq_refl : forall x:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x x.<br/>
54
<code class="keyword">Proof</code>.<br/>
55
destruct x; auto.<br/>
56
<code class="keyword">Qed</code>.<br/>
57
<code class="keyword">Hint</code> Resolve <a href="Coq.Sets.Multiset.html#meq_refl">meq_refl</a>.<br/>
60
<code class="keyword">Lemma</code> <a name="meq_trans"></a>meq_trans : forall x y z:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x y -> <a href="Coq.Sets.Multiset.html#meq">meq</a> y z -> <a href="Coq.Sets.Multiset.html#meq">meq</a> x z.<br/>
61
<code class="keyword">Proof</code>.<br/>
62
unfold meq in |- *.<br/>
63
destruct x; destruct y; destruct z.<br/>
64
intros; rewrite H; auto.<br/>
65
<code class="keyword">Qed</code>.<br/>
68
<code class="keyword">Lemma</code> <a name="meq_sym"></a>meq_sym : forall x y:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x y -> <a href="Coq.Sets.Multiset.html#meq">meq</a> y x.<br/>
69
<code class="keyword">Proof</code>.<br/>
70
unfold meq in |- *.<br/>
71
destruct x; destruct y; auto.<br/>
72
<code class="keyword">Qed</code>.<br/>
73
<code class="keyword">Hint</code> <code class="keyword">Immediate</code> <a href="Coq.Sets.Multiset.html#meq_sym">meq_sym</a>.<br/>
78
<table width="100%"><tr class="doc"><td>
82
<code class="keyword">Definition</code> <a name="munion"></a>munion (m1 m2:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>) :=<br/>
83
<a href="Coq.Sets.Multiset.html#Bag">Bag</a> (fun a:A => <a href="Coq.Sets.Multiset.html#multiplicity">multiplicity</a> m1 a + <a href="Coq.Sets.Multiset.html#multiplicity">multiplicity</a> m2 a).<br/>
86
<code class="keyword">Lemma</code> <a name="munion_empty_left"></a>munion_empty_left : forall x:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> <a href="Coq.Sets.Multiset.html#EmptyBag">EmptyBag</a> x).<br/>
87
<code class="keyword">Proof</code>.<br/>
88
unfold meq in |- *; unfold munion in |- *; simpl in |- *; auto.<br/>
89
<code class="keyword">Qed</code>.<br/>
90
<code class="keyword">Hint</code> Resolve <a href="Coq.Sets.Multiset.html#munion_empty_left">munion_empty_left</a>.<br/>
93
<code class="keyword">Lemma</code> <a name="munion_empty_right"></a>munion_empty_right : forall x:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> x <a href="Coq.Sets.Multiset.html#EmptyBag">EmptyBag</a>).<br/>
94
<code class="keyword">Proof</code>.<br/>
95
unfold meq in |- *; unfold munion in |- *; simpl in |- *; auto.<br/>
96
<code class="keyword">Qed</code>.<br/>
99
<code class="keyword">Require</code> <code class="keyword">Import</code> Plus. <code class="keyword">Lemma</code> <a name="munion_comm"></a>munion_comm : forall x y:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x y) (<a href="Coq.Sets.Multiset.html#munion">munion</a> y x).<br/>
100
<code class="keyword">Proof</code>.<br/>
101
unfold meq in |- *; unfold multiplicity in |- *; unfold munion in |- *.<br/>
102
destruct x; destruct y; auto with arith.<br/>
103
<code class="keyword">Qed</code>.<br/>
104
<code class="keyword">Hint</code> Resolve <a href="Coq.Sets.Multiset.html#munion_comm">munion_comm</a>.<br/>
107
<code class="keyword">Lemma</code> <a name="munion_ass"></a>munion_ass :<br/>
108
forall x y z:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x y) z) (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z)).<br/>
109
<code class="keyword">Proof</code>.<br/>
110
unfold meq in |- *; unfold munion in |- *; unfold multiplicity in |- *.<br/>
111
destruct x; destruct y; destruct z; auto with arith.<br/>
112
<code class="keyword">Qed</code>.<br/>
113
<code class="keyword">Hint</code> Resolve <a href="Coq.Sets.Multiset.html#munion_ass">munion_ass</a>.<br/>
116
<code class="keyword">Lemma</code> <a name="meq_left"></a>meq_left :<br/>
117
forall x y z:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x y -> <a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x z) (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z).<br/>
118
<code class="keyword">Proof</code>.<br/>
119
unfold meq in |- *; unfold munion in |- *; unfold multiplicity in |- *.<br/>
120
destruct x; destruct y; destruct z.<br/>
121
intros; elim H; auto with arith.<br/>
122
<code class="keyword">Qed</code>.<br/>
123
<code class="keyword">Hint</code> Resolve <a href="Coq.Sets.Multiset.html#meq_left">meq_left</a>.<br/>
126
<code class="keyword">Lemma</code> <a name="meq_right"></a>meq_right :<br/>
127
forall x y z:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x y -> <a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> z x) (<a href="Coq.Sets.Multiset.html#munion">munion</a> z y).<br/>
128
<code class="keyword">Proof</code>.<br/>
129
unfold meq in |- *; unfold munion in |- *; unfold multiplicity in |- *.<br/>
130
destruct x; destruct y; destruct z.<br/>
131
intros; elim H; auto.<br/>
132
<code class="keyword">Qed</code>.<br/>
133
<code class="keyword">Hint</code> Resolve <a href="Coq.Sets.Multiset.html#meq_right">meq_right</a>.<br/>
138
<table width="100%"><tr class="doc"><td>
139
Here we should make multiset an abstract datatype, by hiding <code>Bag</code>,
140
<code>munion</code>, <code>multiplicity</code>; all further properties are proved abstractly
145
<code class="keyword">Lemma</code> <a name="munion_rotate"></a>munion_rotate :<br/>
146
forall x y z:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z)) (<a href="Coq.Sets.Multiset.html#munion">munion</a> z (<a href="Coq.Sets.Multiset.html#munion">munion</a> x y)).<br/>
147
<code class="keyword">Proof</code>.<br/>
148
intros; apply (<a href="Coq.Sets.Permut.html#op_rotate">op_rotate</a> <a href="Coq.Sets.Multiset.html#multiset">multiset</a> <a href="Coq.Sets.Multiset.html#munion">munion</a> <a href="Coq.Sets.Multiset.html#meq">meq</a>); auto.<br/>
149
exact <a href="Coq.Sets.Multiset.html#meq_trans">meq_trans</a>.<br/>
150
<code class="keyword">Qed</code>.<br/>
153
<code class="keyword">Lemma</code> <a name="meq_congr"></a>meq_congr :<br/>
154
forall x y z t:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> x y -> <a href="Coq.Sets.Multiset.html#meq">meq</a> z t -> <a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x z) (<a href="Coq.Sets.Multiset.html#munion">munion</a> y t).<br/>
155
<code class="keyword">Proof</code>.<br/>
156
intros; apply (<a href="Coq.Sets.Permut.html#cong_congr">cong_congr</a> <a href="Coq.Sets.Multiset.html#multiset">multiset</a> <a href="Coq.Sets.Multiset.html#munion">munion</a> <a href="Coq.Sets.Multiset.html#meq">meq</a>); auto.<br/>
157
exact <a href="Coq.Sets.Multiset.html#meq_trans">meq_trans</a>.<br/>
158
<code class="keyword">Qed</code>.<br/>
161
<code class="keyword">Lemma</code> <a name="munion_perm_left"></a>munion_perm_left :<br/>
162
forall x y z:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>, <a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z)) (<a href="Coq.Sets.Multiset.html#munion">munion</a> y (<a href="Coq.Sets.Multiset.html#munion">munion</a> x z)).<br/>
163
<code class="keyword">Proof</code>.<br/>
164
intros; apply (<a href="Coq.Sets.Permut.html#perm_left">perm_left</a> <a href="Coq.Sets.Multiset.html#multiset">multiset</a> <a href="Coq.Sets.Multiset.html#munion">munion</a> <a href="Coq.Sets.Multiset.html#meq">meq</a>); auto.<br/>
165
exact <a href="Coq.Sets.Multiset.html#meq_trans">meq_trans</a>.<br/>
166
<code class="keyword">Qed</code>.<br/>
169
<code class="keyword">Lemma</code> <a name="multiset_twist1"></a>multiset_twist1 :<br/>
170
forall x y z t:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>,<br/>
171
<a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z) t)) (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y (<a href="Coq.Sets.Multiset.html#munion">munion</a> x t)) z).<br/>
172
<code class="keyword">Proof</code>.<br/>
173
intros; apply (<a href="Coq.Sets.Permut.html#twist">twist</a> <a href="Coq.Sets.Multiset.html#multiset">multiset</a> <a href="Coq.Sets.Multiset.html#munion">munion</a> <a href="Coq.Sets.Multiset.html#meq">meq</a>); auto.<br/>
174
exact <a href="Coq.Sets.Multiset.html#meq_trans">meq_trans</a>.<br/>
175
<code class="keyword">Qed</code>.<br/>
178
<code class="keyword">Lemma</code> <a name="multiset_twist2"></a>multiset_twist2 :<br/>
179
forall x y z t:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>,<br/>
180
<a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z) t)) (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y (<a href="Coq.Sets.Multiset.html#munion">munion</a> x z)) t).<br/>
181
<code class="keyword">Proof</code>.<br/>
182
intros; apply <a href="Coq.Sets.Multiset.html#meq_trans">meq_trans</a> with (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z)) t).<br/>
183
apply <a href="Coq.Sets.Multiset.html#meq_sym">meq_sym</a>; apply <a href="Coq.Sets.Multiset.html#munion_ass">munion_ass</a>.<br/>
184
apply <a href="Coq.Sets.Multiset.html#meq_left">meq_left</a>; apply <a href="Coq.Sets.Multiset.html#munion_perm_left">munion_perm_left</a>.<br/>
185
<code class="keyword">Qed</code>.<br/>
190
<table width="100%"><tr class="doc"><td>
191
specific for treesort
196
<code class="keyword">Lemma</code> <a name="treesort_twist1"></a>treesort_twist1 :<br/>
197
forall x y z t u:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>,<br/>
198
<a href="Coq.Sets.Multiset.html#meq">meq</a> u (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z) -><br/>
199
<a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> u t)) (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y (<a href="Coq.Sets.Multiset.html#munion">munion</a> x t)) z).<br/>
200
<code class="keyword">Proof</code>.<br/>
201
intros; apply <a href="Coq.Sets.Multiset.html#meq_trans">meq_trans</a> with (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z) t)).<br/>
202
apply <a href="Coq.Sets.Multiset.html#meq_right">meq_right</a>; apply <a href="Coq.Sets.Multiset.html#meq_left">meq_left</a>; trivial.<br/>
203
apply <a href="Coq.Sets.Multiset.html#multiset_twist1">multiset_twist1</a>.<br/>
204
<code class="keyword">Qed</code>.<br/>
207
<code class="keyword">Lemma</code> <a name="treesort_twist2"></a>treesort_twist2 :<br/>
208
forall x y z t u:<a href="Coq.Sets.Multiset.html#multiset">multiset</a>,<br/>
209
<a href="Coq.Sets.Multiset.html#meq">meq</a> u (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z) -><br/>
210
<a href="Coq.Sets.Multiset.html#meq">meq</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> u t)) (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y (<a href="Coq.Sets.Multiset.html#munion">munion</a> x z)) t).<br/>
211
<code class="keyword">Proof</code>.<br/>
212
intros; apply <a href="Coq.Sets.Multiset.html#meq_trans">meq_trans</a> with (<a href="Coq.Sets.Multiset.html#munion">munion</a> x (<a href="Coq.Sets.Multiset.html#munion">munion</a> (<a href="Coq.Sets.Multiset.html#munion">munion</a> y z) t)).<br/>
213
apply <a href="Coq.Sets.Multiset.html#meq_right">meq_right</a>; apply <a href="Coq.Sets.Multiset.html#meq_left">meq_left</a>; trivial.<br/>
214
apply <a href="Coq.Sets.Multiset.html#multiset_twist2">multiset_twist2</a>.<br/>
215
<code class="keyword">Qed</code>.<br/>
218
<code class="keyword">End</code> multiset_defs.<br/>
221
<code class="keyword">Unset</code> <code class="keyword">Implicit</code> Arguments.<br/>
224
<code class="keyword">Hint</code> Unfold meq multiplicity: v62 datatypes.<br/>
225
<code class="keyword">Hint</code> Resolve <a href="Coq.Sets.Multiset.html#munion_empty_right">munion_empty_right</a> <a href="Coq.Sets.Multiset.html#munion_comm">munion_comm</a> <a href="Coq.Sets.Multiset.html#munion_ass">munion_ass</a> <a href="Coq.Sets.Multiset.html#meq_left">meq_left</a> <a href="Coq.Sets.Multiset.html#meq_right">meq_right</a><br/>
226
<a href="Coq.Sets.Multiset.html#munion_empty_left">munion_empty_left</a>: v62 datatypes.<br/>
227
<code class="keyword">Hint</code> <code class="keyword">Immediate</code> <a href="Coq.Sets.Multiset.html#meq_sym">meq_sym</a>: v62 datatypes.</code>
228
<hr/><a href="index.html">Index</a><hr/><font size="-1">This page has been generated by <a href="http://www.lri.fr/~filliatr/coqdoc/">coqdoc</a></font>
b'\\ No newline at end of file'