Skip to content

Commit 79aee4f

Browse files
authored
Merge pull request #232 from formal-land/guillaume-claret@translate-axiom-mode-public
Translate axiom mode as public
2 parents 5726556 + d80c6c9 commit 79aee4f

File tree

238 files changed

+4288
-173
lines changed

Some content is hidden

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

238 files changed

+4288
-173
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
python run_tests.py --output-path ./coq_translation/default/
3434
- name: Translate Rust examples (axiomatized)
3535
run: |
36-
python run_tests.py --axiomatize --output-path ./coq_translation/axiomatized/
36+
python run_tests.py --axiomatize --axiomatize-public --output-path ./coq_translation/axiomatized/
3737
- name: Translate Ink! library
3838
run: |
3939
cd CoqOfRust

CoqOfRust/CoqOfRust.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Require CoqOfRust.core.hash.
196196
Require CoqOfRust.core.iter.
197197
Require CoqOfRust.core.marker.
198198
Require CoqOfRust.core.mem.
199+
Require CoqOfRust.core.num.
199200
Require CoqOfRust.core.option.
200201
Require CoqOfRust.core.primitive.
201202
Require CoqOfRust.core.result.
@@ -216,6 +217,7 @@ Module core.
216217
Export CoqOfRust.core.iter.
217218
Export CoqOfRust.core.marker.
218219
Export CoqOfRust.core.mem.
220+
Export CoqOfRust.core.num.
219221
Export CoqOfRust.core.option.
220222
Export CoqOfRust.core.primitive.
221223
Export CoqOfRust.core.result.
@@ -815,7 +817,6 @@ Require CoqOfRust._std.io.
815817
(* Require CoqOfRust._std.iter. *)
816818
(* Require Import CoqOfRust._std.iter_type. *)
817819
(* Require Import CoqOfRust._std.net. *)
818-
Require Import CoqOfRust._std.num.
819820
Require Import CoqOfRust._std.ops.
820821
(* Require Import CoqOfRust._std.os. *)
821822
Require Import CoqOfRust._std.panic.
@@ -854,7 +855,6 @@ Module std.
854855
Module io := _std.io.
855856
(* Module iter := _std.iter. *)
856857
(* Module net := _std.net. *)
857-
Module num := _std.num.
858858
Module ops := _std.ops.
859859
(* Module os := _std.os. *)
860860
Module panic := _std.panic.

CoqOfRust/blacklist.txt

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -143,74 +143,30 @@ examples/unsafe_operations/inline_assembly_symbol_operands_and_abi_clobbers.v
143143
examples/unsafe_operations/inline_assembly.v
144144
examples/unsafe_operations/raw_pointers.v
145145
examples/variable_bindings/declare_first.v
146-
examples_axiomatized/conversion/from.v
147-
examples_axiomatized/conversion/into.v
148-
examples_axiomatized/conversion/try_from_and_try_into.v
149-
examples_axiomatized/conversion/try_from_and_try_into.v
150146
examples_axiomatized/custom_types/enums_testcase_linked_list.v
151-
examples_axiomatized/custom_types/structures.v
152147
examples_axiomatized/error_handling/boxing_errors.v
153-
examples_axiomatized/error_handling/early_returns.v
154-
examples_axiomatized/error_handling/introducing_question_mark_is_an_replacement_for_deprecated_try.v
155-
examples_axiomatized/error_handling/introducing_question_mark.v
156-
examples_axiomatized/error_handling/map_in_result_via_combinators.v
157-
examples_axiomatized/error_handling/map_in_result_via_match.v
158-
examples_axiomatized/error_handling/multiple_error_types.v
159148
examples_axiomatized/error_handling/other_uses_of_question_mark.v
160-
examples_axiomatized/error_handling/pulling_results_out_of_options_with_stop_error_processing.v
161-
examples_axiomatized/error_handling/pulling_results_out_of_options.v
162-
examples_axiomatized/error_handling/result_use_in_main.v
163149
examples_axiomatized/error_handling/unpacking_options_via_question_mark.v
164150
examples_axiomatized/error_handling/wrapping_errors.v
165151
examples_axiomatized/functions/functions_closures_as_input_parameters.v
166152
examples_axiomatized/functions/functions_closures_as_output_parameters.v
167153
examples_axiomatized/functions/functions_closures_input_functions.v
168154
examples_axiomatized/functions/functions_closures_type_anonymity_define_and_use.v
169-
examples_axiomatized/functions/functions_closures_type_anonymity_define.v
170-
examples_axiomatized/generics/generics_associated_types_problem.v
171-
examples_axiomatized/generics/generics_associated_types_problem.v
172-
examples_axiomatized/generics/generics_associated_types_solution.v
173-
examples_axiomatized/generics/generics_associated_types_solution.v
174-
examples_axiomatized/generics/generics_bounds_test_case_empty_bounds.v
175155
examples_axiomatized/generics/generics_bounds.v
176-
examples_axiomatized/generics/generics_functions.v
177-
examples_axiomatized/generics/generics_functions.v
178156
examples_axiomatized/generics/generics_implementation.v
179-
examples_axiomatized/generics/generics_multiple_bounds.v
180-
examples_axiomatized/generics/generics_phantom_type_test_case_unit_clarification.v
181-
examples_axiomatized/generics/generics_phantom_type.v
182-
examples_axiomatized/generics/generics.v
183-
examples_axiomatized/generics/generics.v
184157
examples_axiomatized/modules/struct_visibility.v
185-
examples_axiomatized/modules/super_and_self.v
186-
examples_axiomatized/modules/the_use_as_declaration.v
187158
examples_axiomatized/modules/visibility.v
188-
examples_axiomatized/primitives/arrays_and_slices.v
189-
examples_axiomatized/scoping_rules/scoping_rules_borrowing_mutablity.v
190-
examples_axiomatized/scoping_rules/scoping_rules_borrowing_the_ref_pattern.v
191-
examples_axiomatized/scoping_rules/scoping_rules_lifetimes_bounds.v
192-
examples_axiomatized/scoping_rules/scoping_rules_lifetimes_structs.v
193-
examples_axiomatized/scoping_rules/scoping_rules_lifetimes_traits.v
194159
examples_axiomatized/scoping_rules/scoping_rules_ownership_and_rules_partial_moves.v
195160
examples_axiomatized/scoping_rules/scoping_rules_raii_desctructor.v
196-
examples_axiomatized/std_library_types/box_stack_heap.v
197-
examples_axiomatized/std_library_types/hash_map_alternate_or_custom_key_types.v
198161
examples_axiomatized/std_misc/file_io_read_lines_efficient_method.v
199162
examples_axiomatized/std_misc/file_io_read_lines.v
200163
examples_axiomatized/std_misc/filesystem_operations.v
201164
examples_axiomatized/std_misc/foreign_function_interface.v
202165
examples_axiomatized/subtle.v
203-
examples_axiomatized/subtle.v
204-
examples_axiomatized/traits/clone.v
205-
examples_axiomatized/traits/derive.v
206-
examples_axiomatized/traits/derive.v
207166
examples_axiomatized/traits/drop.v
208-
examples_axiomatized/traits/hash.v
209167
examples_axiomatized/traits/impl_trait_as_return_type.v
210168
examples_axiomatized/traits/iterators.v
211169
examples_axiomatized/traits/returning_traits_with_dyn.v
212-
examples_axiomatized/traits/returning_traits_with_dyn.v
213-
examples_axiomatized/traits/returning_traits_with_dyn.v
214170
examples_axiomatized/traits/supertraits.v
215171
ink/erc20.v
216172
_std/iter_type.v

