Skip to content

Commit

Permalink
Rename ListUtil.map2 => ListUtil.List.map2
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross committed Dec 4, 2023
1 parent ed16598 commit 0d06cdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/Util/ListUtil.v
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,19 @@ Module Export List.
(** new operations *)
Definition enumerate {A} (ls : list A) : list (nat * A)
:= combine (seq 0 (length ls)) ls.

Section map2.
Context {A B C}
(f : A -> B -> C).

Fixpoint map2 (la : list A) (lb : list B) : list C :=
match la, lb with
| nil, _ => nil
| _, nil => nil
| a :: la', b :: lb'
=> f a b :: map2 la' lb'
end.
End map2.
End List.

#[global]
Expand Down Expand Up @@ -371,19 +384,6 @@ Definition sum_firstn l n := fold_right Z.add 0%Z (firstn n l).

Definition sum xs := sum_firstn xs (length xs).

Section map2.
Context {A B C}
(f : A -> B -> C).

Fixpoint map2 (la : list A) (lb : list B) : list C :=
match la, lb with
| nil, _ => nil
| _, nil => nil
| a :: la', b :: lb'
=> f a b :: map2 la' lb'
end.
End map2.

(* xs[n] := f xs[n] *)
Fixpoint update_nth {T} n f (xs:list T) {struct n} :=
match n with
Expand Down Expand Up @@ -3481,7 +3481,7 @@ Module Reifiable.
intros H. induction l as [| x' l'].
- simpl in H. destruct H.
- simpl in H. destruct H as [H|H].
+ rewrite H. clear H. simpl. destruct (existsb (eqb x) (nodupb l')) eqn:E.
+ rewrite H. clear H. simpl. destruct (existsb (eqb x) (nodupb l')) eqn:E.
-- rewrite existsb_eqb_true_iff in E. rewrite <- nodupb_in_iff in E.
apply IHl' in E. apply E.
-- exists []. exists (nodupb l'). split.
Expand Down
4 changes: 2 additions & 2 deletions src/Util/Tuple.v
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Proof using Type.
Qed.

Lemma to_list_map2 {A B C n xs ys} (f : A -> B -> C)
: ListUtil.map2 f (@to_list A n xs) (@to_list B n ys) = @to_list C n (map2 f xs ys).
: List.map2 f (@to_list A n xs) (@to_list B n ys) = @to_list C n (map2 f xs ys).
Proof using Type.
tuples_from_lists; unfold map2, on_tuple2.
repeat (rewrite to_list_from_list || rewrite from_list_to_list).
Expand Down Expand Up @@ -388,7 +388,7 @@ Proof using Type.
destruct lxs as [|x' lxs']; [simpl in *; discriminate|].
let lys := match goal with lxs : list B |- _ => lxs end in
destruct lys as [|y' lys']; [simpl in *; discriminate|].
change ( f x y :: ListUtil.map2 f (to_list (S n) (from_list (S n) (x' :: lxs') x1))
change ( f x y :: List.map2 f (to_list (S n) (from_list (S n) (x' :: lxs') x1))
(to_list (S n) (from_list (S n) (y' :: lys') x0)) = f x y :: to_list (S n) (map2 f (from_list (S n) (x' :: lxs') x1) (from_list (S n) (y' :: lys') x0)) ).
tuple_maps_to_list_maps.
reflexivity.
Expand Down

0 comments on commit 0d06cdf

Please sign in to comment.