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
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
tlsomers
Actris
Commits
3706934d
Commit
3706934d
authored
4 years ago
by
Jonas Kastberg
Browse files
Options
Downloads
Patches
Plain Diff
WIP Branch proof
parent
20ce8454
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/logrel/types.v
+123
-12
123 additions, 12 deletions
theories/logrel/types.v
with
123 additions
and
12 deletions
theories/logrel/types.v
+
123
−
12
View file @
3706934d
...
@@ -700,18 +700,129 @@ Section properties.
...
@@ -700,18 +700,129 @@ Section properties.
by
wp_pures
.
by
wp_pures
.
Qed
.
Qed
.
(* Definition chanbranch : val := λ: "c", *)
From
stdpp
Require
Import
pretty
.
(* let i := recv "c" in if: b then InjL "c" else InjR "c". *)
From
actris
.
utils
Require
Import
switch
.
From
iris
.
heap_lang
.
lib
Require
Import
assert
.
(* Lemma ltyped_chanbranch Ps : *)
(* ⊢ ∅ ⊨ chanbranch : chan (lsty_branch Ps) → . *)
Fixpoint
lty_arr_list
(
As
:
list
(
lty
Σ
))
(
B
:
lty
Σ
)
:
lty
Σ
:=
(* Proof. *)
match
As
with
(* iIntros (vs) "!> _ /=". iApply wp_value. *)
|
[]
=>
B
(* iIntros "!>" (c) "Hc". rewrite /chanbranch. wp_pures. *)
|
A
::
As
=>
A
⊸
lty_arr_list
As
B
(* wp_branch; wp_pures. *)
end
.
(* - iLeft. iExists c. iSplit=> //. *)
(* - iRight. iExists c. iSplit=> //. *)
Definition
chanbranch
(
xs
:
list
Z
)
:
val
:=
λ
:
"c"
,
(* Qed. *)
switch_lams
"f"
0
(
length
xs
)
$
let
:
"y"
:=
recv
"c"
in
switch_body
"y"
0
xs
(
assert
:
#
false
)
$
λ
i
,
(
"f"
+:+
pretty
i
)
"c"
.
Lemma
lty_arr_list_spec_step
A
As
(
e
:
expr
)
B
ws
y
i
:
(
∀
v
,
lty_car
A
v
-∗
WP
subst_map
(
<
[
y
+:+
pretty
i
:=
v
]
>
ws
)
(
switch_lams
y
(
S
i
)
(
length
As
)
e
)
{{
lty_arr_list
As
B
}})
-∗
WP
subst_map
ws
(
switch_lams
y
i
(
length
(
A
::
As
))
e
)
{{
lty_arr_list
(
A
::
As
)
B
}}
.
Proof
.
iIntros
"H"
.
simpl
.
wp_pures
.
iIntros
(
v
)
"HA"
.
iDestruct
(
"H"
with
"HA"
)
as
"H"
.
wp_pures
.
rewrite
subst_map_insert
.
iApply
"H"
.
Qed
.
Lemma
lty_arr_list_spec
As
(
e
:
expr
)
B
ws
y
i
n
:
n
=
length
As
→
(
∀
vs
,
([
∗
list
]
A
;
v
∈
As
;
vs
,
(
lty_car
A
)
v
)
-∗
WP
subst_map
(
map_string_seq
y
i
vs
∪
ws
)
e
{{
lty_car
B
}})
-∗
WP
subst_map
ws
(
switch_lams
y
i
n
e
)
{{
lty_arr_list
As
B
}}
.
Proof
.
iIntros
(
Hlen
)
"H"
.
iRevert
(
Hlen
)
.
iInduction
As
as
[|
A
As
]
"IH"
forall
(
ws
i
e
n
)=>
/=.
-
iIntros
(
->
)
.
iDestruct
(
"H"
$!
[]
with
"[$]"
)
as
"H"
=>
/=.
by
rewrite
left_id_L
.
-
iIntros
(
Hlen
)
.
rewrite
Hlen
.
iApply
lty_arr_list_spec_step
.
iIntros
(
v
)
"HA"
.
iApply
(
"IH"
with
"[H HA]"
)=>
//.
iIntros
(
vs
)
"HAs"
.
iSpecialize
(
"H"
$!
(
v
::
vs
))
.
simpl
.
rewrite
insert_union_singleton_l
.
rewrite
insert_union_singleton_l
.
rewrite
(
map_union_comm
({[
y
+:+
pretty
i
:=
v
]}));
last
first
.
{
apply
map_disjoint_singleton_l_2
.
apply
lookup_map_string_seq_None_lt
.
eauto
.
}
rewrite
assoc_L
.
iApply
(
"H"
with
"[HA HAs]"
)
.
iFrame
.
Qed
.
Lemma
ltyped_chanbranch
Ps
A
xs
:
Forall
(
λ
x
,
is_Some
(
Ps
!!
x
))
xs
→
⊢
∅
⊨
chanbranch
xs
:
chan
(
lsty_branch
Ps
)
⊸
lty_arr_list
((
λ
x
,
(
chan
(
Ps
!!!
x
)
⊸
A
)
%
lty
)
<$>
xs
)
A
.
Proof
.
intros
Hxs
.
iIntros
"!>"
(
vs
)
"Hvs"
.
rewrite
/
chanbranch
.
simpl
.
iApply
wp_value
.
iIntros
(
c
)
"Hc"
.
wp_lam
=>
/=.
rewrite
-
subst_map_singleton
.
iApply
(
lty_arr_list_spec
)
.
{
by
rewrite
fmap_length
.
}
iIntros
(
ws
)
"H"
.
rewrite
big_sepL2_fmap_l
.
assert
(
strings
.
length
((
λ
x
:
Z
,
(
chan
(
Ps
!!!
x
)
⊸
A
)
%
lty
)
<$>
xs
)
=
strings
.
length
ws
)
as
Heq
.
{
admit
.
}
(* This can be asserted using big_sepL2_alt, but
then we get the map on a weird form *)
rewrite
-
insert_union_singleton_r
=>
//
;
last
by
apply
lookup_map_string_seq_None
.
simpl
.
rewrite
lookup_insert
.
wp_recv
(
x
)
as
"%"
.
wp_pures
.
rewrite
-
subst_map_insert
.
assert
(
x
∈
xs
)
.
{
admit
.
}
(* We need to know that the domain of P is exactly xs to infer this. *)
pose
proof
(
list_find_elem_of
(
eq
x
)
xs
x
H2
eq_refl
)
.
destruct
H3
as
[
y
H3
]
.
destruct
y
.
iApply
switch_body_spec
=>
//=.
2
:
{
by
rewrite
lookup_insert
.
}
{
rewrite
H3
.
simpl
.
reflexivity
.
}
rewrite
lookup_insert_ne
=>
//.
rewrite
lookup_insert_ne
=>
//.
rewrite
lookup_map_string_seq_Some
.
assert
(
xs
!!
n
=
Some
x
)
as
Hxs_Some
.
{
pose
proof
(
@
list_find_Some
Z
)
as
Hlist_find_Some
.
specialize
(
Hlist_find_Some
(
eq
x
)
_
xs
n
z
)
.
destruct
Hlist_find_Some
as
[
Hlist_find_Some
_]
.
specialize
(
Hlist_find_Some
H3
)
.
destruct
Hlist_find_Some
as
[
Heq1
[
->
_]]
.
eauto
.
}
assert
(
is_Some
(
ws
!!
n
))
as
Hws_Some
.
{
apply
lookup_lt_is_Some_2
.
rewrite
-
Heq
.
apply
lookup_lt_is_Some_1
.
rewrite
list_lookup_fmap
.
rewrite
fmap_is_Some
.
by
exists
x
.
}
destruct
Hws_Some
as
[
w
Hws_Some
]
.
iDestruct
(
big_sepL2_lookup
_
xs
ws
n
with
"H"
)
as
"HA"
=>
//.
rewrite
Hws_Some
.
rewrite
insert_commute
=>
//.
rewrite
lookup_insert
.
by
iApply
"HA"
.
Qed
.
End
with_chan
.
End
with_chan
.
End
properties
.
End
properties
.
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