CoqOfRust/_std/num.v renamed to CoqOfRust/core/num.v

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,25 @@ Module NonZeroUsize.
9999
End NonZeroUsize.
100100
Definition NonZeroUsize := NonZeroUsize.t.
101101

102-
(* pub struct ParseFloatError { /* private fields */ } *)
103-
Module ParseFloatError.
104-
Parameter t : Set.
105-
End ParseFloatError.
106-
Definition ParseFloatError := ParseFloatError.t.
107-
108-
(* pub struct ParseIntError { /* private fields */ } *)
109-
Module ParseIntError.
110-
Parameter t : Set.
111-
End ParseIntError.
112-
Definition ParseIntError := ParseIntError.t.
113-
114-
(* pub struct TryFromIntError(_); *)
115-
Module TryFromIntError.
116-
Parameter t : Set.
117-
End TryFromIntError.
118-
Definition TryFromIntError := TryFromIntError.t.
102+
Module error.
103+
(* pub struct ParseFloatError { /* private fields */ } *)
104+
Module ParseFloatError.
105+
Parameter t : Set.
106+
End ParseFloatError.
107+
Definition ParseFloatError := ParseFloatError.t.
108+
109+
(* pub struct ParseIntError { /* private fields */ } *)
110+
Module ParseIntError.
111+
Parameter t : Set.
112+
End ParseIntError.
113+
Definition ParseIntError := ParseIntError.t.
114+
115+
(* pub struct TryFromIntError(_); *)
116+
Module TryFromIntError.
117+
Parameter t : Set.
118+
End TryFromIntError.
119+
Definition TryFromIntError := TryFromIntError.t.
120+
End error.
119121

120122
(* pub struct Wrapping<T>(pub T); *)
121123
Module Wrapping.

cli/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ struct Translate {
1313
/// Axiomatize the definitions
1414
#[arg(long, value_name = "axiomatize", default_value_t = false)]
1515
axiomatize: bool,
16+
/// Axiomatize the definitions with everything as public
17+
#[arg(long, value_name = "axiomatize_public", default_value_t = false)]
18+
axiomatize_public: bool,
1619
/// Generate the "reorder" section of the configuration file
1720
#[arg(long, value_name = "generate_reorder", default_value_t = false)]
1821
generate_reorder: bool,
@@ -61,6 +64,7 @@ fn main() {
6164
path: t.path,
6265
output: t.output_path,
6366
axiomatize: t.axiomatize,
67+
axiomatize_public: t.axiomatize_public,
6468
generate_reorder: t.generate_reorder,
6569
configuration_file: t.configuration_file,
6670
});

