@@ -272,30 +272,7 @@ Section Append.
272272 Example testappendnilright: (append l2 nil) = l2. Proof . apply idpath. Qed .
273273
274274 End AppendTests.
275-
276- (* Local Notation "l1 ++ l2" := (append l1 l2) (at level 60, left associativity).
277- Lemma appendnil1 {X : UU} (l1 : list X) : (l1 ++ nil) = l1.
278- Proof.
279- revert l1.
280- use list_ind; cbn beta; intros.
281- - apply idpath.
282- - exact (maponpaths (cons x) X0).
283- Qed.
284-
285- Lemma appendnil1inv {X : UU} (l1 : list X) : l1 = (l1 ++ nil).
286- Proof.
287- apply pathsinv0, appendnil1.
288- Qed.
289275
290- Lemma appendnil2 {X : UU} (l1 : list X) : (nil ++ l1) = l1.
291- Proof. apply idpath. Qed.
292-
293- Lemma appendnil2inv {X : UU} (l2 : list X) : l2 = (nil ++ l2).
294- Proof. apply idpath. Qed.
295-
296- Lemma appendtrans {X : UU} (l1 l2 l3 : list X) : (l1 ++ l2) ++ l3 = l1 ++ l2 ++ l3.
297- Proof. *)
298-
299276 Local Infix "++" := concatenate.
300277
301278 Lemma isin_concatenate1 {X : UU} (l1 l2 : list X) (x : X) : (is_in x l1) → (is_in x (l1 ++ l2)).
@@ -328,12 +305,51 @@ Section Append.
328305 Defined .
329306End Append.
330307
308+ Section ListProduct.
309+ Local Infix "++" := concatenate.
310+ Definition list_prod {X Y : UU} (l1 : list X) (l2 : list Y) : (list (X × Y)).
311+ Proof .
312+ revert l1.
313+ use list_ind; cbn beta.
314+ - exact nil.
315+ - intros; exact ((map (λ (y : Y), (x,, y)) l2) ++ X0).
316+ Defined .
317+
318+ Lemma inn_list_prod1 {X Y : UU} (l1 : list X) (l2 : list Y) (x : X) (y : Y) : (is_in x l1) → (is_in y l2) → (is_in (x,, y) (list_prod l1 l2)).
319+ Proof .
320+ revert l1.
321+ use list_ind; cbn beta.
322+ - exact fromempty.
323+ - intros x0 xs IHl inn1 inn2.
324+ destruct inn1 as [l | r].
325+ + apply isin_concatenate2. exact (IHl l inn2).
326+ + apply isin_concatenate1. rewrite <- r. clear IHl r x0.
327+ revert l2 inn2. use list_ind; cbn beta.
328+ * exact (fromempty).
329+ * intros y0 ys IHl [l | r]; rewrite -> (mapStep).
330+ -- left. exact (IHl l).
331+ -- right. rewrite -> r. apply idpath.
332+ Defined .
333+ End ListProduct.
334+
335+ Section Map.
336+
337+ Lemma is_inmap {X Y : UU} (f : X → Y) (l : list X) (x : X) : (is_in x l) → (is_in (f x) (map f l)).
338+ Proof .
339+ revert l. use list_ind; cbn beta.
340+ - exact fromempty.
341+ - intros x0 xs IHl [l | r].
342+ + left. exact (IHl l).
343+ + right. apply maponpaths. exact r.
344+ Defined .
345+ End Map.
346+
331347Section CumulativeFunctions.
332348
333349 Local Infix "++" := concatenate.
334- Definition iscumulative {X : UU} (L : nat → list X) := ∏ (n : nat), ∃ (l : list X), (L (S n) = ((L n) ++ l)).
350+ Definition iscumulative {X : UU} (L : nat → list X) := ∏ (n : nat), ∑ (l : list X), (L (S n) = ((L n) ++ l)).
335351
336- Lemma cumulativenleqm {X : UU} (L : nat → list X) (iscum : (iscumulative L)) (m n : nat) : n ≤ m → ∃ (l : list X), L m = (L n) ++ l.
352+ Lemma cumulativenleqm {X : UU} (L : nat → list X) (iscum : (iscumulative L)) (m n : nat) : n ≤ m → ∑ (l : list X), L m = (L n) ++ l.
337353 Proof .
338354 intros nleqm.
339355 assert (eq : ∑ (k : nat), n + k = m).
@@ -342,11 +358,11 @@ Section CumulativeFunctions.
342358 + cbn beta. rewrite -> (natpluscomm n (m - n)). apply (minusplusnmm _ _ nleqm).
343359 - destruct eq as [k eq].
344360 induction eq; induction k.
345- + rewrite (natpluscomm n 0). apply hinhpr. use (tpair _ nil). simpl. rewrite -> (concatenate_nil (L n)). apply idpath.
346- + rewrite (natplusnsm n k); use (squash_to_prop ( iscum (n + k)) (propproperty _)); intros [l eq]; clear iscum.
347- use (squash_to_prop ( IHk (natlehnplusnm _ _)) (propproperty _)); intros [l0 neq]; clear IHk; apply hinhpr .
361+ + rewrite (natpluscomm n 0). use (tpair _ nil). simpl. rewrite -> (concatenate_nil (L n)). apply idpath.
362+ + rewrite (natplusnsm n k); destruct ( iscum (n + k)) as [l eq]; clear iscum.
363+ destruct ( IHk (natlehnplusnm _ _)) as [l0 neq]; clear IHk.
348364 use (tpair _ (l0 ++ l)). simpl. rewrite -> eq, neq. apply assoc_concatenate.
349- Qed .
365+ Qed .
350366
351367 Definition cumul {X : UU} : (nat → list X) → (nat → list X).
352368 Proof .
@@ -359,10 +375,8 @@ Section CumulativeFunctions.
359375 Lemma iscumulativecumul {X : UU} (L : nat → list X) : (iscumulative (cumul L)).
360376 Proof .
361377 intros n; induction n.
362- - apply hinhpr.
363- use (tpair _ (L 1) (idpath _)).
364- - use (squash_to_prop IHn (propproperty _)); intros IH; clear IHn; apply hinhpr.
365- use (tpair _ (L (S (S n))) (idpath _)).
378+ - use (tpair _ (L 1) (idpath _)).
379+ - use (tpair _ (L (S (S n))) (idpath _)).
366380 Defined .
367381
368382 Lemma isinlisincumull {X : UU} (L : nat → list X) (x : X) (n : nat) : (is_in x (L n)) → (is_in x (cumul L n)).
@@ -371,7 +385,14 @@ Section CumulativeFunctions.
371385 induction n.
372386 - exact inn.
373387 - simpl. apply isin_concatenate2. exact inn.
374- Defined .
388+ Defined .
389+
390+ Lemma isincumulleh {X : UU} (L : nat → list X) (x : X) (iscum : iscumulative L) (n m: nat) : (n ≤ m) → (is_in x (L n)) → (is_in x (L m)).
391+ Proof .
392+ intros leq inn.
393+ set (q := cumulativenleqm L iscum m n leq); destruct q as [l eq]; rewrite -> eq.
394+ apply isin_concatenate1. exact inn.
395+ Defined .
375396
376397 Lemma iscumulex {X : UU} (L : nat → list X) (x : X) : (∃ (n : nat), (is_in x (L n))) <-> (∃ (n : nat), (is_in x (cumul L n))).
377398 Proof .
@@ -383,7 +404,7 @@ Section CumulativeFunctions.
383404 + induction (isin_concatenate_choice (cumul L n) (L (S n)) x inn).
384405 * exact (IHn a).
385406 * exact ((S n),, b).
386- Defined .
407+ Defined .
387408
388409End CumulativeFunctions.
389410
0 commit comments