diff options
author | Jade Philipoom <jadep@google.com> | 2018-03-07 12:04:48 +0100 |
---|---|---|
committer | jadephilipoom <jade.philipoom@gmail.com> | 2018-04-03 09:00:55 -0400 |
commit | e36523f6d8a34ae8b09aeb77a2533eeb15585443 (patch) | |
tree | 7a265497f3d8ce6396cd03c2272a350a06f1085e /src/Util/ListUtil.v | |
parent | 502825d2ca27215ae92569df02f82a60c30d9769 (diff) |
move some lemmas/hints to ListUtil
Diffstat (limited to 'src/Util/ListUtil.v')
-rw-r--r-- | src/Util/ListUtil.v | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Util/ListUtil.v b/src/Util/ListUtil.v index 68cc6a41f..081ef54b5 100644 --- a/src/Util/ListUtil.v +++ b/src/Util/ListUtil.v @@ -30,6 +30,7 @@ Create HintDb simpl_skipn discriminated. Create HintDb simpl_fold_right discriminated. Create HintDb simpl_sum_firstn discriminated. Create HintDb push_map discriminated. +Create HintDb push_combine discriminated. Create HintDb push_flat_map discriminated. Create HintDb push_fold_right discriminated. Create HintDb push_partition discriminated. @@ -41,6 +42,7 @@ Create HintDb pull_firstn discriminated. Create HintDb push_firstn discriminated. Create HintDb pull_skipn discriminated. Create HintDb push_skipn discriminated. +Create HintDb push_sum discriminated. Create HintDb pull_update_nth discriminated. Create HintDb push_update_nth discriminated. Create HintDb znonzero discriminated. @@ -94,6 +96,7 @@ Module Export List. Proof. induction n; simpl List.repeat; simpl map; congruence. Qed. End Map. Hint Rewrite @map_cons @map_nil @map_repeat : push_map. + Hint Rewrite @map_app : push_map. Section FlatMap. Lemma flat_map_nil {A B} (f:A->list B) : List.flat_map f (@nil A) = nil. @@ -923,6 +926,10 @@ Proof. induction xs; boring; discriminate. Qed. +Lemma length_tl {A} ls : length (@tl A ls) = (length ls - 1)%nat. +Proof. destruct ls; cbn [tl length]; omega. Qed. +Hint Rewrite @length_tl : distr_length. + Lemma length_snoc : forall {T} xs (x:T), length xs = pred (length (xs++x::nil)). Proof. @@ -932,6 +939,7 @@ Qed. Lemma combine_cons : forall {A B} a b (xs:list A) (ys:list B), combine (a :: xs) (b :: ys) = (a,b) :: combine xs ys. Proof. reflexivity. Qed. +Hint Rewrite @combine_cons : push_combine. Lemma firstn_combine : forall {A B} n (xs:list A) (ys:list B), firstn n (combine xs ys) = combine (firstn n xs) (firstn n ys). @@ -947,6 +955,7 @@ Lemma combine_nil_r : forall {A B} (xs:list A), Proof. induction xs; boring. Qed. +Hint Rewrite @combine_nil_r : push_combine. Lemma skipn_combine : forall {A B} n (xs:list A) (ys:list B), skipn n (combine xs ys) = combine (skipn n xs) (skipn n ys). @@ -1458,9 +1467,15 @@ Hint Rewrite @sum_firstn_app_sum : simpl_sum_firstn. Lemma sum_cons xs x : sum (x :: xs) = (x + sum xs)%Z. Proof. reflexivity. Qed. +Hint Rewrite sum_cons : push_sum. Lemma sum_nil : sum nil = 0%Z. Proof. reflexivity. Qed. +Hint Rewrite sum_nil : push_sum. + +Lemma sum_app x y : sum (x ++ y) = (sum x + sum y)%Z. +Proof. induction x; rewrite ?app_nil_l, <-?app_comm_cons; autorewrite with push_sum; omega. Qed. +Hint Rewrite sum_app : push_sum. Lemma nth_error_skipn : forall {A} n (l : list A) m, nth_error (skipn n l) m = nth_error l (n + m). |