Skip to content

Commit a7a00dd

Browse files
authored
Merge pull request #646 from formal-land/guillaume-claret@add-some-revm-simulations
links: more fixes to the compilation
2 parents 28361e2 + ecbec35 commit a7a00dd

File tree

43 files changed

+571
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+571
-362
lines changed

CoqOfRust/M.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,14 @@ Module Value.
235235
end
236236
| Pointer.Index.Array index =>
237237
match value with
238-
| Array fields => Some (Array (List.replace_at fields (Z.to_nat index) value))
238+
| Array fields => Some (Array (List.replace_at fields (Z.to_nat index) update))
239239
| _ => None
240240
end
241241
| Pointer.Index.StructRecord constructor field =>
242242
match value with
243243
| StructRecord c fields =>
244244
if String.eqb c constructor then
245-
Some (StructRecord c (List.assoc_replace fields field value))
245+
Some (StructRecord c (List.assoc_replace fields field update))
246246
else
247247
None
248248
| _ => None
@@ -251,7 +251,7 @@ Module Value.
251251
match value with
252252
| StructTuple c fields =>
253253
if String.eqb c constructor then
254-
Some (StructTuple c (List.replace_at fields (Z.to_nat index) value))
254+
Some (StructTuple c (List.replace_at fields (Z.to_nat index) update))
255255
else
256256
None
257257
| _ => None

CoqOfRust/alloc/vec/links/mod.v

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,15 @@ Require Import move_sui.translations.move_binary_format.file_format.
55
Import Run.
66

77
Module Vec.
8+
Record t {A : Set} : Set := {
9+
value : list A;
10+
}.
11+
Arguments t : clear implicits.
12+
13+
Parameter to_value : forall {A : Set}, t A -> Value.t.
14+
15+
Global Instance IsLink (A : Set) (_ : Link A) : Link (t A) := {
16+
Φ := Ty.apply (Ty.path "vec") [] [Φ A];
17+
φ := to_value;
18+
}.
819
End Vec.

CoqOfRust/blacklist.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ examples/axiomatized/examples/custom/provided_method.v
77
examples/axiomatized/examples/rust_book/traits/traits.v
88
examples/axiomatized/examples/subtle.v
99
# examples/
10-
revm/links
1110
revm/simulations
12-
revm/translations/precompile/utilities.v
1311
# This file works but is taking a very long time (ten minutes)
1412
revm/translations/interpreter/opcode.v
1513
core/array/mod.v
@@ -18,7 +16,6 @@ core/net/ip_addr.v
1816
core/num/int_sqrt.v
1917
token-2022
2018
# Links that are not working yet
21-
core/links/cmp.v
2219
move_sui/links/
2320
# We ignore the metering for now
2421
move_sui/simulations/move_bytecode_verifier_meter/lib.v

CoqOfRust/core/links/array.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Module Array.
77
Arguments Make {_ _} _.
88

99
Global Instance IsLink (length : Z) (A : Set) (_ : Link A) : Link (t length A) := {
10-
to_ty :=
11-
Ty.apply (Ty.path "array") [Value.Integer IntegerKind.Usize length] [to_ty A];
12-
to_value '(Make x) :=
13-
Value.Array (List.map to_value x);
10+
Φ :=
11+
Ty.apply (Ty.path "array") [Value.Integer IntegerKind.Usize length] [Φ A];
12+
φ '(Make x) :=
13+
Value.Array (List.map φ x);
1414
}.
1515
End Array.

CoqOfRust/core/links/bool.v

Lines changed: 0 additions & 10 deletions
This file was deleted.