coq-of-rust-config.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
"axiomatize": false,
33
"debug_reorder": false,
44
"impl_ignore_axioms": [
5-
"examples/conversion/converting_to_string.rs",
6-
"examples/error_handling/combinators_and_then.rs",
7-
"examples/error_handling/combinators_map.rs",
8-
"examples/error_handling/defining_an_error_type.rs",
9-
"examples/error_handling/unpacking_options_and_defaults_via_get_or_insert.rs",
10-
"examples/error_handling/unpacking_options_and_defaults_via_get_or_insert_with.rs",
11-
"examples/error_handling/unpacking_options_and_defaults_via_or_else.rs",
12-
"examples/error_handling/unpacking_options_and_defaults_via_or.rs",
13-
"examples/primitives/tuples.rs",
14-
"examples/std_library_types/result_chaining_with_question_mark.rs",
15-
"examples/traits/operator_overloading.rs",
165
"ink",
176
"ink_env",
187
"ink_storage"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
(* Generated by coq-of-rust *)
22
Require Import CoqOfRust.CoqOfRust.
33

4+
Parameter used_function : forall `{H' : State.Trait}, M (H := H') unit.
45

6+
(* #[allow(dead_code)] - function was ignored by the compiler *)
7+
Parameter unused_function : forall `{H' : State.Trait}, M (H := H') unit.
8+
9+
Parameter noisy_unused_function : forall `{H' : State.Trait}, M (H := H') unit.
10+
11+
(* #[allow(dead_code)] - function was ignored by the compiler *)
12+
Parameter main : forall `{H' : State.Trait}, M (H := H') unit.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
(* Generated by coq-of-rust *)
22
Require Import CoqOfRust.CoqOfRust.
33

4+
Parameter foo :
5+
forall `{H' : State.Trait} {A : Set},
6+
(core.option.Option A) -> M (H := H') unit.
47

8+
Module tests.
9+
Parameter test_file : forall `{H' : State.Trait}, M (H := H') unit.
10+
11+
Parameter test_file_also : forall `{H' : State.Trait}, M (H := H') unit.
12+
End tests.
13+
14+
Parameter test_file : forall `{H' : State.Trait}, M (H := H') unit.
15+
16+
Parameter test_file_also : forall `{H' : State.Trait}, M (H := H') unit.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
11
(* Generated by coq-of-rust *)
22
Require Import CoqOfRust.CoqOfRust.
33

4+
Module Circle.
5+
Unset Primitive Projections.
6+
Record t : Set := {
7+
radius : i32;
8+
}.
9+
Global Set Primitive Projections.
10+
11+
Global Instance Get_radius : Notation.Dot "radius" := {
12+
Notation.dot '(Build_t x0) := x0;
13+
}.
14+
Global Instance Get_AF_radius : Notation.DoubleColon t "radius" := {
15+
Notation.double_colon '(Build_t x0) := x0;
16+
}.
17+
End Circle.
18+
Definition Circle : Set := Circle.t.
419

20+
Module Impl_core_fmt_Display_for_converting_to_string_Circle.
21+
Definition Self := converting_to_string.Circle.
22+
23+
Parameter fmt :
24+
forall `{H' : State.Trait},
25+
(ref Self) -> (mut_ref core.fmt.Formatter) -> M (H := H') core.fmt.Result.
26+
27+
Global Instance Method_fmt `{H' : State.Trait} : Notation.Dot "fmt" := {
28+
Notation.dot := fmt;
29+
}.
30+
31+
Global Instance I : core.fmt.Display.Trait Self := {
32+
core.fmt.Display.fmt `{H' : State.Trait} := fmt;
33+
}.
34+
Global Hint Resolve I : core.
35+
End Impl_core_fmt_Display_for_converting_to_string_Circle.
36+
37+
(* #[allow(dead_code)] - function was ignored by the compiler *)
38+
Parameter main : forall `{H' : State.Trait}, M (H := H') unit.

coq_translation/axiomatized/examples/conversion/from.v

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
(* Generated by coq-of-rust *)
22
Require Import CoqOfRust.CoqOfRust.
33

4+
Module Number.
5+
Unset Primitive Projections.
6+
Record t : Set := {
7+
value : i32;
8+
}.
9+
Global Set Primitive Projections.
10+
11+
Global Instance Get_value : Notation.Dot "value" := {
12+
Notation.dot '(Build_t x0) := x0;
13+
}.
14+
Global Instance Get_AF_value : Notation.DoubleColon t "value" := {
15+
Notation.double_colon '(Build_t x0) := x0;
16+
}.
17+
End Number.
18+
Definition Number : Set := Number.t.
19+
420
Module Impl_core_convert_From_for_from_Number.
521
Definition Self := from.Number.
622

@@ -16,3 +32,6 @@ Module Impl_core_convert_From_for_from_Number.
1632
}.
1733
Global Hint Resolve I : core.
1834
End Impl_core_convert_From_for_from_Number.
35+
36+
(* #[allow(dead_code)] - function was ignored by the compiler *)
37+
Parameter main : forall `{H' : State.Trait}, M (H := H') unit.

0 commit comments

Comments
 (0)