-
Notifications
You must be signed in to change notification settings - Fork 0
/
graveyard.v
69 lines (63 loc) · 1.9 KB
/
graveyard.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From mathcomp Require Import all_ssreflect.
From Michocoq Require Import semantics util macros.
Import syntax comparable error.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Definition parameter_ty := bytes.
Definition storage_ty := bytes.
Module graveyard(C : ContractContext).
Module semantics := Semantics C. Import semantics.
Require Import String.
Open Scope string_scope.
Definition graveyard: full_contract false parameter_ty None storage_ty :=
DUP;;
{
CAR;
UNPACK unit;
IF_NONE {PUSH _ (Comparable_constant syntax_type.string "unpack param");
FAILWITH}
{DROP1}
};;;
{
CDR;
NIL operation;
PAIR
}.
Lemma graveyard_correct
(env : @proto_env (Some (Comparable_type parameter_ty, None)))
(fuel : Datatypes.nat)
(param : data bytes)
(storage : data bytes)
(psi : stack (pair (list operation) storage_ty ::: [::]) -> Prop) :
fuel > 3 ->
precond (eval_seq env graveyard fuel ((param, storage), tt)) psi
<-> unpack env unit param <> None /\ psi ([::], storage, tt).
Proof.
move=> F; have<-: 4 + (fuel - 4) = fuel by rewrite addnC subnK.
split => H.
+ move: H.
rewrite eval_seq_precond_correct /eval_seq_precond /=.
by case => [] [] [] ->.
+ rewrite eval_seq_precond_correct /eval_seq_precond /=.
case: H; case:(unpack env unit param) => // a _ ?.
by exists a.
Qed.
Lemma graveyard_invocable
(env : @proto_env (Some (Comparable_type parameter_ty, None)))
(fuel : Datatypes.nat)
(param : data bytes)
(storage : data bytes)
(psi : stack (pair (list operation) storage_ty ::: [::]) -> Prop) :
fuel > 3 ->
unpack env unit param <> None ->
precond (eval_seq env graveyard fuel ((param, storage), tt)) psi
<-> psi ([::], storage, tt).
Proof.
move=> F up.
split.
by case/(graveyard_correct _ _ _ _ F).
move=> pt.
by apply/graveyard_correct.
Qed.
End graveyard.