CoqOfRust/core/links/clone.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Import Run.
1515
Module Clone.
1616
Definition Run_clone (Self : Set) `{Link Self} : Set :=
1717
{clone @
18-
IsTraitMethod.t "core::clone::Clone" (to_ty Self) [] "clone" clone *
18+
IsTraitMethod.t "core::clone::Clone" (Φ Self) [] "clone" clone *
1919
forall (self : Ref.t Pointer.Kind.Ref Self),
2020
{{
21-
clone [] [] [ to_value self ] ⇓
21+
clone [] [] [ φ self ] ⇓
2222
output_pure Self
2323
}}
2424
}.

CoqOfRust/core/links/cmp.v

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Module Ordering.
1919
| Greater : t.
2020

2121
Global Instance IsLink : Link t := {
22-
to_ty := Ty.path "core::cmp::Ordering";
23-
to_value x :=
22+
Φ := Ty.path "core::cmp::Ordering";
23+
φ x :=
2424
match x with
2525
| Less => Value.StructTuple "core::cmp::Ordering::Less" []
2626
| Equal => Value.StructTuple "core::cmp::Ordering::Equal" []
@@ -29,6 +29,7 @@ Module Ordering.
2929
}.
3030
End Ordering.
3131

32+
(*
3233
(*
3334
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
3435
match compare(&v1, &v2) {
@@ -222,3 +223,4 @@ Module Impl_Ord_for_u64.
222223
}
223224
Admitted.
224225
End Impl_Ord_for_u64.
226+
*)

CoqOfRust/core/links/default.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Import Run.
1313
Module Default.
1414
Definition Run_default (Self : Set) `{Link Self} : Set :=
1515
{default @
16-
IsTraitMethod.t "core::default::Default" (to_ty Self) [] "default" default *
16+
IsTraitMethod.t "core::default::Default" (Φ Self) [] "default" default *
1717
{{
1818
default [] [] [] ⇓
1919
output_pure Self
@@ -100,7 +100,7 @@ Module Impl_Default_for_integer.
100100

101101
Definition implements_of_integer_kind (kind : IntegerKind.t) :
102102
IsTraitInstance "core::default::Default"
103-
(to_ty (Self kind))
103+
(Φ (Self kind))
104104
[]
105105
[("default", InstanceField.Method (method_of_ingeter_kind kind))] :=
106106
match kind with

CoqOfRust/core/links/option.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Require Import links.M.
33

44
Module Option.
55
Global Instance IsLink (A : Set) (_ : Link A) : Link (option A) := {
6-
to_ty := Ty.apply (Ty.path "core::option::Option") [] [to_ty A];
7-
to_value x :=
6+
Φ := Ty.apply (Ty.path "core::option::Option") [] [Φ A];
7+
φ x :=
88
match x with
99
| None => Value.StructTuple "core::option::Option::None" []
10-
| Some x => Value.StructTuple "core::option::Option::Some" [to_value x]
10+
| Some x => Value.StructTuple "core::option::Option::Some" [φ x]
1111
end;
1212
}.
1313
End Option.

CoqOfRust/core/links/result.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Require Import links.M.
33

44
Module Result.
55
Global Instance IsLink (A B : Set) (_ : Link A) (_ : Link B) : Link (A + B) := {
6-
to_ty := Ty.apply (Ty.path "core::result::Result") [] [to_ty A; to_ty B];
7-
to_value x :=
6+
Φ := Ty.apply (Ty.path "core::result::Result") [] [Φ A; Φ B];
7+
φ x :=
88
match x with
9-
| inl x => Value.StructTuple "core::result::Result::Ok" [to_value x]
10-
| inr e => Value.StructTuple "core::result::Result::Err" [to_value e]
9+
| inl x => Value.StructTuple "core::result::Result::Ok" [φ x]
10+
| inr e => Value.StructTuple "core::result::Result::Err" [φ e]
1111
end;
1212
}.
1313
End Result.

CoqOfRust/core/ops/links/function.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Module FnOnce.
1616
Definition Run_call_once (Self Args : Set) {Output : Set}
1717
`{Link Self} `{Link Args} `{Link Output} : Set :=
1818
{call_once @
19-
IsTraitMethod.t "core::ops::function::FnOnce" (to_ty Self) [ to_ty Args ] "call_once" call_once *
19+
IsTraitMethod.t "core::ops::function::FnOnce" (Φ Self) [ Φ Args ] "call_once" call_once *
2020
forall (self : Self) (args : Args),
2121
{{
22-
call_once [] [] [ to_value self; to_value args ] ⇓
22+
call_once [] [] [ φ self; φ args ] ⇓
2323
output_pure Output
2424
}}
2525
}.

CoqOfRust/core/simulations/eq.v

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Require Import CoqOfRust.CoqOfRust.
2+
13
Module Eq.
24
Class Trait (Self : Set) : Set := {
35
eqb: Self -> Self -> bool
@@ -15,3 +17,7 @@ End Eq.
1517
Module Notations.
1618
Notation "x =? y" := (Eq.eqb x y) (at level 70).
1719
End Notations.
20+
21+
Global Instance ZIsEq : Eq.Trait Z := {
22+
Eq.eqb := Z.eqb
23+
}.

CoqOfRust/core/simulations/integer.v

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)