diff options
author | Sidney Congard | 2022-06-30 12:22:14 +0200 |
---|---|---|
committer | Sidney Congard | 2022-06-30 12:22:14 +0200 |
commit | 47691de8fe3dc32a29663d4d8343eb415ce1d81e (patch) | |
tree | 06ac570c7f9eee49987d716e043415ae31c681d0 /tests | |
parent | da118da3e590fbea4e880121837da2ee938837f6 (diff) |
Traduct globals body separately (WIP)
Diffstat (limited to '')
-rw-r--r-- | tests/misc/Constants.fst | 129 | ||||
-rw-r--r-- | tests/misc/Primitives.fst | 3 |
2 files changed, 4 insertions, 128 deletions
diff --git a/tests/misc/Constants.fst b/tests/misc/Constants.fst index 28a9ace7..8419ba43 100644 --- a/tests/misc/Constants.fst +++ b/tests/misc/Constants.fst @@ -5,134 +5,7 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [constants::X0] *) -let x0_fwd : result u32 = Return 0 - -(** [core::num::u32::{8}::MAX] *) -assume val core_num_u32_max_fwd : result u32 - -(** [constants::X1] *) -let x1_fwd : result u32 = Return 4294967295 - -(** [constants::X2] *) -let x2_fwd : result u32 = Return 3 - (** [constants::incr] *) -let incr_fwd (n : u32) : result u32 = +let incr_fwd (n : u32) : u32 = begin match u32_add n 1 with | Fail -> Fail | Return i -> Return i end -(** [constants::X3] *) -let x3_fwd : result u32 = - begin match incr_fwd 32 with | Fail -> Fail | Return i -> Return i end - -(** [constants::mk_pair0] *) -let mk_pair0_fwd (x : u32) (y : u32) : result (u32 & u32) = Return (x, y) - -(** [constants::Pair] *) -type pair_t (t1 t2 : Type0) = { pair_x : t1; pair_y : t2; } - -(** [constants::mk_pair1] *) -let mk_pair1_fwd (x : u32) (y : u32) : result (pair_t u32 u32) = - Return (Mkpair_t x y) - -(** [constants::P0] *) -let p0_fwd : result (u32 & u32) = - begin match mk_pair0_fwd 0 1 with | Fail -> Fail | Return p -> Return p end - -(** [constants::P1] *) -let p1_fwd : result (pair_t u32 u32) = - begin match mk_pair1_fwd 0 1 with | Fail -> Fail | Return p -> Return p end - -(** [constants::P2] *) -let p2_fwd : result (u32 & u32) = Return (0, 1) - -(** [constants::P3] *) -let p3_fwd : result (pair_t u32 u32) = Return (Mkpair_t 0 1) - -(** [constants::Wrap] *) -type wrap_t (t : Type0) = { wrap_val : t; } - -(** [constants::Wrap::{0}::new] *) -let wrap_new_fwd (t : Type0) (val0 : t) : result (wrap_t t) = - Return (Mkwrap_t val0) - -(** [constants::Y] *) -let y_fwd : result (wrap_t i32) = - begin match wrap_new_fwd i32 2 with | Fail -> Fail | Return w -> Return w end - -(** [constants::unwrap_y] *) -let unwrap_y_fwd : result i32 = - begin match y_fwd with | Fail -> Fail | Return w -> Return w.wrap_val end - -(** [constants::YVAL] *) -let yval_fwd : result i32 = - begin match unwrap_y_fwd with | Fail -> Fail | Return i -> Return i end - -(** [constants::get_z1::Z1] *) -let get_z1_z1_fwd : result i32 = Return 3 - -(** [constants::get_z1] *) -let get_z1_fwd : result i32 = - begin match get_z1_z1_fwd with | Fail -> Fail | Return i -> Return i end - -(** [constants::add] *) -let add_fwd (a : i32) (b : i32) : result i32 = - begin match i32_add a b with | Fail -> Fail | Return i -> Return i end - -(** [constants::Q1] *) -let q1_fwd : result i32 = Return 5 - -(** [constants::Q2] *) -let q2_fwd : result i32 = - begin match q1_fwd with | Fail -> Fail | Return i -> Return i end - -(** [constants::Q3] *) -let q3_fwd : result i32 = - begin match q2_fwd with - | Fail -> Fail - | Return i -> - begin match add_fwd i 3 with | Fail -> Fail | Return i0 -> Return i0 end - end - -(** [constants::get_z2] *) -let get_z2_fwd : result i32 = - begin match get_z1_fwd with - | Fail -> Fail - | Return i -> - begin match q3_fwd with - | Fail -> Fail - | Return i0 -> - begin match add_fwd i i0 with - | Fail -> Fail - | Return i1 -> - begin match q1_fwd with - | Fail -> Fail - | Return i2 -> - begin match add_fwd i2 i1 with - | Fail -> Fail - | Return i3 -> Return i3 - end - end - end - end - end - -(** [constants::S1] *) -let s1_fwd : result u32 = Return 6 - -(** [constants::S2] *) -let s2_fwd : result u32 = - begin match s1_fwd with - | Fail -> Fail - | Return i -> - begin match incr_fwd i with | Fail -> Fail | Return i0 -> Return i0 end - end - -(** [constants::S3] *) -let s3_fwd : result (pair_t u32 u32) = - begin match p3_fwd with | Fail -> Fail | Return p -> Return p end - -(** [constants::S4] *) -let s4_fwd : result (pair_t u32 u32) = - begin match mk_pair1_fwd 7 8 with | Fail -> Fail | Return p -> Return p end - diff --git a/tests/misc/Primitives.fst b/tests/misc/Primitives.fst index fe351f3a..b3da25c2 100644 --- a/tests/misc/Primitives.fst +++ b/tests/misc/Primitives.fst @@ -34,6 +34,9 @@ let bind (#a #b : Type0) (m : result a) (f : a -> result b) : result b = // Monadic assert(...) let massert (b:bool) : result unit = if b then Return () else Fail +// Unwrap a successful result by normalisation (used for globals). +let eval_global (#a : Type0) (x : result a{Return? (normalize_term x)}) : a = Return?.v x + (*** Misc *) type char = FStar.Char.char type string = string |