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
23a5f06b
Commit
23a5f06b
authored
3 years ago
by
Robbert Krebbers
Committed by
Michael Sammler
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Tweak proofs.
parent
22ce5591
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/list_numbers.v
+30
-34
30 additions, 34 deletions
theories/list_numbers.v
with
30 additions
and
34 deletions
theories/list_numbers.v
+
30
−
34
View file @
23a5f06b
...
@@ -214,25 +214,27 @@ End sum_list.
...
@@ -214,25 +214,27 @@ End sum_list.
(** ** Properties of the [Z_to_little_endian] and [Z_of_little_endian] functions *)
(** ** Properties of the [Z_to_little_endian] and [Z_of_little_endian] functions *)
Section
Z_little_endian
.
Section
Z_little_endian
.
Local
Open
Scope
Z_scope
.
Local
Open
Scope
Z_scope
.
Implicit
Types
n
m
:
nat
.
Implicit
Types
z
:
Z
.
Lemma
Z_to_of_little_endian
m
n
bs
:
Lemma
Z_to_of_little_endian
m
n
bs
:
m
=
length
bs
→
0
≤
n
→
m
=
length
bs
→
0
≤
n
→
Forall
(
λ
b
,
0
≤
b
<
2
^
n
)
bs
→
Forall
(
λ
b
,
0
≤
b
<
2
^
n
)
bs
→
Z_to_little_endian
m
n
(
Z_of_little_endian
n
bs
)
=
bs
.
Z_to_little_endian
m
n
(
Z_of_little_endian
n
bs
)
=
bs
.
Proof
.
Proof
.
intros
->
?
Hall
.
induction
Hall
as
[|
b
bs
?
?
IH
];
[
done
|];
csimpl
.
intros
->
?
.
induction
1
as
[|
b
bs
?
?
IH
];
[
done
|];
csimpl
.
f_equal
.
f_equal
.
-
apply
Z
.
bits_inj_iff'
.
intros
n
'
?
.
-
apply
Z
.
bits_inj_iff'
.
intros
z
'
?
.
rewrite
!
Z
.
land_spec
,
Z
.
lor_spec
,
Z_ones_spec
by
lia
.
rewrite
!
Z
.
land_spec
,
Z
.
lor_spec
,
Z_ones_spec
by
lia
.
case_decide
.
case_
bool_
decide
.
+
rewrite
andb_true_r
,
Z
.
shiftl_spec_low
,
orb_false_r
by
lia
.
done
.
+
rewrite
andb_true_r
,
Z
.
shiftl_spec_low
,
orb_false_r
by
lia
.
done
.
+
rewrite
!
andb_false_r
by
lia
.
+
rewrite
andb_false_r
.
symmetry
.
eapply
(
Z_bounded_iff_bits_nonneg
n
);
lia
.
symmetry
.
eapply
(
Z_bounded_iff_bits_nonneg
n
);
lia
.
-
rewrite
<-
IH
at
3
.
f_equal
.
-
rewrite
<-
IH
at
3
.
f_equal
.
apply
Z
.
bits_inj_iff'
.
intros
n
'
?
.
apply
Z
.
bits_inj_iff'
.
intros
z
'
?
.
rewrite
Z
.
shiftr_spec
,
Z
.
lor_spec
,
Z
.
shiftl_spec
by
lia
.
rewrite
Z
.
shiftr_spec
,
Z
.
lor_spec
,
Z
.
shiftl_spec
by
lia
.
assert
(
Z
.
testbit
b
(
n'
+
n
)
=
false
)
as
->
.
{
assert
(
Z
.
testbit
b
(
z'
+
n
)
=
false
)
as
->
.
eapply
(
Z_bounded_iff_bits_nonneg
n
);
lia
.
{
apply
(
Z_bounded_iff_bits_nonneg
n
);
lia
.
}
}
rewrite
orb_false_l
.
f_equal
.
lia
.
rewrite
orb_false_l
.
f_equal
.
lia
.
Qed
.
Qed
.
...
@@ -240,28 +242,28 @@ Section Z_little_endian.
...
@@ -240,28 +242,28 @@ Section Z_little_endian.
0
≤
n
→
0
≤
n
→
Z_of_little_endian
n
(
Z_to_little_endian
m
n
z
)
=
z
`
mod
`
2
^
(
m
*
n
)
.
Z_of_little_endian
n
(
Z_to_little_endian
m
n
z
)
=
z
`
mod
`
2
^
(
m
*
n
)
.
Proof
.
Proof
.
intros
.
rewrite
<-
Z
.
land_ones
by
n
ia
.
intros
.
rewrite
<-
Z
.
land_ones
by
l
ia
.
revert
z
.
induction
m
as
[|
m
IH
];
simpl
.
revert
z
.
induction
m
as
[|
m
IH
];
intros
z
;
simpl
.
{
intros
.
Z
.
bitwise
.
by
rewrite
andb_false_r
.
}
{
Z
.
bitwise
.
by
rewrite
andb_false_r
.
}
intros
z
.
rewrite
IH
.
rewrite
IH
.
apply
Z
.
bits_inj_iff'
.
intros
n
'
?
.
apply
Z
.
bits_inj_iff'
.
intros
z
'
?
.
rewrite
Z
.
land_spec
,
Z
.
lor_spec
,
Z
.
shiftl_spec
,
!
Z
.
land_spec
by
lia
.
rewrite
Z
.
land_spec
,
Z
.
lor_spec
,
Z
.
shiftl_spec
,
!
Z
.
land_spec
by
lia
.
rewrite
(
Z_ones_spec
n
n
'
)
by
lia
.
case_bool_decide
.
rewrite
(
Z_ones_spec
n
z
'
)
by
lia
.
case_bool_decide
.
-
rewrite
andb_true_r
.
rewrite
(
Z
.
testbit_neg_r
_
(
n
'
-
n
)),
orb_false_r
by
lia
.
simpl
.
-
rewrite
andb_true_r
,
(
Z
.
testbit_neg_r
_
(
z
'
-
n
)),
orb_false_r
by
lia
.
simpl
.
rewrite
Z_ones_spec
by
nia
.
case_bool_decide
;
[
by
rewrite
andb_true_r
|
n
ia
]
.
by
rewrite
Z_ones_spec
,
bool_decide_true
,
andb_true_r
by
l
ia
.
-
rewrite
andb_false_r
,
orb_false_l
.
-
rewrite
andb_false_r
,
orb_false_l
.
rewrite
Z
.
shiftr_spec
by
lia
.
f_equal
.
{
f_equal
.
lia
.
}
rewrite
Z
.
shiftr_spec
by
lia
.
f_equal
;
[
f_equal
;
lia
|]
.
rewrite
!
Z_ones_spec
by
n
ia
.
apply
bool_decide_iff
.
n
ia
.
rewrite
!
Z_ones_spec
by
l
ia
.
apply
bool_decide_iff
.
l
ia
.
Qed
.
Qed
.
Lemma
Z_to_little_endian_bound
m
n
z
:
Lemma
Z_to_little_endian_bound
m
n
z
:
0
≤
n
→
0
≤
n
→
Forall
(
λ
b
,
0
≤
b
<
2
^
n
)
(
Z_to_little_endian
m
n
z
)
.
Forall
(
λ
b
,
0
≤
b
<
2
^
n
)
(
Z_to_little_endian
m
n
z
)
.
Proof
.
Proof
.
intros
?
.
revert
z
.
induction
m
as
[|
m
IH
];
simpl
.
intros
?
.
revert
z
.
induction
m
as
[|
m
IH
];
intros
z
;
simpl
.
{
by
constructor
.
}
{
by
constructor
.
}
intros
?
.
constructor
;
[|
by
apply
IH
]
.
rewrite
Z
.
land_ones
by
lia
.
constructor
;
[|
by
apply
IH
]
.
rewrite
Z
.
land_ones
by
lia
.
apply
Z
.
mod_pos_bound
.
apply
Z
.
pow_pos_nonneg
;
lia
.
apply
Z
.
mod_pos_bound
,
Z
.
pow_pos_nonneg
;
lia
.
Qed
.
Qed
.
Lemma
Z_of_little_endian_bound
n
bs
:
Lemma
Z_of_little_endian_bound
n
bs
:
...
@@ -269,18 +271,12 @@ Section Z_little_endian.
...
@@ -269,18 +271,12 @@ Section Z_little_endian.
Forall
(
λ
b
,
0
≤
b
<
2
^
n
)
bs
→
Forall
(
λ
b
,
0
≤
b
<
2
^
n
)
bs
→
0
≤
Z_of_little_endian
n
bs
<
2
^
(
length
bs
*
n
)
.
0
≤
Z_of_little_endian
n
bs
<
2
^
(
length
bs
*
n
)
.
Proof
.
Proof
.
intros
?
Hall
.
intros
?
.
induction
1
as
[|
b
bs
Hb
?
IH
];
[
done
|];
simpl
.
induction
Hall
as
[|
b
bs
Hb
?
IH
];
[
done
|];
simpl
.
apply
Z_bounded_iff_bits_nonneg'
;
[
lia
|..]
.
apply
Z_bounded_iff_bits_nonneg'
;
[
nia
|
|]
.
{
apply
Z
.
lor_nonneg
.
split
;
[
lia
|]
.
apply
Z
.
shiftl_nonneg
.
lia
.
}
-
apply
Z
.
lor_nonneg
.
split
;
[
lia
|]
.
apply
Z
.
shiftl_nonneg
.
lia
.
intros
z'
?
.
rewrite
Z
.
lor_spec
.
-
intros
l
?
.
rewrite
Z
.
lor_spec
.
rewrite
Z_bounded_iff_bits_nonneg'
in
Hb
by
lia
.
eapply
Z_bounded_iff_bits_nonneg'
in
Hb
.
rewrite
Hb
,
orb_false_l
,
Z
.
shiftl_spec
by
lia
.
+
erewrite
Hb
,
orb_false_l
.
apply
(
Z_bounded_iff_bits_nonneg'
(
length
bs
*
n
));
lia
.
rewrite
Z
.
shiftl_spec
by
nia
.
eapply
Z_bounded_iff_bits_nonneg'
;
[|
|
done
|];
nia
.
+
lia
.
+
lia
.
+
nia
.
Qed
.
Qed
.
Local
Close
Scope
Z_scope
.
End
Z_little_endian
.
End
Z_little_endian
.
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