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
Model registry
Operate
Environments
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
Iris
Actris
Commits
2efbf2f6
Commit
2efbf2f6
authored
5 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Better names for basic examples.
parent
df678f5f
No related branches found
No related tags found
No related merge requests found
Pipeline
#21262
passed
5 years ago
Stage: build
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/examples/basics.v
+32
-32
32 additions, 32 deletions
theories/examples/basics.v
with
32 additions
and
32 deletions
theories/examples/basics.v
+
32
−
32
View file @
2efbf2f6
...
...
@@ -5,17 +5,17 @@ From iris.heap_lang Require Import proofmode notation lib.spin_lock.
From
actris
.
utils
Require
Import
contribution
.
(** Basic *)
Definition
prog
1
:
val
:=
λ
:
<>
,
Definition
prog
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
send
"c'"
#
42
)
in
recv
"c"
.
(** Tranfering References *)
Definition
prog
1
_ref
:
val
:=
λ
:
<>
,
Definition
prog_ref
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
send
"c'"
(
ref
#
42
))
in
!
(
recv
"c"
)
.
(** Delegation, i.e. transfering channels *)
Definition
prog
1
_del
:
val
:=
λ
:
<>
,
Definition
prog_del
:
val
:=
λ
:
<>
,
let
:
"c1"
:=
start_chan
(
λ
:
"c1'"
,
let
:
"cc2"
:=
new_chan
#
()
in
send
"c1'"
(
Fst
"cc2"
);;
...
...
@@ -23,18 +23,18 @@ Definition prog1_del : val := λ: <>,
recv
(
recv
"c1"
)
.
(** Dependent protocols *)
Definition
prog
2
:
val
:=
λ
:
<>
,
Definition
prog
_dep
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
let
:
"x"
:=
recv
"c'"
in
send
"c'"
(
"x"
+
#
2
))
in
send
"c"
#
40
;;
recv
"c"
.
Definition
prog
2
_ref
:
val
:=
λ
:
<>
,
Definition
prog
_dep
_ref
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
let
:
"l"
:=
recv
"c'"
in
"l"
<-
!
"l"
+
#
2
;;
send
"c'"
#
())
in
let
:
"l"
:=
ref
#
40
in
send
"c"
"l"
;;
recv
"c"
;;
!
"l"
.
Definition
prog
2
_del
:
val
:=
λ
:
<>
,
Definition
prog
_dep
_del
:
val
:=
λ
:
<>
,
let
:
"c1"
:=
start_chan
(
λ
:
"c1'"
,
let
:
"cc2"
:=
new_chan
#
()
in
send
"c1'"
(
Fst
"cc2"
);;
...
...
@@ -42,7 +42,7 @@ Definition prog2_del : val := λ: <>,
let
:
"c2'"
:=
recv
"c1"
in
send
"c2'"
#
40
;;
recv
"c2'"
.
(** Transfering higher-order functions *)
Definition
prog
3
:
val
:=
λ
:
<>
,
Definition
prog
_fun
:
val
:=
λ
:
<>
,
let
:
"c"
:=
start_chan
(
λ
:
"c'"
,
let
:
"f"
:=
recv
"c'"
in
send
"c'"
(
λ
:
<>
,
"f"
#
()
+
#
2
))
in
let
:
"r"
:=
ref
#
40
in
...
...
@@ -61,27 +61,27 @@ Section proofs.
Context
`{
heapG
Σ
,
proto_chanG
Σ
}
.
(** Protocols for the respective programs *)
Definition
prot
1
:
iProto
Σ
:=
Definition
prot
:
iProto
Σ
:=
(
<
?
>
MSG
#
42
;
END
)
%
proto
.
Definition
prot
1
_ref
:
iProto
Σ
:=
Definition
prot_ref
:
iProto
Σ
:=
(
<
?
>
l
:
loc
,
MSG
#
l
{{
l
↦
#
42
}};
END
)
%
proto
.
Definition
prot
1
_del
:
iProto
Σ
:=
(
<
?
>
c
:
val
,
MSG
c
{{
c
↣
prot
1
}};
END
)
%
proto
.
Definition
prot_del
:
iProto
Σ
:=
(
<
?
>
c
:
val
,
MSG
c
{{
c
↣
prot
}};
END
)
%
proto
.
Definition
prot
2
:
iProto
Σ
:=
Definition
prot
_dep
:
iProto
Σ
:=
(
<!>
x
:
Z
,
MSG
#
x
;
<
?
>
MSG
#
(
x
+
2
);
END
)
%
proto
.
Definition
prot
2
_ref
:
iProto
Σ
:=
Definition
prot
_dep
_ref
:
iProto
Σ
:=
(
<!>
(
l
:
loc
)
(
x
:
Z
),
MSG
#
l
{{
l
↦
#
x
}};
<
?
>
MSG
#
()
{{
l
↦
#
(
x
+
2
)
}};
END
)
%
proto
.
Definition
prot
2
_del
:
iProto
Σ
:=
(
<
?
>
c
:
val
,
MSG
c
{{
c
↣
prot
2
}};
END
)
%
proto
.
Definition
prot
_dep
_del
:
iProto
Σ
:=
(
<
?
>
c
:
val
,
MSG
c
{{
c
↣
prot
_dep
}};
END
)
%
proto
.
Definition
prot
3
:
iProto
Σ
:=
Definition
prot
_fun
:
iProto
Σ
:=
(
<!>
(
P
:
iProp
Σ
)
(
Φ
:
Z
→
iProp
Σ
)
(
vf
:
val
),
MSG
vf
{{
{{{
P
}}}
vf
#
()
{{{
x
,
RET
#
x
;
Φ
x
}}}
}};
<
?
>
(
vg
:
val
),
...
...
@@ -95,64 +95,64 @@ Fixpoint prot_lock (n : nat) : iProto Σ :=
end
%
proto
.
(** Specs and proofs of the respective programs *)
Lemma
prog
1
_spec
:
{{{
True
}}}
prog
1
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog_spec
:
{{{
True
}}}
prog
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
prot
1
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
prot
);
iIntros
(
c
)
"Hc"
.
-
by
wp_send
with
"[]"
.
-
wp_recv
as
"_"
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog
1
_ref_spec
:
{{{
True
}}}
prog
1
_ref
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog_ref_spec
:
{{{
True
}}}
prog_ref
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
prot
1
_ref
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
prot_ref
);
iIntros
(
c
)
"Hc"
.
-
wp_alloc
l
as
"Hl"
.
by
wp_send
with
"[$Hl]"
.
-
wp_recv
(
l
)
as
"Hl"
.
wp_load
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog
1
_del_spec
:
{{{
True
}}}
prog
1
_del
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog_del_spec
:
{{{
True
}}}
prog_del
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
prot
1
_del
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
prot_del
);
iIntros
(
c
)
"Hc"
.
-
wp_apply
(
new_chan_proto_spec
with
"[//]"
)
.
iIntros
(
c2
c2'
)
"Hcc2"
.
iMod
(
"Hcc2"
$!
prot
1
)
as
"[Hc2 Hc2']"
.
iIntros
(
c2
c2'
)
"Hcc2"
.
iMod
(
"Hcc2"
$!
prot
)
as
"[Hc2 Hc2']"
.
wp_send
with
"[$Hc2]"
.
by
wp_send
with
"[]"
.
-
wp_recv
(
c2
)
as
"Hc2"
.
wp_recv
as
"_"
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog
2
_spec
:
{{{
True
}}}
prog
2
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog
_dep
_spec
:
{{{
True
}}}
prog
_dep
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
prot
2
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
prot
_dep
);
iIntros
(
c
)
"Hc"
.
-
wp_recv
(
x
)
as
"_"
.
by
wp_send
with
"[]"
.
-
wp_send
with
"[//]"
.
wp_recv
as
"_"
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog2_ref_spec
:
{{{
True
}}}
prog
2
_ref
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog2_ref_spec
:
{{{
True
}}}
prog
_dep
_ref
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
prot
2
_ref
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
prot
_dep
_ref
);
iIntros
(
c
)
"Hc"
.
-
wp_recv
(
l
x
)
as
"Hl"
.
wp_load
.
wp_store
.
by
wp_send
with
"[Hl]"
.
-
wp_alloc
l
as
"Hl"
.
wp_send
with
"[$Hl]"
.
wp_recv
as
"Hl"
.
wp_load
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog
2
_del_spec
:
{{{
True
}}}
prog
2
_del
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog
_dep
_del_spec
:
{{{
True
}}}
prog
_dep
_del
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
prot
2
_del
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
prot
_dep
_del
);
iIntros
(
c
)
"Hc"
.
-
wp_apply
(
new_chan_proto_spec
with
"[//]"
)
.
iIntros
(
c2
c2'
)
"Hcc2"
.
iMod
(
"Hcc2"
$!
prot
2
)
as
"[Hc2 Hc2']"
.
iIntros
(
c2
c2'
)
"Hcc2"
.
iMod
(
"Hcc2"
$!
prot
_dep
)
as
"[Hc2 Hc2']"
.
wp_send
with
"[$Hc2]"
.
wp_recv
(
x
)
as
"_"
.
by
wp_send
with
"[]"
.
-
wp_recv
(
c2
)
as
"Hc2"
.
wp_send
with
"[//]"
.
wp_recv
as
"_"
.
by
iApply
"HΦ"
.
Qed
.
Lemma
prog
3
_spec
:
{{{
True
}}}
prog
3
#
()
{{{
RET
#
42
;
True
}}}
.
Lemma
prog
_fun
_spec
:
{{{
True
}}}
prog
_fun
#
()
{{{
RET
#
42
;
True
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
(
start_chan_proto_spec
prot
3
);
iIntros
(
c
)
"Hc"
.
wp_apply
(
start_chan_proto_spec
prot
_fun
);
iIntros
(
c
)
"Hc"
.
-
wp_recv
(
P
Ψ
vf
)
as
"#Hf"
.
wp_send
with
"[]"
;
last
done
.
iIntros
"!>"
(
Ψ'
)
"HP HΨ'"
.
wp_apply
(
"Hf"
with
"HP"
);
iIntros
(
x
)
"HΨ"
.
wp_pures
.
by
iApply
"HΨ'"
.
...
...
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