@@ -842,21 +842,21 @@ Section Elts.
842
842
Lemma remove_remove_eq : forall l x, remove x (remove x l) = remove x l.
843
843
Proof . intros l x; now rewrite (notin_remove _ _ (remove_In l x)). Qed .
844
844
845
- Lemma remove_length_le : forall l x, length (remove x l) <= length l.
845
+ Lemma length_remove_le : forall l x, length (remove x l) <= length l.
846
846
Proof .
847
847
intro l; induction l as [|y l IHl]; simpl; intros x; trivial.
848
848
destruct (eq_dec x y); simpl.
849
849
- rewrite IHl; constructor; reflexivity.
850
850
- apply (proj1 (Nat.succ_le_mono _ _) (IHl x)).
851
851
Qed .
852
852
853
- Lemma remove_length_lt : forall l x, In x l -> length (remove x l) < length l.
853
+ Lemma length_remove_lt : forall l x, In x l -> length (remove x l) < length l.
854
854
Proof .
855
855
intro l; induction l as [|y l IHl]; simpl; intros x Hin.
856
856
- contradiction Hin.
857
857
- destruct Hin as [-> | Hin].
858
858
+ destruct (eq_dec x x); [|easy].
859
- apply Nat.lt_succ_r, remove_length_le .
859
+ apply Nat.lt_succ_r, length_remove_le .
860
860
+ specialize (IHl _ Hin); destruct (eq_dec x y); simpl; auto.
861
861
now apply Nat.succ_lt_mono in IHl.
862
862
Qed .
@@ -1730,20 +1730,20 @@ End Fold_Right_Recursor.
1730
1730
- cbn. rewrite IH. destruct (f x); reflexivity.
1731
1731
Qed .
1732
1732
1733
- Corollary filter_length f (l : list A) : length (filter f l) + length (filter (fun x => negb (f x)) l) = length l.
1733
+ Corollary length_filter f (l : list A) : length (filter f l) + length (filter (fun x => negb (f x)) l) = length l.
1734
1734
Proof . symmetry. apply (partition_length f), partition_as_filter. Qed .
1735
1735
1736
- Corollary filter_length_le f (l : list A): length (filter f l) <= length l.
1737
- Proof . rewrite <- (filter_length f l). apply Nat.le_add_r. Qed .
1736
+ Corollary length_filter_le f (l : list A): length (filter f l) <= length l.
1737
+ Proof . rewrite <- (length_filter f l). apply Nat.le_add_r. Qed .
1738
1738
1739
- Lemma filter_length_forallb f (l : list A): length (filter f l) = length l -> forallb f l = true.
1739
+ Lemma length_filter_forallb f (l : list A): length (filter f l) = length l -> forallb f l = true.
1740
1740
Proof .
1741
1741
intro H. induction l as [|x l IH]; [reflexivity |].
1742
1742
cbn in *. destruct (f x).
1743
1743
- apply IH. now injection H.
1744
1744
- exfalso. assert (length l < length (filter f l)) as E.
1745
1745
+ symmetry in H. apply Nat.eq_le_incl in H. exact H.
1746
- + eapply Nat.le_ngt; [apply filter_length_le | exact E].
1746
+ + eapply Nat.le_ngt; [apply length_filter_le | exact E].
1747
1747
Qed .
1748
1748
1749
1749
(** Remove by filtering *)
@@ -2185,14 +2185,14 @@ Section Cutting.
2185
2185
Lemma firstn_O l: firstn 0 l = [].
2186
2186
Proof . now simpl. Qed .
2187
2187
2188
- Lemma firstn_le_length n: forall l:list A, length (firstn n l) <= n.
2188
+ Lemma length_firstn_le n: forall l:list A, length (firstn n l) <= n.
2189
2189
Proof .
2190
2190
induction n as [|k iHk]; simpl; [auto | intro l; destruct l as [|x xs]; simpl].
2191
2191
- now apply Nat.le_0_l.
2192
2192
- now rewrite <- Nat.succ_le_mono.
2193
2193
Qed .
2194
2194
2195
- Lemma firstn_length_le : forall l:list A, forall n:nat,
2195
+ Lemma length_firstn_eq : forall l:list A, forall n:nat,
2196
2196
n <= length l -> length (firstn n l) = n.
2197
2197
Proof . intro l; induction l as [|x xs Hrec].
2198
2198
- simpl. intros n H. apply Nat.le_0_r in H. now subst.
@@ -3670,7 +3670,7 @@ Section Repeat.
3670
3670
| S k => x::(repeat x k)
3671
3671
end .
3672
3672
3673
- Theorem repeat_length x n:
3673
+ Theorem length_repeat x n:
3674
3674
length (repeat x n) = n.
3675
3675
Proof .
3676
3676
induction n as [| k Hrec]; simpl; rewrite ?Hrec; reflexivity.
@@ -3701,7 +3701,7 @@ Section Repeat.
3701
3701
repeat x n = l1 ++ l2 -> repeat x (length l1) = l1 /\ repeat x (length l2) = l2.
3702
3702
Proof .
3703
3703
revert n; induction l1 as [|a l1 IHl1]; simpl; intros n Hr; subst.
3704
- - repeat split; now rewrite repeat_length .
3704
+ - repeat split; now rewrite length_repeat .
3705
3705
- destruct n; inversion Hr as [ [Heq Hr0] ]; subst.
3706
3706
now apply IHl1 in Hr0 as [-> ->].
3707
3707
Qed .
@@ -3799,7 +3799,7 @@ Section Repeat.
3799
3799
Proof .
3800
3800
intro Hnm. rewrite (nth_error_nth' _ a).
3801
3801
- now rewrite nth_repeat.
3802
- - now rewrite repeat_length .
3802
+ - now rewrite length_repeat .
3803
3803
Qed .
3804
3804
3805
3805
End Repeat.
@@ -3854,7 +3854,7 @@ Proof.
3854
3854
rewrite flat_map_concat_map, length_concat, map_map. reflexivity.
3855
3855
Qed .
3856
3856
3857
- Corollary flat_map_constant_length A B c (f: A -> list B) l:
3857
+ Corollary length_flat_map_constant A B c (f: A -> list B) l:
3858
3858
(forall x, In x l -> length (f x) = c) -> length (flat_map f l) = (length l) * c.
3859
3859
Proof .
3860
3860
intro H. rewrite length_flat_map.
@@ -3867,7 +3867,7 @@ Lemma length_list_power (A B:Type)(l:list A) (l':list B):
3867
3867
length (list_power l l') = (length l')^(length l).
3868
3868
Proof .
3869
3869
induction l as [ | a m IH ]; [reflexivity|].
3870
- cbn. rewrite flat_map_constant_length with (c := length l').
3870
+ cbn. rewrite length_flat_map_constant with (c := length l').
3871
3871
- rewrite IH. apply Nat.mul_comm.
3872
3872
- intros x H. apply length_map.
3873
3873
Qed .
@@ -4013,6 +4013,15 @@ Notation concat_length := length_concat (only parsing).
4013
4013
Notation flat_map_length := length_flat_map (only parsing).
4014
4014
#[deprecated(since = "8.20", note = "Use length_list_power instead.")]
4015
4015
Notation list_power_length := length_list_power (only parsing).
4016
+ Notation remove_length_le := length_remove_le (only parsing).
4017
+ Notation remove_length_lt := length_remove_lt (only parsing).
4018
+ Notation filter_length := length_filter (only parsing).
4019
+ Notation filter_length_le := length_filter_le (only parsing).
4020
+ Notation filter_length_forallb := length_filter_forallb (only parsing).
4021
+ Notation firstn_le_length := length_firstn_le (only parsing).
4022
+ Notation firstn_length_le := length_firstn_eq (only parsing).
4023
+ Notation repeat_length := length_repeat (only parsing).
4024
+ Notation flat_map_constant_length := length_flat_map_constant (only parsing).
4016
4025
(* end hide *)
4017
4026
4018
4027
0 commit comments