Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Actris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Dan Frumin
Actris
Commits
2ce7a89e
Commit
2ce7a89e
authored
4 years ago
by
Jonas Kastberg
Browse files
Options
Downloads
Patches
Plain Diff
Improved structure of proof
parent
5d08f0e8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/examples/swap_mapper.v
+171
-85
171 additions, 85 deletions
theories/examples/swap_mapper.v
with
171 additions
and
85 deletions
theories/examples/swap_mapper.v
+
171
−
85
View file @
2ce7a89e
...
...
@@ -23,140 +23,193 @@ Section with_Σ.
ProtoUnfold
(
mapper_prot
)
(
mapper_prot_aux
mapper_prot
)
.
Proof
.
apply
proto_unfold_eq
,
(
fixpoint_unfold
mapper_prot_aux
)
.
Qed
.
Definition
map
per_prot_twice
:=
Definition
map
_once
prot
:=
(
<!>
MSG
(
LitV
$
true
);
<!
(
x1
:
T
)
(
v1
:
val
)
>
MSG
v1
{{
IT
x1
v1
}};
<
?
(
w1
:
val
)
>
MSG
w1
{{
IU
(
f
x1
)
w1
}};
<!>
MSG
(
LitV
$
true
);
<!
(
x2
:
T
)
(
v2
:
val
)
>
MSG
v2
{{
IT
x2
v2
}};
<
?
(
w2
:
val
)
>
MSG
w2
{{
IU
(
f
x2
)
w2
}};
<!>
MSG
(
LitV
$
false
);
END
)
%
proto
.
<!
(
x
:
T
)
(
v
:
val
)
>
MSG
v
{{
IT
x
v
}};
<
?
(
w
:
val
)
>
MSG
w
{{
IU
(
f
x
)
w
}};
prot
)
%
proto
.
Lemma
map_once_mono
prot1
prot2
:
▷
(
prot1
⊑
prot2
)
-∗
map_once
prot1
⊑
map_once
prot2
.
Proof
.
iIntros
"Hsub"
.
rewrite
/
map_once
.
iModIntro
.
iIntros
(
x
v
)
"Hv"
.
iExists
x
,
v
.
iFrame
"Hv"
.
iModIntro
.
iIntros
(
w
)
"Hw"
.
iExists
w
.
iFrame
"Hw"
.
iModIntro
.
iApply
"Hsub"
.
Qed
.
Global
Instance
map_once_from_modal
p1
p2
:
FromModal
(
modality_instances
.
modality_laterN
1
)
(
p1
⊑
p2
)
((
map_once
p1
)
⊑
(
map_once
p2
))
(
p1
⊑
p2
)
.
Proof
.
apply
map_once_mono
.
Qed
.
Definition
mapper_prot_once
:=
(
map_once
mapper_prot
)
%
proto
.
Lemma
subprot_once
:
⊢
mapper_prot
⊑
mapper_prot_once
.
Proof
.
rewrite
/
mapper_prot
/
mapper_prot_once
.
rewrite
fixpoint_unfold
/
mapper_prot_aux
.
rewrite
/
iProto_choice
.
iExists
true
.
iModIntro
.
iApply
iProto_le_refl
.
Qed
.
Definition
mapper_prot_twice
:=
map_once
$
map_once
$
mapper_prot
.
Lemma
subprot_twice
:
⊢
mapper_prot
⊑
mapper_prot_twice
.
Proof
.
iApply
iProto_le_trans
.
{
iApply
subprot_once
.
}
iModIntro
.
iApply
subprot_once
.
Qed
.
Definition
mapper_prot_twice_swap
:=
(
<!>
MSG
(
LitV
$
true
)
{{
True
}}
;
(
<!>
MSG
(
LitV
$
true
);
<!
(
x1
:
T
)
(
v1
:
val
)
>
MSG
v1
{{
IT
x1
v1
}};
<!>
MSG
(
LitV
$
true
)
{{
True
}}
;
<!>
MSG
(
LitV
$
true
);
<!
(
x2
:
T
)
(
v2
:
val
)
>
MSG
v2
{{
IT
x2
v2
}};
<!>
MSG
(
LitV
$
false
)
{{
True
}};
<
?
(
w1
:
val
)
>
MSG
w1
{{
IU
(
f
x1
)
w1
}};
<
?
(
w2
:
val
)
>
MSG
w2
{{
IU
(
f
x2
)
w2
}};
END
)
%
proto
.
mapper_prot
)
%
proto
.
Lemma
subprot_twice
:
Lemma
subprot_twice
_swap
:
⊢
mapper_prot
⊑
mapper_prot_twice_swap
.
Proof
.
rewrite
/
mapper_prot
/
mapper_prot_twice
.
rewrite
fixpoint_unfold
fixpoint_unfold
fixpoint_unfold
/
mapper_prot_aux
.
iApply
(
iProto_le_trans
_
mapper_prot_twice
)
.
{
rewrite
/
iProto_choice
.
iExists
true
.
iModIntro
.
iIntros
(
x1
v1
)
"Hv1"
.
iExists
x1
,
v1
.
iFrame
"Hv1"
.
iModIntro
.
iIntros
(
w1
)
"Hw1"
.
iExists
w1
.
iFrame
"Hw1"
.
iModIntro
.
iExists
true
.
iModIntro
.
iIntros
(
x2
v2
)
"Hv2"
.
iExists
x2
,
v2
.
iFrame
"Hv2"
.
iModIntro
.
iIntros
(
w2
)
"Hw2"
.
iExists
w2
.
iFrame
"Hw2"
.
iModIntro
.
iExists
false
.
eauto
.
}
rewrite
/
mapper_prot_twice
/
mapper_prot_twice_swap
.
iApply
iProto_le_trans
.
{
iApply
subprot_twice
.
}
iModIntro
.
iIntros
(
x1
v1
)
"Hv1"
.
iExists
x1
,
v1
.
iFrame
"Hv1"
.
iModIntro
.
iIntros
(
w1
)
"Hw1"
.
iApply
(
iProto_le_trans
);
first
by
iApply
iProto_le_base_swap
.
iApply
iProto_le_trans
.
{
iApply
iProto_le_base_swap
.
}
iModIntro
.
iIntros
(
x2
v2
)
"Hv2"
.
iApply
(
iProto_le_trans
with
"[Hv2]"
)
.
{
iModIntro
.
iExists
x2
,
v2
.
iFrame
"Hv2"
.
iModIntro
.
iApply
iProto_le_refl
.
}
iApply
(
iProto_le_trans
)
.
{
iModIntro
.
iExists
x2
,
v2
.
iFrame
"Hv2"
.
iApply
iProto_le_refl
.
}
iApply
iProto_le_trans
.
{
iApply
iProto_le_base_swap
.
}
iModIntro
.
iExists
(
w1
)
.
iFrame
"Hw1"
.
iModIntro
.
iApply
iProto_le_refl
.
Qed
.
Definition
mapper_prot_twice_swap_end
:=
(
<!>
MSG
(
LitV
$
true
);
<!
(
x1
:
T
)
(
v1
:
val
)
>
MSG
v1
{{
IT
x1
v1
}};
<!>
MSG
(
LitV
$
true
);
<!
(
x2
:
T
)
(
v2
:
val
)
>
MSG
v2
{{
IT
x2
v2
}};
<!>
MSG
(
LitV
$
false
);
<
?
(
w1
:
val
)
>
MSG
w1
{{
IU
(
f
x1
)
w1
}};
<
?
(
w2
:
val
)
>
MSG
w2
{{
IU
(
f
x2
)
w2
}};
END
)
%
proto
.
Lemma
subprot_twice_swap_end
:
⊢
mapper_prot
⊑
mapper_prot_twice_swap_end
.
Proof
.
iApply
iProto_le_trans
.
{
iApply
subprot_twice_swap
.
}
rewrite
/
mapper_prot_twice_swap
/
mapper_prot_twice_swap_end
.
iModIntro
.
iIntros
(
x1
v1
)
"Hv1"
.
iExists
x1
,
v1
.
iFrame
"Hv1"
.
iModIntro
.
iModIntro
.
iIntros
(
x2
v2
)
"Hv2"
.
iExists
x2
,
v2
.
iFrame
"Hv2"
.
iModIntro
.
iApply
iProto_le_trans
.
{
iModIntro
.
iIntros
(
w2
)
"Hw2"
.
{
iIntros
(
w1
)
"Hw1"
.
iExists
w1
.
iSplitL
.
iExact
"Hw1"
.
iModIntro
.
iIntros
(
w2
)
"Hw2"
.
iExists
w2
.
iSplitL
.
iExact
"Hw2"
.
iModIntro
.
rewrite
/
mapper_prot
fixpoint_unfold
/
mapper_prot_aux
/
iProto_choice
.
iExists
false
.
iApply
iProto_le_refl
.
}
iApply
iProto_le_trans
.
{
iIntros
(
w1
)
"Hw1"
.
iExists
w1
.
iSplitL
.
iExact
"Hw1"
.
iModIntro
.
iIntros
(
w2
)
"Hw2"
.
iApply
iProto_le_trans
.
{
iApply
iProto_le_base_swap
.
}
iModIntro
.
iExists
(
w2
)
.
iSplitL
.
iExact
"Hw2"
.
iApply
iProto_le_refl
.
}
iModIntro
.
iExists
w2
.
iSplitL
.
iExact
"Hw2"
.
iApply
iProto_le_refl
.
}
iIntros
(
w1
)
"Hw1"
.
iApply
iProto_le_trans
.
{
iApply
iProto_le_base_swap
.
}
iModIntro
.
iExists
(
w1
)
.
iFrame
"Hw1"
.
iModIntro
.
eauto
.
iModIntro
.
iExists
w1
.
iSplitL
.
iExact
"Hw1"
.
iApply
iProto_le_refl
.
Qed
.
Fixpoint
mapper_prot_
list
n
:
iProto
Σ
:=
Fixpoint
mapper_prot_
n
n
prot
:
iProto
Σ
:=
match
n
with
|
O
=>
(
<!>
MSG
(
LitV
$
false
);
END
)
%
prot
o
|
O
=>
prot
|
S
n
=>
(
<!>
MSG
(
LitV
$
true
);
<!
(
x
:
T
)
(
v
:
val
)
>
MSG
v
{{
IT
x
v
}};
<
?
(
w
:
val
)
>
MSG
w
{{
IU
(
f
x
)
w
}};
mapper_prot_
list
n
)
%
proto
<
?
(
w
:
val
)
>
MSG
w
{{
IU
(
f
x
)
w
}};
mapper_prot_
n
n
prot
)
%
proto
end
.
Lemma
subprot_
list
n
:
⊢
mapper_prot
⊑
mapper_prot_
list
n
.
Lemma
subprot_
n
n
:
⊢
mapper_prot
⊑
mapper_prot_
n
n
mapper_prot
.
Proof
.
iEval
(
rewrite
/
mapper_prot
)
.
iInduction
n
as
[|
n
]
"IH"
;
iEval
(
rewrite
fixpoint_unfold
/
mapper_prot_aux
)
.
-
rewrite
/
iProto_choice
.
iExists
false
.
eauto
.
-
rewrite
/
iProto_choice
/=.
iExists
true
.
iModIntro
.
iIntros
(
x1
v1
)
"Hv1"
.
iExists
x1
,
v1
.
iFrame
"Hv1"
.
iModIntro
.
iIntros
(
w1
)
"Hw1"
.
iExists
w1
.
iFrame
"Hw1"
.
iModIntro
.
iApply
"IH"
.
iInduction
n
as
[|
n
]
"IH"
=>
//.
simpl
.
iApply
(
iProto_le_trans
)
.
{
iApply
subprot_once
.
}
rewrite
/
mapper_prot_once
.
iModIntro
.
iApply
"IH"
.
Qed
.
Fixpoint
mapper_prot_list_swap_tail
xs
:=
Fixpoint
recv_list
xs
prot
:=
match
xs
with
|
[]
=>
END
%
prot
o
|
[]
=>
prot
|
x
::
xs
=>
(
<
?
(
w
:
val
)
>
MSG
w
{{
IU
(
f
x
)
w
}};
mapper_prot_list_swap_tail
xs
)
%
proto
end
.
recv_list
xs
prot
)
%
proto
end
.
Fixpoint
mapper_prot_list_swap
n
xs
:=
Lemma
recv_list_mono
xs
prot1
prot2
:
prot1
⊑
prot2
-∗
recv_list
xs
prot1
⊑
recv_list
xs
prot2
.
Proof
.
iIntros
"Hsub"
.
iInduction
xs
as
[|
xs
]
"IHxs"
=>
//.
simpl
.
iIntros
(
w
)
"Hw"
.
iExists
w
.
iFrame
"Hw"
.
iModIntro
.
by
iApply
"IHxs"
.
Qed
.
Fixpoint
mapper_prot_n_swap
n
xs
prot
:=
match
n
with
|
O
=>
(
<!>
MSG
(
LitV
$
false
);
mapper_prot_list_swap_tail
(
rev
xs
)
)
%
proto
|
O
=>
recv_list
(
rev
xs
)
prot
%
proto
|
S
n
=>
(
<!>
MSG
(
LitV
$
true
);
<!
(
x
:
T
)
(
v
:
val
)
>
MSG
v
{{
IT
x
v
}};
mapper_prot_
list
_swap
n
(
x
::
xs
))
%
proto
mapper_prot_
n
_swap
n
(
x
::
xs
)
prot
)
%
proto
end
.
Fixpoint
mapper_prot_list_swap_recv_head
xs
prot
:=
match
xs
with
|
[]
=>
prot
|
x
::
xs
=>
(
<
?
w
>
MSG
w
{{
IU
(
f
x
)
w
}};
mapper_prot_list_swap_recv_head
xs
prot
)
%
proto
end
.
Lemma
mapper_prot_list_swap_forward
xs
w
prot
:
⊢
(
mapper_prot_list_swap_recv_head
xs
(
<!>
MSG
w
;
prot
))
%
proto
⊑
(
<!>
MSG
w
;
mapper_prot_list_swap_recv_head
xs
prot
)
%
proto
.
Lemma
recv_list_fwd
xs
v
prot
:
⊢
recv_list
xs
(
<!>
MSG
v
;
prot
)
%
proto
⊑
(
<!>
MSG
v
;
recv_list
xs
prot
)
%
proto
.
Proof
.
iInduction
xs
as
[|
x
xs
]
"IH"
=>
//=.
iIntros
(
v
)
"H
v
"
.
iApply
(
iProto_le_trans
_
(
<!>
MSG
w
;
<
?
>
MSG
v
;_)
%
proto
);
last
first
.
{
iModIntro
.
iExists
v
.
iFrame
"H
v
"
.
eauto
.
}
iIntros
(
w
)
"H
w
"
.
iApply
(
iProto_le_trans
_
(
<!>
MSG
v
;
<
?
>
MSG
w
;_)
%
proto
);
last
first
.
{
iModIntro
.
iExists
w
.
iFrame
"H
w
"
.
eauto
.
}
iApply
iProto_le_trans
;
last
first
.
{
iApply
iProto_le_base_swap
.
}
iModIntro
.
iApply
"IH"
.
Qed
.
Lemma
subprot_list_swap_general
xs
n
:
⊢
mapper_prot_list_swap_recv_head
xs
(
mapper_prot_list
n
)
⊑
mapper_prot_list_swap
n
(
rev
xs
)
.
Lemma
subprot_n_n_swap
n
xs
prot
:
⊢
(
recv_list
xs
(
mapper_prot_n
n
prot
))
⊑
mapper_prot_n_swap
n
(
rev
xs
)
prot
.
Proof
.
iInduction
n
as
[|
n
]
"IHn"
forall
(
xs
)
.
-
simpl
.
rewrite
rev_involutive
.
iInduction
n
as
[|
n
]
"IHn"
forall
(
xs
)
=>
//.
-
iInduction
xs
as
[|
x
xs
]
"IHxs"
=>
//=.
rewrite
rev_unit
/=
rev_involutive
.
iIntros
(
w1
)
"Hw1"
.
iExists
w1
.
iFrame
"Hw1"
.
iModIntro
.
iApply
"IHxs"
.
-
simpl
.
iApply
iProto_le_trans
.
{
iApply
mapper_prot_list_swap_forward
.
}
iModIntro
.
iInduction
xs
as
[|
x
xs
]
"IHxs"
=>
//.
iIntros
(
w
)
"Hw"
.
iExists
w
.
iFrame
"Hw"
.
iModIntro
.
iApply
"IHxs"
.
-
iApply
iProto_le_trans
.
{
iApply
mapper_prot_list_swap_forward
.
}
{
iApply
recv_list_fwd
.
}
iModIntro
.
iApply
(
iProto_le_trans
_
(
<!
(
x
:
T
)
(
v
:
val
)
>
MSG
v
{{
IT
x
v
}};
mapper_prot_list_swap_recv_head
xs
(
<
?
(
w
:
val
)
>
MSG
w
{{
IU
(
f
x
)
w
}};
mapper_prot_list
n
))
%
proto
)
.
{
iInduction
xs
as
[|
x
xs
]
"IHxs"
=>
//=.
recv_list
xs
(
<
?
(
w
:
val
)
>
MSG
w
{{
IU
(
f
x
)
w
}};
mapper_prot_n
n
prot
))
%
proto
)
.
{
iInduction
xs
as
[|
x
xs
]
"IHxs"
=>
//.
iIntros
(
w
)
"Hw"
.
iApply
iProto_le_trans
.
{
iModIntro
.
iApply
"IHxs"
.
}
...
...
@@ -176,12 +229,45 @@ Section with_Σ.
iApply
"IHxs"
.
Qed
.
Lemma
subprot_list_swap
n
:
⊢
mapper_prot
⊑
mapper_prot_list_swap
n
[]
.
Lemma
subprot_n_swap
n
:
⊢
mapper_prot
⊑
mapper_prot_n_swap
n
[]
mapper_prot
.
Proof
.
iApply
iProto_le_trans
.
{
iApply
(
subprot_n
n
)
.
}
iInduction
n
as
[|
n
]
"IHn"
=>
//=.
iModIntro
.
iIntros
(
x1
v1
)
"Hv1"
.
iExists
x1
,
v1
.
iFrame
"Hv1"
.
iModIntro
.
iApply
(
subprot_n_n_swap
n
[
x1
])
.
Qed
.
Fixpoint
mapper_prot_n_swap_fwd
n
xs
prot
:=
match
n
with
|
O
=>
(
<!>
MSG
LitV
$
false
;
recv_list
(
rev
xs
)
prot
)
%
proto
|
S
n
=>
(
<!>
MSG
(
LitV
$
true
);
<!
(
x
:
T
)
(
v
:
val
)
>
MSG
v
{{
IT
x
v
}};
mapper_prot_n_swap_fwd
n
(
x
::
xs
)
prot
)
%
proto
end
.
Lemma
subprot_n_swap_n_swap_end
n
xs
:
⊢
mapper_prot_n_swap
n
xs
mapper_prot
⊑
mapper_prot_n_swap_fwd
n
xs
END
%
proto
.
Proof
.
iInduction
n
as
[|
n
]
"IHn"
forall
(
xs
)=>
/=.
-
iApply
iProto_le_trans
.
{
iApply
recv_list_mono
.
rewrite
/
mapper_prot
fixpoint_unfold
/
mapper_prot_aux
/
iProto_choice
.
iExists
false
.
iApply
iProto_le_refl
.
}
iApply
recv_list_fwd
.
-
iModIntro
.
iIntros
(
x1
v1
)
"Hv1"
.
iExists
x1
,
v1
.
iFrame
"Hv1"
.
iModIntro
.
iApply
"IHn"
.
Qed
.
Lemma
subprot_n_swap_end
n
:
⊢
mapper_prot
⊑
mapper_prot_n_swap_fwd
n
[]
END
%
proto
.
Proof
.
iApply
iProto_le_trans
.
{
iApply
(
subprot_
list
n
)
.
}
iApply
(
subprot_
list
_swap_
g
en
eral
[]
n
)
.
{
iApply
(
subprot_
n_swap
n
)
.
}
iApply
subprot_
n_swap_n
_swap_en
d
.
Qed
.
End
with_Σ
.
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