Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Abhishek Anand
Iris
Commits
7bc008c5
Commit
7bc008c5
authored
Jun 21, 2019
by
Ralf Jung
Browse files
introduce notation for value comparison
parent
472aa3bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
theories/heap_lang/lang.v
View file @
7bc008c5
...
...
@@ -184,6 +184,10 @@ Fixpoint val_for_compare (v : val) : val :=
|
RecV
f
x
e
=>
RecV
BAnon
BAnon
(
Val
$
LitV
$
LitUnit
)
end
.
(** Now we can define how to compare values. *)
Notation
"v1 =ᵥ v2"
:
=
(
val_for_compare
v1
=
val_for_compare
v2
)
(
at
level
70
)
:
stdpp_scope
.
Notation
"v1 ≠ᵥ v2"
:
=
(
val_for_compare
v1
≠
val_for_compare
v2
)
(
at
level
70
)
:
stdpp_scope
.
(** The state: heaps of vals. *)
Record
state
:
Type
:
=
{
heap
:
gmap
loc
val
;
...
...
@@ -518,7 +522,7 @@ Definition bin_op_eval_bool (op : bin_op) (b1 b2 : bool) : option base_lit :=
Definition
bin_op_eval
(
op
:
bin_op
)
(
v1
v2
:
val
)
:
option
val
:
=
if
decide
(
op
=
EqOp
)
then
Some
$
LitV
$
LitBool
$
bool_decide
(
v
al_for_compare
v1
=
val_for_compare
v2
)
Some
$
LitV
$
LitBool
$
bool_decide
(
v
1
=
ᵥ
v2
)
else
match
v1
,
v2
with
|
LitV
(
LitInt
n1
),
LitV
(
LitInt
n2
)
=>
LitV
<$>
bin_op_eval_int
op
n1
n2
...
...
@@ -636,13 +640,13 @@ Inductive head_step : expr → state → list observation → expr → state →
|
CasFailS
l
v1
v2
vl
σ
:
vals_cas_compare_safe
vl
v1
→
σ
.(
heap
)
!!
l
=
Some
vl
→
v
al_for_compare
vl
≠
val_for_compare
v1
→
v
l
≠ᵥ
v1
→
head_step
(
CAS
(
Val
$
LitV
$
LitLoc
l
)
(
Val
v1
)
(
Val
v2
))
σ
[]
(
Val
$
LitV
$
LitBool
false
)
σ
[]
|
CasSucS
l
v1
v2
vl
σ
:
vals_cas_compare_safe
vl
v1
→
σ
.(
heap
)
!!
l
=
Some
vl
→
v
al_for_compare
vl
=
val_for_compare
v1
→
v
l
=
ᵥ
v1
→
head_step
(
CAS
(
Val
$
LitV
$
LitLoc
l
)
(
Val
v1
)
(
Val
v2
))
σ
[]
(
Val
$
LitV
$
LitBool
true
)
(
state_upd_heap
<[
l
:
=
v2
]>
σ
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment