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
Package Registry
Model registry
Operate
Terraform modules
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
Adam
stdpp
Commits
e3c9027e
Commit
e3c9027e
authored
5 years ago
by
Simon Spies
Committed by
Robbert Krebbers
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
SeqZ Function
parent
8dfc9983
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theories/list.v
+57
-0
57 additions, 0 deletions
theories/list.v
theories/numbers.v
+7
-0
7 additions, 0 deletions
theories/numbers.v
with
64 additions
and
0 deletions
theories/list.v
+
57
−
0
View file @
e3c9027e
...
...
@@ -394,6 +394,13 @@ used by [positives_flatten]. *)
Definition
positives_unflatten
(
p
:
positive
)
:
option
(
list
positive
)
:=
positives_unflatten_go
p
[]
1
.
(** [seqZ m n] generates the sequence [m], [m + 1], ..., [m + n - 1]
over integers, provided [n >= 0]. If n < 0, then the range is empty. **)
Definition
seqZ
(
m
len
:
Z
)
:
list
Z
:=
(
λ
i
:
nat
,
Z
.
add
i
m
)
<$>
(
seq
0
(
Z
.
to_nat
len
))
.
Arguments
seqZ
:
simpl
never
.
(** * Basic tactics on lists *)
(** The tactic [discriminate_list] discharges a goal if it submseteq
a list equality involving [(::)] and [(++)] of two lists that have a different
...
...
@@ -1460,6 +1467,7 @@ Proof.
rewrite
lookup_seq
by
done
.
intuition
congruence
.
Qed
.
(** ** Properties of the [Permutation] predicate *)
Lemma
Permutation_nil
l
:
l
≡
ₚ
[]
↔
l
=
[]
.
Proof
.
split
.
by
intro
;
apply
Permutation_nil
.
by
intros
->
.
Qed
.
...
...
@@ -3345,6 +3353,55 @@ Section mapM.
Proof
.
eauto
using
mapM_fmap_Forall2_Some_inv
,
Forall2_true
,
mapM_length
.
Qed
.
End
mapM
.
(** ** Properties of the [seqZ] function *)
Section
seqZ
.
Implicit
Types
(
m
n
:
Z
)
(
i
j
:
nat
)
.
Local
Open
Scope
Z
.
Lemma
seqZ_nil
m
n
:
n
≤
0
→
seqZ
m
n
=
[]
.
Proof
.
by
destruct
n
.
Qed
.
Lemma
seqZ_cons
m
n
:
0
<
n
→
seqZ
m
n
=
m
::
seqZ
(
Z
.
succ
m
)
(
Z
.
pred
n
)
.
Proof
.
intros
H
.
unfold
seqZ
.
replace
n
with
(
Z
.
succ
(
Z
.
pred
n
))
at
1
by
lia
.
rewrite
Z2Nat
.
inj_succ
by
lia
.
f_equal
/=.
rewrite
<-
fmap_seq
,
<-
list_fmap_compose
.
apply
map_ext
;
naive_solver
lia
.
Qed
.
Lemma
seqZ_length
m
n
:
length
(
seqZ
m
n
)
=
Z
.
to_nat
n
.
Proof
.
unfold
seqZ
;
by
rewrite
fmap_length
,
seq_length
.
Qed
.
Lemma
seqZ_fmap
m
m'
n
:
Z
.
add
m
<$>
seqZ
m'
n
=
seqZ
(
m
+
m'
)
n
.
Proof
.
revert
m'
.
induction
n
as
[|
n
?
IH
|]
using
(
Z_succ_pred_induction
0
);
intros
m'
.
-
by
rewrite
seqZ_nil
.
-
rewrite
(
seqZ_cons
m'
)
by
lia
.
rewrite
(
seqZ_cons
(
m
+
m'
))
by
lia
.
f_equal
/=.
rewrite
Z
.
pred_succ
,
IH
;
simpl
.
f_equal
;
lia
.
-
by
rewrite
!
seqZ_nil
by
lia
.
Qed
.
Lemma
seqZ_lookup_lt
m
n
i
:
i
<
n
→
seqZ
m
n
!!
i
=
Some
(
m
+
i
)
.
Proof
.
revert
m
i
.
induction
n
as
[|
n
?
IH
|]
using
(
Z_succ_pred_induction
0
);
intros
m
i
Hi
;
try
lia
.
rewrite
seqZ_cons
by
lia
.
destruct
i
as
[|
i
];
simpl
.
-
f_equal
;
lia
.
-
rewrite
Z
.
pred_succ
,
IH
by
lia
.
f_equal
;
lia
.
Qed
.
Lemma
seqZ_lookup_ge
m
n
i
:
n
≤
i
→
seqZ
m
n
!!
i
=
None
.
Proof
.
revert
m
i
.
induction
n
as
[|
n
?
IH
|]
using
(
Z_succ_pred_induction
0
);
intros
m
i
Hi
;
try
lia
.
-
by
rewrite
seqZ_nil
.
-
rewrite
seqZ_cons
by
lia
.
destruct
i
as
[|
i
];
simpl
;
[
lia
|]
.
by
rewrite
Z
.
pred_succ
,
IH
by
lia
.
-
by
rewrite
seqZ_nil
by
lia
.
Qed
.
Lemma
seqZ_lookup
m
n
i
m'
:
seqZ
m
n
!!
i
=
Some
m'
↔
m'
=
m
+
i
∧
i
<
n
.
Proof
.
destruct
(
Z_le_gt_dec
n
i
)
.
{
rewrite
seqZ_lookup_ge
by
lia
.
naive_solver
lia
.
}
rewrite
seqZ_lookup_lt
by
lia
.
naive_solver
lia
.
Qed
.
End
seqZ
.
(** ** Properties of the [permutations] function *)
Section
permutations
.
Context
{
A
:
Type
}
.
...
...
This diff is collapsed.
Click to expand it.
theories/numbers.v
+
7
−
0
View file @
e3c9027e
...
...
@@ -467,6 +467,13 @@ Proof.
apply
Nat
.
mod_bound_pos
;
lia
.
}
by
rewrite
<-
Nat2Z
.
inj_mul
,
<-
Nat2Z
.
inj_add
,
<-
Nat
.
div_mod
.
Qed
.
Lemma
Z_succ_pred_induction
y
(
P
:
Z
→
Prop
)
:
P
y
→
(
∀
x
,
y
≤
x
→
P
x
→
P
(
Z
.
succ
x
))
→
(
∀
x
,
x
≤
y
→
P
x
→
P
(
Z
.
pred
x
))
→
(
∀
x
,
P
x
)
.
Proof
.
intros
H0
HS
HP
.
by
apply
(
Z
.
order_induction'
_
_
y
)
.
Qed
.
Close
Scope
Z_scope
.
(** * Injectivity of casts *)
...
...
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