Skip to content

Commit

Permalink
Merge pull request #21 from pi8027/sorted_filter_sort
Browse files Browse the repository at this point in the history
Add sorted_filter_sort (taken from #20)
  • Loading branch information
pi8027 authored Feb 27, 2024
2 parents 4fea401 + 5add817 commit 7f03fa6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions theories/stablesort.v
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,21 @@ move=> /in2_sig leT_total /in3_sig leT_tr p _ /all_sigP[s ->].
by rewrite !(sort_map, filter_map) filter_sort.
Qed.

Lemma sorted_filter_sort (T : Type) (leT : rel T) :
total leT -> transitive leT ->
forall (p : pred T) (s : seq T),
sorted leT (filter p s) -> filter p (sort _ leT s) = filter p s.
Proof. by move=> *; rewrite filter_sort// sorted_sort. Qed.

Lemma sorted_filter_sort_in (T : Type) (P : {pred T}) (leT : rel T) :
{in P &, total leT} -> {in P & &, transitive leT} ->
forall (p : pred T) (s : seq T),
all P s -> sorted leT (filter p s) -> filter p (sort _ leT s) = filter p s.
Proof.
move=> /in2_sig leT_total /in3_sig leT_tr p _ /all_sigP[s ->].
by rewrite sort_map !filter_map sorted_map /= => /sorted_filter_sort ->.
Qed.

Lemma sort_sort (T : Type) (leT leT' : rel T) :
total leT -> transitive leT -> total leT' -> transitive leT' ->
forall s : seq T, sort _ leT (sort _ leT' s) = sort _ (lexord leT leT') s.
Expand Down Expand Up @@ -1412,6 +1427,8 @@ Arguments mem_sort sort {T} leT s _.
Arguments sort_uniq sort {T} leT s.
Arguments filter_sort sort {T leT} leT_total leT_tr p s.
Arguments filter_sort_in sort {T P leT} leT_total leT_tr p {s} _.
Arguments sorted_filter_sort sort {T leT} leT_total leT_tr p {s} _.
Arguments sorted_filter_sort_in sort {T P leT} leT_total leT_tr p {s} _ _.
Arguments sort_sort sort {T leT leT'}
leT_total leT_tr leT'_total leT'_tr s.
Arguments sort_sort_in sort {T P leT leT'}
Expand Down

0 comments on commit 7f03fa6

Please sign in to comment.