Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stdpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Iris
stdpp
Commits
55e93ffd
Commit
55e93ffd
authored
1 month ago
by
Robbert Krebbers
Committed by
Marijn van Wezel
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Renames and make use of `set_solver` to shorten proof.
parent
7f43d3f2
No related branches found
Branches containing commit
No related tags found
1 merge request
!584
Add lemma `StronglySorted_app_iff`
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stdpp/sorting.v
+19
-31
19 additions, 31 deletions
stdpp/sorting.v
with
19 additions
and
31 deletions
stdpp/sorting.v
+
19
−
31
View file @
55e93ffd
(** Merge sort. Adapted from the implementation of Hugo Herbelin in the Coq
standard library, but without using the module system. *)
From
Coq
Require
Export
Sorted
.
From
stdpp
Require
Export
orders
list
.
From
stdpp
Require
Export
orders
list
sets
.
From
stdpp
Require
Import
options
.
Section
merge_sort
.
...
...
@@ -48,48 +48,36 @@ Inductive TlRel {A} (R : relation A) (a : A) : list A → Prop :=
Section
sorted
.
Context
{
A
}
(
R
:
relation
A
)
.
Lemma
StronglySorted_app_iff
l1
l2
:
StronglySorted
R
(
l1
++
l2
)
↔
Lemma
StronglySorted_cons
l
x
:
StronglySorted
R
(
x
::
l
)
↔
Forall
(
R
x
)
l
∧
StronglySorted
R
l
.
Proof
.
split
;
[
inv
1
|
constructor
];
naive_solver
.
Qed
.
Lemma
StronglySorted_app
l1
l2
:
StronglySorted
R
(
l1
++
l2
)
↔
(
∀
x1
x2
,
x1
∈
l1
→
x2
∈
l2
→
R
x1
x2
)
∧
StronglySorted
R
l1
∧
StronglySorted
R
l2
.
Proof
.
induction
l1
as
[|
x1'
l1
IH
];
simpl
;
split
.
-
intros
Hs
.
repeat
split
;
[|
constructor
|
naive_solver
]
.
by
setoid_rewrite
elem_of_nil
.
-
naive_solver
.
-
intros
[
Hs
Hall
]
%
StronglySorted_inv
.
split
.
*
intros
?
?
Hinl1
Hinl2
.
apply
elem_of_cons
in
Hinl1
as
[
Hinl1
|
Hinl1
]
.
+
subst
.
apply
Forall_app
in
Hall
as
[_
Hall
]
.
rewrite
Forall_forall
in
Hall
.
by
apply
Hall
.
+
apply
IH
in
Hs
as
(
HR
&
?
&
?)
.
by
apply
HR
.
*
repeat
split
;
[
apply
SSorted_cons
|];
apply
IH
in
Hs
.
+
naive_solver
.
+
apply
Forall_app
in
Hall
;
naive_solver
.
+
naive_solver
.
-
intros
(
HR
&
[?
?]
%
StronglySorted_inv
&
?)
.
apply
SSorted_cons
.
*
apply
IH
;
[|
done
..]
.
repeat
split
;
[|
done
..]
.
intros
;
apply
HR
;
[|
done
]
.
apply
elem_of_cons
.
naive_solver
.
*
rewrite
Forall_app
;
split
;
[
done
|]
.
rewrite
Forall_forall
.
intros
;
apply
HR
;
[|
done
]
.
apply
elem_of_cons
.
naive_solver
.
induction
l1
as
[|
x1'
l1
IH
];
simpl
.
-
set_solver
by
eauto
using
SSorted_nil
.
-
rewrite
!
StronglySorted_cons
,
IH
,
!
Forall_forall
.
set_solver
.
Qed
.
Lemma
StronglySorted_app
l1
l2
:
Lemma
StronglySorted_app
_2
l1
l2
:
(
∀
x1
x2
,
x1
∈
l1
→
x2
∈
l2
→
R
x1
x2
)
→
StronglySorted
R
l1
→
StronglySorted
R
l2
→
StronglySorted
R
(
l1
++
l2
)
.
Proof
.
by
rewrite
StronglySorted_app
_iff
.
Qed
.
Lemma
elem_of_
StronglySorted_app
l1
l2
x1
x2
:
Proof
.
by
rewrite
StronglySorted_app
.
Qed
.
Lemma
StronglySorted_app
_1_elem_of
l1
l2
x1
x2
:
StronglySorted
R
(
l1
++
l2
)
→
x1
∈
l1
→
x2
∈
l2
→
R
x1
x2
.
Proof
.
rewrite
StronglySorted_app
_iff
.
naive_solver
.
Qed
.
Lemma
StronglySorted_app_
inv
_l
l1
l2
:
Proof
.
rewrite
StronglySorted_app
.
naive_solver
.
Qed
.
Lemma
StronglySorted_app_
1
_l
l1
l2
:
StronglySorted
R
(
l1
++
l2
)
→
StronglySorted
R
l1
.
Proof
.
rewrite
StronglySorted_app
_iff
.
naive_solver
.
Qed
.
Lemma
StronglySorted_app_
inv
_r
l1
l2
:
Proof
.
rewrite
StronglySorted_app
.
naive_solver
.
Qed
.
Lemma
StronglySorted_app_
1
_r
l1
l2
:
StronglySorted
R
(
l1
++
l2
)
→
StronglySorted
R
l2
.
Proof
.
rewrite
StronglySorted_app
_iff
.
naive_solver
.
Qed
.
Proof
.
rewrite
StronglySorted_app
.
naive_solver
.
Qed
.
Lemma
Sorted_StronglySorted
`{
!
Transitive
R
}
l
:
Sorted
R
l
→
StronglySorted
R
l
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment