Skip to content

Commit 7df69e3

Browse files
authored
Merge pull request #1466 from cryspen/proof-lib/fstar-support-more-rbe
Proof lib/fstar support more rbe
2 parents d0ca438 + 93a3ae2 commit 7df69e3

File tree

15 files changed

+126
-2
lines changed

15 files changed

+126
-2
lines changed

.utils/rust-by-example.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function codeBlocksToModules(code_blocks) {
4646
/unsafe_asm \d+/
4747
];
4848
let modules = {};
49-
49+
5050
for(let {name, blocks} of code_blocks) {
5151
let mod_section = `section_${name}`;
5252
modules[mod_section] = {};
@@ -105,21 +105,27 @@ fs.writeFileSync(OUTPUT_CRATE_SRC + '/lib.rs', root_mod);
105105
// A list of [<module_name>, [<snippet_number>]] that are known not to be processed by hax
106106
let cargo_hax_denylist = [
107107
['error_iter_result', [3]],
108+
['error_multiple_error_types_boxing_errors', [1]], // uses dyn
109+
['error_multiple_error_types_reenter_question_mark', [2]], // uses dyn
110+
['error_multiple_error_types_wrap_error', [1]], // uses dyn
108111
['error_option_unwrap_defaults', [3,4]],
109112
['flow_control_for', [1,2,3,5]],
110113
['flow_control_if_let', [3]],
114+
['flow_control_let_else', [1,2]], // Let else panics, bug #1460
111115
['flow_control_loop_nested', [1]],
112116
['flow_control_loop_return', [1]],
113117
['flow_control_loop', [1]],
114118
['flow_control_match_binding', [1,2]],
115119
['flow_control_match_destructuring_destructure_pointers', [1]],
116120
['flow_control_match_destructuring_destructure_slice', [1]],
121+
['flow_control_match_destructuring_destructure_tuple', [1]], // .. pattern, bug #1462
117122
['flow_control_match', [1]],
118123
['flow_control_while_let', [1,2]],
119124
['fn_closures_capture', [1]],
120125
['fn_closures_input_parameters', [1]],
121126
['fn', [1]],
122127
['hello_print_fmt', [1]],
128+
['generics_bounds_testcase_empty', [1]], // Marker traits, bug #1221
123129
['macros_dry', [1]],
124130
['scope_borrow_alias', [1]],
125131
['scope_borrow_ref', [1]],
@@ -135,6 +141,8 @@ let cargo_hax_denylist = [
135141
['std_str', [1]],
136142
['trait_iter', [1]],
137143
['trait', [1]],
144+
['trait_dyn', [1]], // uses dyn
145+
['trait_supertraits', [1]], // uses dyn
138146
['unsafe', [1,2]],
139147
].map(([module, snippets]) => snippets.map(n => `section_${module}::snippet_${n}`)).flat();
140148

hax-lib/proof-libs/fstar-secret-integers/core/Core.Str.fsti

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ open Rust_primitives
44
val impl__str__len: string -> usize
55
val impl__str__as_bytes: string -> t_Slice u8
66

7+
/// Parses this string slice into another type
8+
val impl_str__parse (#t: Type0) (#err: Type0) (s:string) :
9+
(Core.Result.t_Result t err)
10+
11+
/// Trims trailing whitespace
12+
val impl_str__trim : string -> string
13+
14+
/// Split strings on patterns
15+
val impl_str__split : (#pattern: Type) -> string -> pattern ->
16+
(Core.Str.Iter.t_Split pattern)

hax-lib/proof-libs/fstar/core/Alloc.String.fst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ let impl__String__pop (self: t_String): (Alloc.String.t_String & Core.Option.t_O
1515
if l > 0 then
1616
(FStar.String.sub self 0 (l - 1), Core.Option.Option_Some (FStar.String.index self (l - 1)))
1717
else (self, Core.Option.Option_None)
18+
19+
/// Placeholder for the to_string typeclass
20+
assume
21+
val f_to_string (#t: Type) {| Core.TypeClassPlaceHolder.t_Placeholder |} (x:t) : Alloc.String.t_String
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Core.F32
2+
3+
open Rust_primitives.Float
4+
5+
val impl_f32__abs : float -> float

hax-lib/proof-libs/fstar/core/Core.Fmt.fsti

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ val impl_4__new_v1_formatted :
3232

3333
val impl_11__write_fmt : Core.Fmt.t_Formatter -> Core.Fmt.t_Arguments -> Core.Fmt.t_Formatter & Core.Result_Option_bundle.t_Result unit Core.Fmt.t_Error
3434

35+
[@FStar.Tactics.Typeclasses.tcinstance]
36+
val impl_t_debug_string : t_Debug Prims.string
37+
38+
[@FStar.Tactics.Typeclasses.tcinstance]
39+
val impl_t_display_string : t_Display Prims.string
40+
3541
instance debuggable_bool : t_Debug Prims.bool =
3642
{
3743
f_dbg_fmt_pre = (fun (b: Prims.bool) (fmt: Core.Fmt.t_Formatter) -> true);
@@ -56,3 +62,7 @@ instance debuggable_pair (#a:Type) (#b:Type) (x: t_Debug a) (y: t_Debug b): t_De
5662
| Core.Result.Result_Ok v -> f_dbg_fmt pair._2 fmt_a
5763
| Core.Result.Result_Err e -> (fmt_a, result_a));
5864
}
65+
66+
/// Default empty implementation, used for lax-checking
67+
[@FStar.Tactics.Typeclasses.tcinstance]
68+
val derive_debug (#t: Type) : t_Debug t

hax-lib/proof-libs/fstar/core/Core.Iter.Traits.Iterator.fst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ assume val repeat_with_iter (t: Type0) : Core.Iter.Traits.Iterator.t_Iterator
6868
[@FStar.Tactics.Typeclasses.tcinstance]
6969
assume val flat_map_iter (t: Type0) (u: Type0) (v: Type0) : Core.Iter.Traits.Iterator.t_Iterator
7070
(Core.Iter.Adapters.Flatten.t_FlatMap t u v)
71+
72+
[@FStar.Tactics.Typeclasses.tcinstance]
73+
assume val t_split_iter (pattern: Type) :
74+
(Core.Str.Iter.t_Split pattern) -> t_Iterator (Core.Str.Iter.t_Split pattern)

hax-lib/proof-libs/fstar/core/Core.Mem.fsti

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ open Rust_primitives
44
// FIXME(unsafe!): remove default type (see #545)
55
val size_of (#[FStar.Tactics.exact (`eqtype_as_type unit)]t:Type): unit -> usize
66
val size_of_val (#t:Type) : t -> usize
7+
8+
val drop (#t: Type) (x:t) : Prims.unit

hax-lib/proof-libs/fstar/core/Core.Ops.Arith.fsti

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ class t_DivAssign self rhs = {
5959
}
6060

6161
let f_neg #t x = zero #t -! x
62+
63+
/// Type class implementations
64+
[@FStar.Tactics.Typeclasses.tcinstance]
65+
val impl_float_f_mul : t_Mul float float
66+
[@FStar.Tactics.Typeclasses.tcinstance]
67+
val impl_float_f_add : t_Add float float
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Core.Ops.Drop
2+
3+
class t_Drop (v_Self: Type) = {
4+
f_drop_pre : v_Self -> Type;
5+
f_drop_post : v_Self -> v_Self -> Type;
6+
f_drop : v_Self -> v_Self;
7+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module Core.Ops.Function
2+
3+
[@FStar.Tactics.Typeclasses.tcclass]
4+
class t_FnOnce
5+
(v_Self: Type0) (v_Args: Type0)
6+
= {
7+
f_Output:Type0;
8+
f_call_once_pre:v_Self -> v_Args
9+
-> Type0;
10+
f_call_once_post:
11+
v_Self ->
12+
v_Args ->
13+
f_Output
14+
-> Type0;
15+
f_call_once:x0: v_Self -> x1: v_Args
16+
-> Prims.Pure f_Output
17+
(f_call_once_pre x0 x1)
18+
(fun result ->
19+
f_call_once_post x0 x1 result)
20+
}
21+
22+
[@FStar.Tactics.Typeclasses.tcclass]
23+
class t_Fn (v_Self: Type0) (v_Args: Type0)
24+
= {
25+
[@@@ FStar.Tactics.Typeclasses.no_method]_super_11844238443650317928:t_FnOnce
26+
v_Self v_Args;
27+
f_call_pre:v_Self -> v_Args -> Type0;
28+
f_call_post:v_Self -> v_Args -> _
29+
-> Type0;
30+
f_call:x0: v_Self -> x1: v_Args
31+
-> Prims.Pure _super_11844238443650317928.f_Output
32+
(f_call_pre x0 x1)
33+
(fun result ->
34+
f_call_post x0 x1 result)
35+
}

0 commit comments

Comments
 (0)