Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROSA - Formally Proven Schedulability Analysis
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
Environments
Terraform modules
Monitor
Incidents
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
Lasse Blaauwbroek
PROSA - Formally Proven Schedulability Analysis
Commits
d7582402
Commit
d7582402
authored
3 years ago
by
Sergey Bozhko
Browse files
Options
Downloads
Patches
Plain Diff
add comments to file [util/div_mod.v]
parent
bc38ff74
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
util/div_mod.v
+30
-25
30 additions, 25 deletions
util/div_mod.v
with
30 additions
and
25 deletions
util/div_mod.v
+
30
−
25
View file @
d7582402
Require
Export
prosa
.
util
.
nat
prosa
.
util
.
subadditivity
.
From
mathcomp
Require
Export
ssreflect
ssrbool
eqtype
ssrnat
seq
fintype
bigop
div
ssrfun
.
Definition
div_floor
(
x
y
:
nat
)
:
nat
:=
x
%/
y
.
Definition
div_ceil
(
x
y
:
nat
)
:=
if
y
%|
x
then
x
%/
y
else
(
x
%/
y
).
+
1
.
(** First, we define functions [div_floor] and [div_ceil], which are
divisions rounded down and up, respectively. *)
Definition
div_floor
(
x
y
:
nat
)
:
nat
:=
x
%/
y
.
Definition
div_ceil
(
x
y
:
nat
)
:=
if
y
%|
x
then
x
%/
y
else
(
x
%/
y
).
+
1
.
Lemma
mod_elim
:
forall
a
b
c
,
c
>
0
->
b
<
c
->
(
a
+
c
-
b
)
%%
c
=
if
a
%%
c
>=
b
then
(
a
%%
c
-
b
)
else
(
a
%%
c
+
c
-
b
)
.
Proof
.
intros
*
CP
BC
.
have
G
:
a
%%
c
<
c
by
apply
ltn_pmod
.
case
(
b
<=
a
%%
c
)
eqn
:
CASE
;
rewrite
-
addnBA
;
auto
;
rewrite
-
modnDml
.
-
rewrite
addnABC
;
auto
.
rewrite
-
modnDmr
modnn
addn0
modn_small
;
auto
;
ssrlia
.
-
rewrite
modn_small
;
try
ssrlia
.
Qed
.
(** We show that for any two integers [a] and [c],
[a] is less than [a %/ c * c + c] given that [c] is positive. *)
(** We show that for any two integers [a] and [b],
[a] is less than [a %/ b * b + b] given that [b] is positive. *)
Lemma
div_floor_add_g
:
forall
a
c
,
c
>
0
->
a
<
a
%/
c
*
c
+
c
.
forall
a
b
,
b
>
0
->
a
<
a
%/
b
*
b
+
b
.
Proof
.
intros
*
POS
.
specialize
(
divn_eq
a
c
)
=>
DIV
.
specialize
(
divn_eq
a
b
)
=>
DIV
.
rewrite
[
in
X
in
X
<
_]
DIV
.
rewrite
ltn_add2l
.
now
apply
ltn_pmod
.
by
apply
ltn_pmod
.
Qed
.
(** We show that the division with ceiling by a constant [T] is a subadditive function. *)
Lemma
div_ceil_subadditive
:
forall
T
,
subadditive
(
div_ceil
^~
T
)
.
forall
T
,
subadditive
(
div_ceil
^~
T
)
.
Proof
.
move
=>
T
ab
a
b
SUM
.
rewrite
-
SUM
.
...
...
@@ -54,3 +41,21 @@ Proof.
apply
leq_ltn_trans
with
(
a
%/
T
+
b
%/
T
+
1
);
last
by
ssrlia
.
by
apply
leq_divDl
.
Qed
.
(** We prove a technical lemma stating that for any three integers [a,
b, c] such that [c > b], [mod] can be swapped with subtraction in
the expression [(a + c - b) %% c]. *)
Lemma
mod_elim
:
forall
a
b
c
,
c
>
b
->
(
a
+
c
-
b
)
%%
c
=
if
a
%%
c
>=
b
then
(
a
%%
c
-
b
)
else
(
a
%%
c
+
c
-
b
)
.
Proof
.
intros
*
BC
.
have
POS
:
c
>
0
by
ssrlia
.
have
G
:
a
%%
c
<
c
by
apply
ltn_pmod
.
case
(
b
<=
a
%%
c
)
eqn
:
CASE
;
rewrite
-
addnBA
;
auto
;
rewrite
-
modnDml
.
-
rewrite
addnABC
;
auto
.
by
rewrite
-
modnDmr
modnn
addn0
modn_small
;
auto
;
ssrlia
.
-
by
rewrite
modn_small
;
ssrlia
.
Qed
.
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