file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.to_uint8_of_uint8
val to_uint8_of_uint8 (n: nat{n <= 8}) (x: U8.t{U8.v x < pow2 n}) : Lemma (to_uint8 (of_uint8 n x) == x)
val to_uint8_of_uint8 (n: nat{n <= 8}) (x: U8.t{U8.v x < pow2 n}) : Lemma (to_uint8 (of_uint8 n x) == x)
let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 5, "end_line": 44, "start_col": 0, "start_line": 34 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat{n <= 8} -> x: FStar.UInt8.t{FStar.UInt8.v x < Prims.pow2 n} -> FStar.Pervasives.Lemma (ensures LowParse.Spec.BitVector.to_uint8 (LowParse.Spec.BitVector.of_uint8 n x) == x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt8.t", "Prims.op_LessThan", "FStar.UInt8.v", "Prims.pow2", "Prims.op_Equality", "Prims.int", "Prims.bool", "LowParse.Spec.BitVector.to_uint8_of_uint8", "Prims.op_Subtraction", "FStar.UInt8.div", "FStar.UInt8.__uint_to_t", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "LowParse.Spec.BitVector.of_uint8", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.l_or", "LowParse.Spec.BitVector.to_uint8", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec to_uint8_of_uint8 (n: nat{n <= 8}) (x: U8.t{U8.v x < pow2 n}) : Lemma (to_uint8 (of_uint8 n x) == x) =
if n = 0 then () else (assert ((Seq.slice (of_uint8 n x) 0 (n - 1)) `Seq.equal` (of_uint8 (n - 1) (x `U8.div` 2uy))); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy))
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.parse_byte_bv_kind
val parse_byte_bv_kind (n: nat) : Tot parser_kind
val parse_byte_bv_kind (n: nat) : Tot parser_kind
let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal)
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 55, "end_line": 132, "start_col": 0, "start_line": 131 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.parser_kind
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.strong_parser_kind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.ParserKindMetadataTotal", "LowParse.Spec.Base.parser_kind" ]
[]
false
false
false
true
false
let parse_byte_bv_kind (n: nat) : Tot parser_kind =
strong_parser_kind n n (Some ParserKindMetadataTotal)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_extra_bv8
val synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8))
val synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8))
let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 167, "start_col": 0, "start_line": 166 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: LowParse.Spec.Combinators.parse_filter_refine (LowParse.Spec.BitVector.extra_bytes_prop n) -> FStar.BitVector.bv_t (n % 8)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.parse_filter_refine", "FStar.UInt8.t", "LowParse.Spec.BitVector.extra_bytes_prop", "LowParse.Spec.BitVector.of_uint8", "Prims.op_Modulus", "FStar.BitVector.bv_t" ]
[]
false
false
false
false
false
let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) =
of_uint8 (n % 8) x
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.parse_byte_bv
val parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n)))
val parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n)))
let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1)
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 87, "end_line": 146, "start_col": 0, "start_line": 140 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.parser (LowParse.Spec.BitVector.parse_byte_bv_kind n) (FStar.BitVector.bv_t (8 * n))
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "LowParse.Spec.Combinators.parse_ret", "FStar.BitVector.bv_t", "FStar.Mul.op_Star", "FStar.Seq.Base.empty", "Prims.bool", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.BitVector.parse_bv8_kind", "LowParse.Spec.BitVector.parse_byte_bv_kind", "Prims.op_Subtraction", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.BitVector.parse_bv8", "LowParse.Spec.BitVector.parse_byte_bv", "LowParse.Spec.BitVector.synth_byte_bv", "LowParse.Spec.Base.parser", "Prims.unit", "LowParse.Spec.BitVector.parse_byte_bv_kind_eq" ]
[ "recursion" ]
false
false
false
false
false
let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) =
parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` (parse_byte_bv (n - 1))) `parse_synth` (synth_byte_bv (n - 1))
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_byte_bv_injective
val synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))]
val synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))]
let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') )
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 117, "start_col": 0, "start_line": 109 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Combinators.synth_injective (LowParse.Spec.BitVector.synth_byte_bv n)) [SMTPat (LowParse.Spec.Combinators.synth_injective (LowParse.Spec.BitVector.synth_byte_bv n))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.synth_inverse_intro'", "FStar.BitVector.bv_t", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.BitVector.synth_byte_bv_recip", "LowParse.Spec.BitVector.synth_byte_bv", "Prims._assert", "FStar.Seq.Base.equal", "Prims.bool", "Prims.unit", "Prims.op_Multiply", "Prims.l_True", "Prims.squash", "LowParse.Spec.Combinators.synth_injective", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
false
false
true
false
false
let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] =
synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let hd, tl = x in let hd', tl' = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl'))
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_byte_bv
val synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n)))
val synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n)))
let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x)
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 104, "start_col": 0, "start_line": 103 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: (FStar.BitVector.bv_t 8 * FStar.BitVector.bv_t (8 * n)) -> FStar.BitVector.bv_t (8 * (1 + n))
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Pervasives.Native.tuple2", "FStar.BitVector.bv_t", "FStar.Mul.op_Star", "FStar.Seq.Base.append", "Prims.bool", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd", "Prims.op_Addition" ]
[]
false
false
false
false
false
let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) =
Seq.append (fst x) (snd x)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_extra_bv8_inverse
val synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))]
val synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))]
let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x )
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 184, "start_col": 0, "start_line": 179 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Combinators.synth_inverse (LowParse.Spec.BitVector.synth_extra_bv8 n) (LowParse.Spec.BitVector.synth_extra_bv8_recip n)) [ SMTPat (LowParse.Spec.Combinators.synth_inverse (LowParse.Spec.BitVector.synth_extra_bv8 n) (LowParse.Spec.BitVector.synth_extra_bv8_recip n)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.synth_inverse_intro'", "LowParse.Spec.Combinators.parse_filter_refine", "FStar.UInt8.t", "LowParse.Spec.BitVector.extra_bytes_prop", "FStar.BitVector.bv_t", "Prims.op_Modulus", "LowParse.Spec.BitVector.synth_extra_bv8", "LowParse.Spec.BitVector.synth_extra_bv8_recip", "LowParse.Spec.BitVector.of_uint8_to_uint8", "Prims.unit", "Prims.l_True", "Prims.squash", "LowParse.Spec.Combinators.synth_inverse", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
false
false
true
false
false
let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] =
synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.extra_bytes_prop
val extra_bytes_prop (n: nat) (x: U8.t) : Tot bool
val extra_bytes_prop (n: nat) (x: U8.t) : Tot bool
let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8)
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 23, "end_line": 164, "start_col": 0, "start_line": 163 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: FStar.UInt8.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.UInt8.t", "Prims.op_LessThan", "FStar.UInt8.v", "Prims.pow2", "Prims.op_Modulus", "Prims.bool" ]
[]
false
false
false
true
false
let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool =
U8.v x < pow2 (n % 8)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.parse_extra_bv8
val parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8)))
val parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8)))
let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 78, "end_line": 190, "start_col": 0, "start_line": 189 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.parser (LowParse.Spec.BitVector.parse_extra_bv8_kind n) (FStar.BitVector.bv_t (n % 8))
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Int.parse_u8_kind", "LowParse.Spec.Combinators.parse_filter_refine", "FStar.UInt8.t", "LowParse.Spec.BitVector.extra_bytes_prop", "FStar.BitVector.bv_t", "Prims.op_Modulus", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.Int.parse_u8", "LowParse.Spec.BitVector.synth_extra_bv8", "LowParse.Spec.Base.parser", "LowParse.Spec.BitVector.parse_extra_bv8_kind" ]
[]
false
false
false
false
false
let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) =
(parse_u8 `parse_filter` (extra_bytes_prop n)) `parse_synth` (synth_extra_bv8 n)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_extra_bv8_injective
val synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))]
val synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))]
let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x )
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 177, "start_col": 0, "start_line": 172 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Combinators.synth_injective (LowParse.Spec.BitVector.synth_extra_bv8 n) ) [ SMTPat (LowParse.Spec.Combinators.synth_injective (LowParse.Spec.BitVector.synth_extra_bv8 n )) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.synth_inverse_intro'", "FStar.BitVector.bv_t", "Prims.op_Modulus", "FStar.UInt8.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt8.v", "Prims.pow2", "LowParse.Spec.BitVector.synth_extra_bv8_recip", "LowParse.Spec.BitVector.synth_extra_bv8", "LowParse.Spec.BitVector.to_uint8_of_uint8", "Prims.unit", "Prims.l_True", "Prims.squash", "LowParse.Spec.Combinators.synth_injective", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BitVector.extra_bytes_prop", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
false
false
true
false
false
let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] =
synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.to_uint8
val to_uint8 (#n: nat{n <= 8}) (x: BV.bv_t n) : Tot (y: U8.t{U8.v y < pow2 n})
val to_uint8 (#n: nat{n <= 8}) (x: BV.bv_t n) : Tot (y: U8.t{U8.v y < pow2 n})
let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 20, "start_col": 0, "start_line": 10 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.BitVector.bv_t n -> y: FStar.UInt8.t{FStar.UInt8.v y < Prims.pow2 n}
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.BitVector.bv_t", "Prims.op_Equality", "Prims.int", "FStar.UInt8.__uint_to_t", "Prims.bool", "FStar.UInt8.add", "FStar.UInt8.t", "Prims.op_LessThan", "FStar.UInt8.v", "FStar.Seq.Base.index", "Prims.op_Subtraction", "FStar.UInt8.mul", "Prims.pow2", "LowParse.Spec.BitVector.to_uint8", "FStar.Seq.Base.slice" ]
[ "recursion" ]
false
false
false
false
false
let rec to_uint8 (#n: nat{n <= 8}) (x: BV.bv_t n) : Tot (y: U8.t{U8.v y < pow2 n}) =
if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let r:r: U8.t{U8.v r < 2} = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.serialize_extra_bv8
val serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n))
val serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n))
let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) ()
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 198, "start_col": 0, "start_line": 192 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.serializer (LowParse.Spec.BitVector.parse_extra_bv8 n)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Int.parse_u8_kind", "LowParse.Spec.Combinators.parse_filter_refine", "FStar.UInt8.t", "LowParse.Spec.BitVector.extra_bytes_prop", "FStar.BitVector.bv_t", "Prims.op_Modulus", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.Int.parse_u8", "LowParse.Spec.BitVector.synth_extra_bv8", "LowParse.Spec.Combinators.serialize_filter", "LowParse.Spec.Int.serialize_u8", "LowParse.Spec.BitVector.synth_extra_bv8_recip", "LowParse.Spec.Base.serializer", "LowParse.Spec.BitVector.parse_extra_bv8_kind", "LowParse.Spec.BitVector.parse_extra_bv8" ]
[]
false
false
false
false
false
let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) =
serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) ()
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.parse_bv_kind
val parse_bv_kind (n: nat) : Tot parser_kind
val parse_bv_kind (n: nat) : Tot parser_kind
let parse_bv_kind (n: nat) : Tot parser_kind = if n % 8 = 0 then strong_parser_kind (n / 8) (n / 8) (Some ParserKindMetadataTotal) else strong_parser_kind (1 + n / 8) (1 + n / 8) None
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 54, "end_line": 228, "start_col": 0, "start_line": 225 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x) let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] = synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert (synth_bv n (synth_bv_recip n x) `Seq.equal` x) )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.parser_kind
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "LowParse.Spec.Base.strong_parser_kind", "Prims.op_Division", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.ParserKindMetadataTotal", "Prims.bool", "Prims.op_Addition", "FStar.Pervasives.Native.None", "LowParse.Spec.Base.parser_kind" ]
[]
false
false
false
true
false
let parse_bv_kind (n: nat) : Tot parser_kind =
if n % 8 = 0 then strong_parser_kind (n / 8) (n / 8) (Some ParserKindMetadataTotal) else strong_parser_kind (1 + n / 8) (1 + n / 8) None
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.serialize_byte_bv
val serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n))
val serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n))
let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) ()
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 8, "end_line": 159, "start_col": 0, "start_line": 148 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.serializer (LowParse.Spec.BitVector.parse_byte_bv n)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "LowParse.Spec.Combinators.serialize_ret", "FStar.BitVector.bv_t", "FStar.Seq.Base.empty", "Prims.bool", "Prims._assert", "FStar.Seq.Base.equal", "Prims.unit", "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.BitVector.parse_bv8_kind", "LowParse.Spec.BitVector.parse_byte_bv_kind", "Prims.op_Subtraction", "FStar.Pervasives.Native.tuple2", "FStar.Mul.op_Star", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.BitVector.parse_bv8", "LowParse.Spec.BitVector.parse_byte_bv", "LowParse.Spec.BitVector.synth_byte_bv", "LowParse.Spec.Combinators.serialize_nondep_then", "LowParse.Spec.BitVector.serialize_bv8", "LowParse.Spec.BitVector.serialize_byte_bv", "LowParse.Spec.BitVector.synth_byte_bv_recip", "LowParse.Spec.Base.serializer", "LowParse.Spec.BitVector.parse_byte_bv_kind_eq" ]
[ "recursion" ]
false
false
false
false
false
let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) =
parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` (parse_byte_bv (n - 1))) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` (serialize_byte_bv (n - 1))) (synth_byte_bv_recip (n - 1)) ()
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_extra_bv8_recip
val synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n))
val synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n))
let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 12, "end_line": 170, "start_col": 0, "start_line": 169 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: FStar.BitVector.bv_t (n % 8) -> LowParse.Spec.Combinators.parse_filter_refine (LowParse.Spec.BitVector.extra_bytes_prop n)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.BitVector.bv_t", "Prims.op_Modulus", "LowParse.Spec.BitVector.to_uint8", "LowParse.Spec.Combinators.parse_filter_refine", "FStar.UInt8.t", "LowParse.Spec.BitVector.extra_bytes_prop" ]
[]
false
false
false
false
false
let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) =
to_uint8 x
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.of_uint8_to_uint8
val of_uint8_to_uint8 (#n: nat{n <= 8}) (x: BV.bv_t n) : Lemma ((of_uint8 n (to_uint8 x)) `Seq.equal` x)
val of_uint8_to_uint8 (#n: nat{n <= 8}) (x: BV.bv_t n) : Lemma ((of_uint8 n (to_uint8 x)) `Seq.equal` x)
let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 5, "end_line": 62, "start_col": 0, "start_line": 46 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.BitVector.bv_t n -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (LowParse.Spec.BitVector.of_uint8 n (LowParse.Spec.BitVector.to_uint8 x)) x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.BitVector.bv_t", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.UInt8.t", "LowParse.Spec.BitVector.to_uint8", "Prims.op_Subtraction", "FStar.UInt8.div", "FStar.UInt8.__uint_to_t", "Prims.l_or", "FStar.Mul.op_Star", "FStar.UInt8.v", "Prims.op_Addition", "LowParse.Spec.BitVector.of_uint8_to_uint8", "FStar.Seq.Base.seq", "FStar.Seq.Base.slice", "Prims.l_True", "Prims.squash", "FStar.Seq.Base.equal", "LowParse.Spec.BitVector.of_uint8", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec of_uint8_to_uint8 (#n: nat{n <= 8}) (x: BV.bv_t n) : Lemma ((of_uint8 n (to_uint8 x)) `Seq.equal` x) =
if n = 0 then () else let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x'; assert (U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x)); assert (to_uint8 #(n - 1) x' == (to_uint8 x) `U8.div` 2uy); ()
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_bv_injective
val synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))]
val synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))]
let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') )
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 216, "start_col": 0, "start_line": 208 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Combinators.synth_injective (LowParse.Spec.BitVector.synth_bv n)) [SMTPat (LowParse.Spec.Combinators.synth_injective (LowParse.Spec.BitVector.synth_bv n))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.synth_inverse_intro'", "FStar.BitVector.bv_t", "FStar.Pervasives.Native.tuple2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.op_Division", "LowParse.Spec.BitVector.synth_bv_recip", "LowParse.Spec.BitVector.synth_bv", "Prims._assert", "FStar.Seq.Base.equal", "Prims.bool", "Prims.unit", "Prims.op_Multiply", "Prims.l_True", "Prims.squash", "LowParse.Spec.Combinators.synth_injective", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
false
false
true
false
false
let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] =
synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let hd, tl = x in let hd', tl' = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl'))
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_bv
val synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n)
val synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n)
let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x)
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 203, "start_col": 0, "start_line": 202 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: (FStar.BitVector.bv_t (n % 8) * FStar.BitVector.bv_t (8 * (n / 8))) -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Pervasives.Native.tuple2", "FStar.BitVector.bv_t", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.op_Division", "FStar.Seq.Base.append", "Prims.bool", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd" ]
[]
false
false
false
false
false
let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) =
Seq.append (fst x) (snd x)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.parse_bv
val parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n))
val parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n))
let parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n)) = if n % 8 = 0 then parse_byte_bv (n / 8) else ((parse_extra_bv8 n `nondep_then` parse_byte_bv (n / 8)) `parse_synth` synth_bv n)
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 129, "end_line": 231, "start_col": 0, "start_line": 230 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x) let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] = synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert (synth_bv n (synth_bv_recip n x) `Seq.equal` x) ) let parse_bv_kind (n: nat) : Tot parser_kind = if n % 8 = 0 then strong_parser_kind (n / 8) (n / 8) (Some ParserKindMetadataTotal) else strong_parser_kind (1 + n / 8) (1 + n / 8) None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.parser (LowParse.Spec.BitVector.parse_bv_kind n) (FStar.BitVector.bv_t n)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "LowParse.Spec.BitVector.parse_byte_bv", "Prims.op_Division", "Prims.bool", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.BitVector.parse_extra_bv8_kind", "LowParse.Spec.BitVector.parse_byte_bv_kind", "FStar.Pervasives.Native.tuple2", "FStar.BitVector.bv_t", "FStar.Mul.op_Star", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.BitVector.parse_extra_bv8", "LowParse.Spec.BitVector.synth_bv", "LowParse.Spec.Base.parser", "LowParse.Spec.BitVector.parse_bv_kind" ]
[]
false
false
false
false
false
let parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n)) =
if n % 8 = 0 then parse_byte_bv (n / 8) else (((parse_extra_bv8 n) `nondep_then` (parse_byte_bv (n / 8))) `parse_synth` (synth_bv n))
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_bv_recip
val synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))
val synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))
let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x)
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 59, "end_line": 206, "start_col": 0, "start_line": 205 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: FStar.BitVector.bv_t n -> FStar.BitVector.bv_t (n % 8) * FStar.BitVector.bv_t (8 * (n / 8))
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.BitVector.bv_t", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.op_Division", "FStar.Seq.Base.slice", "Prims.bool", "FStar.Seq.Base.length", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
false
false
let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) =
Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x)
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.parse_bounded_bv_payload_kind
val parse_bounded_bv_payload_kind (min: nat) (max: nat{min <= max}) : Tot parser_kind
val parse_bounded_bv_payload_kind (min: nat) (max: nat{min <= max}) : Tot parser_kind
let parse_bounded_bv_payload_kind (min: nat) (max: nat { min <= max }) : Tot parser_kind = strong_parser_kind (if min % 8 = 0 then min / 8 else 1 + min / 8) (if max % 8 = 0 then max / 8 else 1 + max / 8) None
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 8, "end_line": 264, "start_col": 0, "start_line": 257 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x) let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] = synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert (synth_bv n (synth_bv_recip n x) `Seq.equal` x) ) let parse_bv_kind (n: nat) : Tot parser_kind = if n % 8 = 0 then strong_parser_kind (n / 8) (n / 8) (Some ParserKindMetadataTotal) else strong_parser_kind (1 + n / 8) (1 + n / 8) None let parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n)) = if n % 8 = 0 then parse_byte_bv (n / 8) else ((parse_extra_bv8 n `nondep_then` parse_byte_bv (n / 8)) `parse_synth` synth_bv n) let serialize_bv (n: nat) : Tot (serializer (parse_bv n)) = if n % 8 = 0 then serialize_byte_bv (n / 8) else serialize_synth _ (synth_bv n) (serialize_extra_bv8 n `serialize_nondep_then` serialize_byte_bv (n / 8)) (synth_bv_recip n) () (* parse a bounded bit vector *) module U32 = FStar.UInt32 open LowParse.Spec.BoundedInt inline_for_extraction let bounded_bv_t (min: nat) (max: nat { min <= max }) : Tot Type = (bitsize: bounded_int32 min max & BV.bv_t (U32.v bitsize))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max} -> LowParse.Spec.Base.parser_kind
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Spec.Base.strong_parser_kind", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Prims.bool", "Prims.op_Addition", "FStar.Pervasives.Native.None", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.parser_kind" ]
[]
false
false
false
false
false
let parse_bounded_bv_payload_kind (min: nat) (max: nat{min <= max}) : Tot parser_kind =
strong_parser_kind (if min % 8 = 0 then min / 8 else 1 + min / 8) (if max % 8 = 0 then max / 8 else 1 + max / 8) None
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.synth_bv_inverse
val synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))]
val synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))]
let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] = synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert (synth_bv n (synth_bv_recip n x) `Seq.equal` x) )
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 223, "start_col": 0, "start_line": 218 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x) let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Combinators.synth_inverse (LowParse.Spec.BitVector.synth_bv n) (LowParse.Spec.BitVector.synth_bv_recip n)) [ SMTPat (LowParse.Spec.Combinators.synth_inverse (LowParse.Spec.BitVector.synth_bv n) (LowParse.Spec.BitVector.synth_bv_recip n)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Combinators.synth_inverse_intro'", "FStar.Pervasives.Native.tuple2", "FStar.BitVector.bv_t", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.op_Division", "FStar.Seq.Base.seq", "Prims.bool", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "LowParse.Spec.BitVector.synth_bv", "LowParse.Spec.BitVector.synth_bv_recip", "Prims._assert", "FStar.Seq.Base.equal", "Prims.unit", "Prims.l_True", "Prims.squash", "LowParse.Spec.Combinators.synth_inverse", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
false
false
true
false
false
let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] =
synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert ((synth_bv n (synth_bv_recip n x)) `Seq.equal` x))
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.parse_bounded_bv
val parse_bounded_bv (min: nat) (max: nat{min <= max}) (#hk: parser_kind) (hp: parser hk (bounded_int32 min max)) : Tot (parser (parse_bounded_bv_kind min max hk) (bounded_bv_t min max))
val parse_bounded_bv (min: nat) (max: nat{min <= max}) (#hk: parser_kind) (hp: parser hk (bounded_int32 min max)) : Tot (parser (parse_bounded_bv_kind min max hk) (bounded_bv_t min max))
let parse_bounded_bv (min: nat) (max: nat { min <= max }) (#hk: parser_kind) (hp: parser hk (bounded_int32 min max)) : Tot (parser (parse_bounded_bv_kind min max hk) (bounded_bv_t min max)) = parse_dtuple2 hp (fun (sz: bounded_int32 min max) -> weaken (parse_bounded_bv_payload_kind min max) (parse_bv (U32.v sz)))
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 109, "end_line": 295, "start_col": 0, "start_line": 287 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x) let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] = synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert (synth_bv n (synth_bv_recip n x) `Seq.equal` x) ) let parse_bv_kind (n: nat) : Tot parser_kind = if n % 8 = 0 then strong_parser_kind (n / 8) (n / 8) (Some ParserKindMetadataTotal) else strong_parser_kind (1 + n / 8) (1 + n / 8) None let parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n)) = if n % 8 = 0 then parse_byte_bv (n / 8) else ((parse_extra_bv8 n `nondep_then` parse_byte_bv (n / 8)) `parse_synth` synth_bv n) let serialize_bv (n: nat) : Tot (serializer (parse_bv n)) = if n % 8 = 0 then serialize_byte_bv (n / 8) else serialize_synth _ (synth_bv n) (serialize_extra_bv8 n `serialize_nondep_then` serialize_byte_bv (n / 8)) (synth_bv_recip n) () (* parse a bounded bit vector *) module U32 = FStar.UInt32 open LowParse.Spec.BoundedInt inline_for_extraction let bounded_bv_t (min: nat) (max: nat { min <= max }) : Tot Type = (bitsize: bounded_int32 min max & BV.bv_t (U32.v bitsize)) let parse_bounded_bv_payload_kind (min: nat) (max: nat { min <= max }) : Tot parser_kind = strong_parser_kind (if min % 8 = 0 then min / 8 else 1 + min / 8) (if max % 8 = 0 then max / 8 else 1 + max / 8) None let parse_bounded_bv_payload_kind_is_weaker_than_parse_bv_kind (min: nat) (max: nat) (n: nat) : Lemma (requires (min <= n /\ n <= max)) (ensures ( min <= n /\ n <= max /\ parse_bounded_bv_payload_kind min max `is_weaker_than` parse_bv_kind n )) [SMTPat (parse_bounded_bv_payload_kind min max `is_weaker_than` parse_bv_kind n)] = () let parse_bounded_bv_kind (min: nat) (max: nat { min <= max }) (hk: parser_kind) : Tot parser_kind = hk `and_then_kind` parse_bounded_bv_payload_kind min max
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max} -> hp: LowParse.Spec.Base.parser hk (LowParse.Spec.BoundedInt.bounded_int32 min max) -> LowParse.Spec.Base.parser (LowParse.Spec.BitVector.parse_bounded_bv_kind min max hk) (LowParse.Spec.BitVector.bounded_bv_t min max)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_dtuple2", "LowParse.Spec.BitVector.parse_bounded_bv_payload_kind", "FStar.BitVector.bv_t", "FStar.UInt32.v", "LowParse.Spec.Base.weaken", "LowParse.Spec.BitVector.parse_bv_kind", "LowParse.Spec.BitVector.parse_bv", "LowParse.Spec.BitVector.parse_bounded_bv_kind", "LowParse.Spec.BitVector.bounded_bv_t" ]
[]
false
false
false
false
false
let parse_bounded_bv (min: nat) (max: nat{min <= max}) (#hk: parser_kind) (hp: parser hk (bounded_int32 min max)) : Tot (parser (parse_bounded_bv_kind min max hk) (bounded_bv_t min max)) =
parse_dtuple2 hp (fun (sz: bounded_int32 min max) -> weaken (parse_bounded_bv_payload_kind min max) (parse_bv (U32.v sz)))
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.serialize_bv
val serialize_bv (n: nat) : Tot (serializer (parse_bv n))
val serialize_bv (n: nat) : Tot (serializer (parse_bv n))
let serialize_bv (n: nat) : Tot (serializer (parse_bv n)) = if n % 8 = 0 then serialize_byte_bv (n / 8) else serialize_synth _ (synth_bv n) (serialize_extra_bv8 n `serialize_nondep_then` serialize_byte_bv (n / 8)) (synth_bv_recip n) ()
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 8, "end_line": 242, "start_col": 0, "start_line": 233 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x) let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] = synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert (synth_bv n (synth_bv_recip n x) `Seq.equal` x) ) let parse_bv_kind (n: nat) : Tot parser_kind = if n % 8 = 0 then strong_parser_kind (n / 8) (n / 8) (Some ParserKindMetadataTotal) else strong_parser_kind (1 + n / 8) (1 + n / 8) None let parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n)) = if n % 8 = 0 then parse_byte_bv (n / 8) else ((parse_extra_bv8 n `nondep_then` parse_byte_bv (n / 8)) `parse_synth` synth_bv n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> LowParse.Spec.Base.serializer (LowParse.Spec.BitVector.parse_bv n)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "LowParse.Spec.BitVector.serialize_byte_bv", "Prims.op_Division", "Prims.bool", "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.BitVector.parse_extra_bv8_kind", "LowParse.Spec.BitVector.parse_byte_bv_kind", "FStar.Pervasives.Native.tuple2", "FStar.BitVector.bv_t", "FStar.Mul.op_Star", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.BitVector.parse_extra_bv8", "LowParse.Spec.BitVector.parse_byte_bv", "LowParse.Spec.BitVector.synth_bv", "LowParse.Spec.Combinators.serialize_nondep_then", "LowParse.Spec.BitVector.serialize_extra_bv8", "LowParse.Spec.BitVector.synth_bv_recip", "LowParse.Spec.Base.serializer", "LowParse.Spec.BitVector.parse_bv_kind", "LowParse.Spec.BitVector.parse_bv" ]
[]
false
false
false
false
false
let serialize_bv (n: nat) : Tot (serializer (parse_bv n)) =
if n % 8 = 0 then serialize_byte_bv (n / 8) else serialize_synth _ (synth_bv n) ((serialize_extra_bv8 n) `serialize_nondep_then` (serialize_byte_bv (n / 8))) (synth_bv_recip n) ()
false
LowParse.Spec.BitVector.fst
LowParse.Spec.BitVector.serialize_bounded_bv
val serialize_bounded_bv (min: nat) (max: nat{min <= max}) (#hk: parser_kind) (#hp: parser hk (bounded_int32 min max)) (hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong}) : Tot (serializer (parse_bounded_bv min max hp))
val serialize_bounded_bv (min: nat) (max: nat{min <= max}) (#hk: parser_kind) (#hp: parser hk (bounded_int32 min max)) (hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong}) : Tot (serializer (parse_bounded_bv min max hp))
let serialize_bounded_bv (min: nat) (max: nat { min <= max }) (#hk: parser_kind) (#hp: parser hk (bounded_int32 min max)) (hs: serializer hp { hk.parser_kind_subkind == Some ParserStrong }) : Tot (serializer (parse_bounded_bv min max hp)) = serialize_dtuple2 hs (fun (sz: bounded_int32 min max) -> serialize_weaken (parse_bounded_bv_payload_kind min max) (serialize_bv (U32.v sz)))
{ "file_name": "src/lowparse/LowParse.Spec.BitVector.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 123, "end_line": 306, "start_col": 0, "start_line": 297 }
module LowParse.Spec.BitVector open FStar.Mul module BV = FStar.BitVector module U8 = FStar.UInt8 module Seq = FStar.Seq (* Big-endian conversion of a bit vector to a UInt8 *) let rec to_uint8 (#n: nat { n <= 8 }) (x: BV.bv_t n) : Tot (y: U8.t { U8.v y < pow2 n }) = if n = 0 then 0uy else let hi = to_uint8 #(n - 1) (Seq.slice x 0 (n - 1)) in let hi' = hi `U8.mul` 2uy in let (r: U8.t { U8.v r < 2 }) = if Seq.index x (n - 1) then 1uy else 0uy in hi' `U8.add` r let rec of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Tot (BV.bv_t n) = if n = 0 then Seq.empty else let hi = of_uint8 (n - 1) (x `U8.div` 2uy) in Seq.snoc hi (x `U8.rem` 2uy = 1uy) #push-options "--z3rlimit 32" let rec to_uint8_of_uint8 (n: nat { n <= 8 }) (x: U8.t { U8.v x < pow2 n }) : Lemma (to_uint8 (of_uint8 n x) == x) = if n = 0 then () else begin assert (Seq.slice (of_uint8 n x) 0 (n - 1) `Seq.equal` of_uint8 (n - 1) (x `U8.div` 2uy)); to_uint8_of_uint8 (n - 1) (x `U8.div` 2uy) end let rec of_uint8_to_uint8 (#n: nat {n <= 8}) (x: BV.bv_t n) : Lemma (of_uint8 n (to_uint8 x) `Seq.equal` x) = if n = 0 then () else begin let x' = Seq.slice x 0 (n - 1) in of_uint8_to_uint8 #(n - 1) x' ; assert ( U8.v (to_uint8 #(n - 1) x') * 2 == U8.v (to_uint8 x) \/ U8.v (to_uint8 #(n - 1) x') * 2 + 1 == U8.v (to_uint8 x) ); assert (to_uint8 #(n - 1) x' == to_uint8 x `U8.div` 2uy); () end #pop-options (* parse a 8-bit vector *) open LowParse.Spec.Combinators open LowParse.Spec.Int let synth_bv8 (x: U8.t) : Tot (BV.bv_t 8) = of_uint8 8 x let synth_bv8_recip (x: BV.bv_t 8) : Tot U8.t = to_uint8 x let synth_bv8_injective : squash (synth_injective synth_bv8) = synth_inverse_intro' synth_bv8_recip synth_bv8 (fun x -> to_uint8_of_uint8 8 x ) let synth_bv8_inverse : squash (synth_inverse synth_bv8 synth_bv8_recip) = synth_inverse_intro' synth_bv8 synth_bv8_recip (fun x -> of_uint8_to_uint8 x ) let parse_bv8_kind = parse_u8_kind let parse_bv8 : parser parse_bv8_kind (BV.bv_t 8) = parse_u8 `parse_synth` synth_bv8 let serialize_bv8 : serializer parse_bv8 = serialize_synth parse_u8 synth_bv8 serialize_u8 synth_bv8_recip () (* parse a 8*n bit vector *) let synth_byte_bv (n: nat) (x: (BV.bv_t 8 & BV.bv_t (8 * n))) : Tot (BV.bv_t (8 * (1 + n))) = Seq.append (fst x) (snd x) let synth_byte_bv_recip (n: nat) (x: BV.bv_t (8 * (1 + n))) : Tot (BV.bv_t 8 & BV.bv_t (8 * n)) = Seq.slice x 0 8, Seq.slice x 8 (Seq.length x) let synth_byte_bv_injective (n: nat) : Lemma (synth_injective (synth_byte_bv n)) [SMTPat (synth_injective (synth_byte_bv n))] = synth_inverse_intro' (synth_byte_bv_recip n) (synth_byte_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_byte_bv_recip n (synth_byte_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_byte_bv_inverse (n: nat) : Lemma (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n)) [SMTPat (synth_inverse (synth_byte_bv n) (synth_byte_bv_recip n))] = synth_inverse_intro' (synth_byte_bv n) (synth_byte_bv_recip n) (fun x -> assert (synth_byte_bv n (synth_byte_bv_recip n x) `Seq.equal` x) ) let rec parse_byte_bv_kind' (n: nat) : Tot parser_kind = if n = 0 then parse_ret_kind else parse_bv8_kind `and_then_kind` parse_byte_bv_kind' (n - 1) let parse_byte_bv_kind (n: nat) : Tot parser_kind = strong_parser_kind n n (Some ParserKindMetadataTotal) let rec parse_byte_bv_kind_eq (n: nat) : Lemma (parse_byte_bv_kind n == parse_byte_bv_kind' n) = if n = 0 then () else parse_byte_bv_kind_eq (n - 1) let rec parse_byte_bv (n: nat) : Tot (parser (parse_byte_bv_kind n) (BV.bv_t (8 * n))) = parse_byte_bv_kind_eq n; if n = 0 then parse_ret Seq.empty else (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) `parse_synth` synth_byte_bv (n - 1) let rec serialize_byte_bv (n: nat) : Tot (serializer (parse_byte_bv n)) = parse_byte_bv_kind_eq n; if n = 0 then serialize_ret Seq.empty (fun (x: BV.bv_t 0) -> assert (x `Seq.equal` Seq.empty)) else serialize_synth (parse_bv8 `nondep_then` parse_byte_bv (n - 1)) (synth_byte_bv (n - 1)) (serialize_bv8 `serialize_nondep_then` serialize_byte_bv (n - 1)) (synth_byte_bv_recip (n - 1)) () (* parse extra bits (big-endian with the first bits equal to 0) *) let extra_bytes_prop (n: nat) (x: U8.t) : Tot bool = U8.v x < pow2 (n % 8) let synth_extra_bv8 (n: nat) (x: parse_filter_refine (extra_bytes_prop n)) : Tot (BV.bv_t (n % 8)) = of_uint8 (n % 8) x let synth_extra_bv8_recip (n: nat) (x: BV.bv_t (n % 8)) : Tot (parse_filter_refine (extra_bytes_prop n)) = to_uint8 x let synth_extra_bv8_injective (n: nat) : Lemma (synth_injective (synth_extra_bv8 n)) [SMTPat (synth_injective (synth_extra_bv8 n))] = synth_inverse_intro' (synth_extra_bv8_recip n) (synth_extra_bv8 n) (fun x -> to_uint8_of_uint8 (n % 8) x ) let synth_extra_bv8_inverse (n: nat) : Lemma (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n)) [SMTPat (synth_inverse (synth_extra_bv8 n) (synth_extra_bv8_recip n))] = synth_inverse_intro' (synth_extra_bv8 n) (synth_extra_bv8_recip n) (fun x -> of_uint8_to_uint8 x ) let parse_extra_bv8_kind (n: nat) : Tot parser_kind = parse_filter_kind parse_u8_kind let parse_extra_bv8 (n: nat) : Tot (parser (parse_extra_bv8_kind n) (BV.bv_t (n % 8))) = (parse_u8 `parse_filter` extra_bytes_prop n) `parse_synth` synth_extra_bv8 n let serialize_extra_bv8 (n: nat) : Tot (serializer (parse_extra_bv8 n)) = serialize_synth _ (synth_extra_bv8 n) (serialize_filter serialize_u8 (extra_bytes_prop n)) (synth_extra_bv8_recip n) () (* parse a bitvector, general *) let synth_bv (n: nat) (x: (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8)))) : Tot (BV.bv_t n) = Seq.append (fst x) (snd x) let synth_bv_recip (n: nat) (x: BV.bv_t n) : Tot (BV.bv_t (n % 8) & BV.bv_t (8 * (n / 8))) = Seq.slice x 0 (n % 8), Seq.slice x (n % 8) (Seq.length x) let synth_bv_injective (n: nat) : Lemma (synth_injective (synth_bv n)) [SMTPat (synth_injective (synth_bv n))] = synth_inverse_intro' (synth_bv_recip n) (synth_bv n) (fun x -> let (hd, tl) = x in let (hd', tl') = synth_bv_recip n (synth_bv n x) in assert (hd `Seq.equal` hd'); assert (tl `Seq.equal` tl') ) let synth_bv_inverse (n: nat) : Lemma (synth_inverse (synth_bv n) (synth_bv_recip n)) [SMTPat (synth_inverse (synth_bv n) (synth_bv_recip n))] = synth_inverse_intro' (synth_bv n) (synth_bv_recip n) (fun x -> assert (synth_bv n (synth_bv_recip n x) `Seq.equal` x) ) let parse_bv_kind (n: nat) : Tot parser_kind = if n % 8 = 0 then strong_parser_kind (n / 8) (n / 8) (Some ParserKindMetadataTotal) else strong_parser_kind (1 + n / 8) (1 + n / 8) None let parse_bv (n: nat) : Tot (parser (parse_bv_kind n) (BV.bv_t n)) = if n % 8 = 0 then parse_byte_bv (n / 8) else ((parse_extra_bv8 n `nondep_then` parse_byte_bv (n / 8)) `parse_synth` synth_bv n) let serialize_bv (n: nat) : Tot (serializer (parse_bv n)) = if n % 8 = 0 then serialize_byte_bv (n / 8) else serialize_synth _ (synth_bv n) (serialize_extra_bv8 n `serialize_nondep_then` serialize_byte_bv (n / 8)) (synth_bv_recip n) () (* parse a bounded bit vector *) module U32 = FStar.UInt32 open LowParse.Spec.BoundedInt inline_for_extraction let bounded_bv_t (min: nat) (max: nat { min <= max }) : Tot Type = (bitsize: bounded_int32 min max & BV.bv_t (U32.v bitsize)) let parse_bounded_bv_payload_kind (min: nat) (max: nat { min <= max }) : Tot parser_kind = strong_parser_kind (if min % 8 = 0 then min / 8 else 1 + min / 8) (if max % 8 = 0 then max / 8 else 1 + max / 8) None let parse_bounded_bv_payload_kind_is_weaker_than_parse_bv_kind (min: nat) (max: nat) (n: nat) : Lemma (requires (min <= n /\ n <= max)) (ensures ( min <= n /\ n <= max /\ parse_bounded_bv_payload_kind min max `is_weaker_than` parse_bv_kind n )) [SMTPat (parse_bounded_bv_payload_kind min max `is_weaker_than` parse_bv_kind n)] = () let parse_bounded_bv_kind (min: nat) (max: nat { min <= max }) (hk: parser_kind) : Tot parser_kind = hk `and_then_kind` parse_bounded_bv_payload_kind min max let parse_bounded_bv (min: nat) (max: nat { min <= max }) (#hk: parser_kind) (hp: parser hk (bounded_int32 min max)) : Tot (parser (parse_bounded_bv_kind min max hk) (bounded_bv_t min max)) = parse_dtuple2 hp (fun (sz: bounded_int32 min max) -> weaken (parse_bounded_bv_payload_kind min max) (parse_bv (U32.v sz)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BitVector.fst" }
[ { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.BitVector", "short_module": "BV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max} -> hs: LowParse.Spec.Base.serializer hp { Mkparser_kind'?.parser_kind_subkind hk == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> LowParse.Spec.Base.serializer (LowParse.Spec.BitVector.parse_bounded_bv min max hp)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "LowParse.Spec.Combinators.serialize_dtuple2", "LowParse.Spec.BitVector.parse_bounded_bv_payload_kind", "FStar.BitVector.bv_t", "FStar.UInt32.v", "LowParse.Spec.Base.weaken", "LowParse.Spec.BitVector.parse_bv_kind", "LowParse.Spec.BitVector.parse_bv", "LowParse.Spec.Combinators.serialize_weaken", "LowParse.Spec.BitVector.serialize_bv", "LowParse.Spec.BitVector.parse_bounded_bv_kind", "LowParse.Spec.BitVector.bounded_bv_t", "LowParse.Spec.BitVector.parse_bounded_bv" ]
[]
false
false
false
false
false
let serialize_bounded_bv (min: nat) (max: nat{min <= max}) (#hk: parser_kind) (#hp: parser hk (bounded_int32 min max)) (hs: serializer hp {hk.parser_kind_subkind == Some ParserStrong}) : Tot (serializer (parse_bounded_bv min max hp)) =
serialize_dtuple2 hs (fun (sz: bounded_int32 min max) -> serialize_weaken (parse_bounded_bv_payload_kind min max) (serialize_bv (U32.v sz)))
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.pure_hoare_effect_qn
val pure_hoare_effect_qn : Prims.string
let pure_hoare_effect_qn = "Prims.Pure"
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 21, "start_col": 0, "start_line": 21 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.string
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let pure_hoare_effect_qn =
"Prims.Pure"
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.pure_effect_qn
val pure_effect_qn : Prims.string
let pure_effect_qn = "Prims.PURE"
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 20, "start_col": 0, "start_line": 20 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.string
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let pure_effect_qn =
"Prims.PURE"
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.st_effect_qn
val st_effect_qn : Prims.string
let st_effect_qn = "FStar.HyperStack.ST.ST"
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 23, "start_col": 0, "start_line": 23 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.string
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let st_effect_qn =
"FStar.HyperStack.ST.ST"
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.stack_effect_qn
val stack_effect_qn : Prims.string
let stack_effect_qn = "FStar.HyperStack.ST.Stack"
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 22, "start_col": 0, "start_line": 22 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.string
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let stack_effect_qn =
"FStar.HyperStack.ST.Stack"
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.effect_name_to_type
val effect_name_to_type (ename : name) : Tot effect_type
val effect_name_to_type (ename : name) : Tot effect_type
let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 65, "start_col": 0, "start_line": 59 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ename: FStar.Stubs.Reflection.Types.name -> FStar.InteractiveHelpers.ExploreTerm.effect_type
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.name", "Prims.op_Equality", "Prims.string", "FStar.InteractiveHelpers.ExploreTerm.pure_effect_qn", "FStar.InteractiveHelpers.ExploreTerm.E_PURE", "Prims.bool", "FStar.InteractiveHelpers.ExploreTerm.pure_hoare_effect_qn", "FStar.InteractiveHelpers.ExploreTerm.E_Pure", "FStar.InteractiveHelpers.ExploreTerm.stack_effect_qn", "FStar.InteractiveHelpers.ExploreTerm.E_Stack", "FStar.InteractiveHelpers.ExploreTerm.st_effect_qn", "FStar.InteractiveHelpers.ExploreTerm.E_ST", "FStar.InteractiveHelpers.ExploreTerm.E_Unknown", "FStar.InteractiveHelpers.ExploreTerm.effect_type", "FStar.Reflection.V1.Derived.flatten_name" ]
[]
false
false
false
true
false
let effect_name_to_type (ename: name) : Tot effect_type =
let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.mk_type_info
val mk_type_info : ty: FStar.Stubs.Reflection.Types.typ -> refin: FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.term -> FStar.InteractiveHelpers.ExploreTerm.type_info
let mk_type_info = Mktype_info
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 79, "start_col": 0, "start_line": 79 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ty: FStar.Stubs.Reflection.Types.typ -> refin: FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.term -> FStar.InteractiveHelpers.ExploreTerm.type_info
Prims.Tot
[ "total" ]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.Mktype_info" ]
[]
false
false
false
true
false
let mk_type_info =
Mktype_info
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.type_info_to_string
val type_info_to_string : type_info -> Tac string
val type_info_to_string : type_info -> Tac string
let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")"
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 85, "start_col": 0, "start_line": 82 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
info: FStar.InteractiveHelpers.ExploreTerm.type_info -> FStar.Tactics.Effect.Tac Prims.string
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.type_info", "Prims.op_Hat", "Prims.string", "FStar.InteractiveHelpers.Base.option_to_string", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Tactics.V1.Builtins.term_to_string", "FStar.InteractiveHelpers.ExploreTerm.__proj__Mktype_info__item__refin", "FStar.InteractiveHelpers.ExploreTerm.__proj__Mktype_info__item__ty" ]
[]
false
true
false
false
false
let type_info_to_string info =
"Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")"
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.unit_type_info
val unit_type_info : FStar.InteractiveHelpers.ExploreTerm.type_info
let unit_type_info = mk_type_info (`unit) None
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 87, "start_col": 0, "start_line": 87 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.InteractiveHelpers.ExploreTerm.type_info
Prims.Tot
[ "total" ]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.mk_type_info", "FStar.Pervasives.Native.None", "FStar.Stubs.Reflection.Types.term" ]
[]
false
false
false
true
false
let unit_type_info =
mk_type_info (`unit) None
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.safe_tc
val safe_tc (e:env) (t:term) : Tac (option term)
val safe_tc (e:env) (t:term) : Tac (option term)
let safe_tc e t = try Some (tc e t) with | _ -> None
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 91, "start_col": 0, "start_line": 90 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.term)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.try_with", "FStar.Pervasives.Native.option", "Prims.unit", "FStar.Pervasives.Native.Some", "FStar.Stubs.Tactics.V1.Builtins.tc", "Prims.exn", "FStar.Pervasives.Native.None" ]
[]
false
true
false
false
false
let safe_tc e t =
try Some (tc e t) with | _ -> None
false
Steel.Utils.fst
Steel.Utils.change_slprop_ens
val change_slprop_ens (p q: vprop) (r: prop) (f: (m: mem -> Lemma (requires interp (hp_of p) m) (ensures interp (hp_of q) m /\ r))) : Steel unit p (fun _ -> q) (requires fun _ -> True) (ensures fun _ _ _ -> r)
val change_slprop_ens (p q: vprop) (r: prop) (f: (m: mem -> Lemma (requires interp (hp_of p) m) (ensures interp (hp_of q) m /\ r))) : Steel unit p (fun _ -> q) (requires fun _ -> True) (ensures fun _ _ _ -> r)
let change_slprop_ens (p:vprop) (q:vprop) (r:prop) (f:(m:mem -> Lemma (requires interp (hp_of p) m) (ensures interp (hp_of q) m /\ r))) : Steel unit p (fun _ -> q) (requires fun _ -> True) (ensures fun _ _ _ -> r) = rewrite_slprop p (q `star` pure r) (fun m -> f m; Steel.Memory.emp_unit (hp_of q); Steel.Memory.pure_star_interp (hp_of q) r m); elim_pure r
{ "file_name": "lib/steel/Steel.Utils.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 15, "end_line": 44, "start_col": 0, "start_line": 37 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Utils open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference let pts_to_not_null (#a:Type) (#opened:inames) (#p:perm) (#v:FStar.Ghost.erased a) (r:ref a) : SteelGhost unit opened (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> r =!= null) = extract_info_raw (pts_to r p v) (r =!= null) (fun m -> pts_to_not_null r p v m)
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Utils.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Effect.Common.vprop -> q: Steel.Effect.Common.vprop -> r: Prims.prop -> f: (m: Steel.Memory.mem -> FStar.Pervasives.Lemma (requires Steel.Memory.interp (Steel.Effect.Common.hp_of p) m) (ensures Steel.Memory.interp (Steel.Effect.Common.hp_of q) m /\ r)) -> Steel.Effect.Steel Prims.unit
Steel.Effect.Steel
[]
[]
[ "Steel.Effect.Common.vprop", "Prims.prop", "Steel.Memory.mem", "Prims.unit", "Steel.Memory.interp", "Steel.Effect.Common.hp_of", "Prims.squash", "Prims.l_and", "Prims.Nil", "FStar.Pervasives.pattern", "Steel.Effect.Atomic.elim_pure", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Atomic.rewrite_slprop", "Steel.Effect.Common.star", "Steel.Effect.Common.pure", "Steel.Memory.pure_star_interp", "Steel.Memory.emp_unit", "Steel.Effect.Common.rmem", "Prims.l_True" ]
[]
false
true
false
false
false
let change_slprop_ens (p q: vprop) (r: prop) (f: (m: mem -> Lemma (requires interp (hp_of p) m) (ensures interp (hp_of q) m /\ r))) : Steel unit p (fun _ -> q) (requires fun _ -> True) (ensures fun _ _ _ -> r) =
rewrite_slprop p (q `star` (pure r)) (fun m -> f m; Steel.Memory.emp_unit (hp_of q); Steel.Memory.pure_star_interp (hp_of q) r m); elim_pure r
false
Steel.Utils.fst
Steel.Utils.extract_pure
val extract_pure (p: prop) : Steel unit (pure p) (fun _ -> pure p) (fun _ -> True) (fun _ _ _ -> p)
val extract_pure (p: prop) : Steel unit (pure p) (fun _ -> pure p) (fun _ -> True) (fun _ _ _ -> p)
let extract_pure (p:prop) : Steel unit (pure p) (fun _ -> pure p) (fun _ -> True) (fun _ _ _ -> p) = elim_pure p; intro_pure p
{ "file_name": "lib/steel/Steel.Utils.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 59, "start_col": 0, "start_line": 56 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Utils open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference let pts_to_not_null (#a:Type) (#opened:inames) (#p:perm) (#v:FStar.Ghost.erased a) (r:ref a) : SteelGhost unit opened (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> r =!= null) = extract_info_raw (pts_to r p v) (r =!= null) (fun m -> pts_to_not_null r p v m) let change_slprop_ens (p:vprop) (q:vprop) (r:prop) (f:(m:mem -> Lemma (requires interp (hp_of p) m) (ensures interp (hp_of q) m /\ r))) : Steel unit p (fun _ -> q) (requires fun _ -> True) (ensures fun _ _ _ -> r) = rewrite_slprop p (q `star` pure r) (fun m -> f m; Steel.Memory.emp_unit (hp_of q); Steel.Memory.pure_star_interp (hp_of q) r m); elim_pure r let pure_as_ens (#p:prop) () : Steel unit (pure p) (fun _ -> pure p) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_ens (pure p) (pure p) p (Steel.Memory.pure_interp p) let rewrite #a (#p:a -> vprop) (x y:a) : Steel unit (p x) (fun _ -> p y) (requires fun _ -> x == y) (ensures fun _ _ _ -> True) = rewrite_slprop (p x) (p y) (fun _ -> ())
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Utils.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> Steel.Effect.Steel Prims.unit
Steel.Effect.Steel
[]
[]
[ "Prims.prop", "Steel.Effect.Atomic.intro_pure", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.unit", "Steel.Effect.Atomic.elim_pure", "Steel.Effect.Common.pure", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_True" ]
[]
false
true
false
false
false
let extract_pure (p: prop) : Steel unit (pure p) (fun _ -> pure p) (fun _ -> True) (fun _ _ _ -> p) =
elim_pure p; intro_pure p
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.safe_tcc
val safe_tcc (e:env) (t:term) : Tac (option comp)
val safe_tcc (e:env) (t:term) : Tac (option comp)
let safe_tcc e t = try Some (tcc e t) with | _ -> None
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 95, "start_col": 0, "start_line": 94 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.comp)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.try_with", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.comp", "Prims.unit", "FStar.Pervasives.Native.Some", "FStar.Stubs.Tactics.V1.Builtins.tcc", "Prims.exn", "FStar.Pervasives.Native.None" ]
[]
false
true
false
false
false
let safe_tcc e t =
try Some (tcc e t) with | _ -> None
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.get_total_or_gtotal_ret_type
val get_total_or_gtotal_ret_type : comp -> Tot (option typ)
val get_total_or_gtotal_ret_type : comp -> Tot (option typ)
let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 120, "start_col": 0, "start_line": 117 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: FStar.Stubs.Reflection.Types.comp -> FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.typ
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V1.Builtins.inspect_comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Pervasives.Native.Some", "FStar.Stubs.Reflection.V1.Data.comp_view", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
false
false
false
true
false
let get_total_or_gtotal_ret_type c =
match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.get_type_info_from_type
val get_type_info_from_type (ty: typ) : Tac type_info
val get_type_info_from_type (ty: typ) : Tac type_info
let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 107, "start_col": 0, "start_line": 97 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ty: FStar.Stubs.Reflection.Types.typ -> FStar.Tactics.Effect.Tac FStar.InteractiveHelpers.ExploreTerm.type_info
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.term", "FStar.InteractiveHelpers.ExploreTerm.mk_type_info", "FStar.Pervasives.Native.Some", "FStar.InteractiveHelpers.ExploreTerm.type_info", "FStar.Stubs.Tactics.V1.Builtins.pack", "FStar.Stubs.Reflection.V1.Data.Tv_Abs", "FStar.InteractiveHelpers.Base.prettify_term", "FStar.Stubs.Reflection.Types.binder", "FStar.Reflection.V1.Derived.mk_binder", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Pervasives.Native.None", "FStar.Stubs.Tactics.V1.Builtins.inspect" ]
[]
false
true
false
false
false
let get_type_info_from_type (ty: typ) : Tac type_info =
match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b:binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.comp_qualifier
val comp_qualifier (c : comp) : Tac string
val comp_qualifier (c : comp) : Tac string
let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff"
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 35, "start_col": 0, "start_line": 30 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: FStar.Stubs.Reflection.Types.comp -> FStar.Tactics.Effect.Tac Prims.string
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V1.Builtins.inspect_comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Data.universes", "FStar.Stubs.Reflection.Types.name", "Prims.list", "FStar.Stubs.Reflection.V1.Data.argv", "Prims.string" ]
[]
false
true
false
false
false
let comp_qualifier (c: comp) : Tac string =
match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff"
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.is_unit_type
val is_unit_type : typ -> Tac bool
val is_unit_type : typ -> Tac bool
let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 137, "start_col": 0, "start_line": 134 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ty: FStar.Stubs.Reflection.Types.typ -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.fv", "FStar.InteractiveHelpers.Base.fv_eq_name", "FStar.Reflection.Const.unit_lid", "FStar.Stubs.Reflection.V1.Data.term_view", "Prims.bool", "FStar.Stubs.Tactics.V1.Builtins.inspect" ]
[]
false
true
false
false
false
let is_unit_type ty =
match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.is_total_or_gtotal
val is_total_or_gtotal : comp -> Tot bool
val is_total_or_gtotal : comp -> Tot bool
let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 131, "start_col": 0, "start_line": 130 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: FStar.Stubs.Reflection.Types.comp -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.uu___is_Some", "FStar.Stubs.Reflection.Types.typ", "FStar.InteractiveHelpers.ExploreTerm.get_total_or_gtotal_ret_type", "Prims.bool" ]
[]
false
false
false
true
false
let is_total_or_gtotal c =
Some? (get_total_or_gtotal_ret_type c)
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.effect_type_is_pure
val effect_type_is_pure : effect_type -> Tot bool
val effect_type_is_pure : effect_type -> Tot bool
let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 71, "start_col": 0, "start_line": 68 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
etype: FStar.InteractiveHelpers.ExploreTerm.effect_type -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.effect_type", "Prims.bool" ]
[]
false
false
false
true
false
let effect_type_is_pure etype =
match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.effect_type_to_string
val effect_type_to_string : effect_type -> string
val effect_type_to_string : effect_type -> string
let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown"
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 54, "start_col": 0, "start_line": 45 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ety: FStar.InteractiveHelpers.ExploreTerm.effect_type -> Prims.string
Prims.Tot
[ "total" ]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.effect_type", "Prims.string" ]
[]
false
false
false
true
false
let effect_type_to_string ety =
match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown"
false
Steel.Utils.fst
Steel.Utils.dup_pure
val dup_pure (p: prop) : SteelT unit (pure p) (fun _ -> (pure p) `star` (pure p))
val dup_pure (p: prop) : SteelT unit (pure p) (fun _ -> (pure p) `star` (pure p))
let dup_pure (p:prop) : SteelT unit (pure p) (fun _ -> pure p `star` pure p) = extract_pure p; intro_pure p
{ "file_name": "lib/steel/Steel.Utils.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 64, "start_col": 0, "start_line": 61 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Utils open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.FractionalPermission open Steel.Reference let pts_to_not_null (#a:Type) (#opened:inames) (#p:perm) (#v:FStar.Ghost.erased a) (r:ref a) : SteelGhost unit opened (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> r =!= null) = extract_info_raw (pts_to r p v) (r =!= null) (fun m -> pts_to_not_null r p v m) let change_slprop_ens (p:vprop) (q:vprop) (r:prop) (f:(m:mem -> Lemma (requires interp (hp_of p) m) (ensures interp (hp_of q) m /\ r))) : Steel unit p (fun _ -> q) (requires fun _ -> True) (ensures fun _ _ _ -> r) = rewrite_slprop p (q `star` pure r) (fun m -> f m; Steel.Memory.emp_unit (hp_of q); Steel.Memory.pure_star_interp (hp_of q) r m); elim_pure r let pure_as_ens (#p:prop) () : Steel unit (pure p) (fun _ -> pure p) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_ens (pure p) (pure p) p (Steel.Memory.pure_interp p) let rewrite #a (#p:a -> vprop) (x y:a) : Steel unit (p x) (fun _ -> p y) (requires fun _ -> x == y) (ensures fun _ _ _ -> True) = rewrite_slprop (p x) (p y) (fun _ -> ()) let extract_pure (p:prop) : Steel unit (pure p) (fun _ -> pure p) (fun _ -> True) (fun _ _ _ -> p) = elim_pure p; intro_pure p
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Utils.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Prims.prop", "Steel.Effect.Atomic.intro_pure", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.unit", "Steel.Utils.extract_pure", "Steel.Effect.Common.pure", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let dup_pure (p: prop) : SteelT unit (pure p) (fun _ -> (pure p) `star` (pure p)) =
extract_pure p; intro_pure p
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.subst_bv_in_comp
val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp
val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp
let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)]
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 197, "start_col": 0, "start_line": 196 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> b: FStar.Stubs.Reflection.Types.bv -> sort: FStar.Stubs.Reflection.Types.typ -> t: FStar.Stubs.Reflection.Types.term -> c: FStar.Stubs.Reflection.Types.comp -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.comp
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.comp", "FStar.InteractiveHelpers.Base.apply_subst_in_comp", "Prims.Cons", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil" ]
[]
false
true
false
false
false
let subst_bv_in_comp e b sort t c =
apply_subst_in_comp e c [((b, sort), t)]
false
Hacl.Impl.Ed25519.PointDouble.fst
Hacl.Impl.Ed25519.PointDouble.point_double_
val point_double_: out:point -> p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h tmp /\ eq_or_disjoint out p /\ disjoint tmp p /\ disjoint tmp out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_double (F51.point_eval h0 p))
val point_double_: out:point -> p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h tmp /\ eq_or_disjoint out p /\ disjoint tmp p /\ disjoint tmp out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_double (F51.point_eval h0 p))
let point_double_ out p tmp = point_double_step_1 p tmp; point_double_step_2 p tmp; let tmp_f = sub tmp 0ul 5ul in let tmp_e = sub tmp 5ul 5ul in let tmp_h = sub tmp 10ul 5ul in let tmp_g = sub tmp 15ul 5ul in let x3 = getx out in let y3 = gety out in let z3 = getz out in let t3 = gett out in fmul x3 tmp_e tmp_f; fmul y3 tmp_g tmp_h; fmul t3 tmp_e tmp_h; fmul z3 tmp_f tmp_g
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointDouble.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 119, "start_col": 0, "start_line": 105 }
module Hacl.Impl.Ed25519.PointDouble module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_double_step_1: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let a = x1 `SC.fmul` x1 in let b = y1 `SC.fmul` y1 in let c = 2 `SC.fmul` (z1 `SC.fmul` z1) in let h = a `SC.fadd` b in let g = a `SC.fsub` b in F51.felem_fits h1 (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == c)) let point_double_step_1 p tmp = let tmp1 = sub tmp 0ul 5ul in // c let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in // h let tmp4 = sub tmp 15ul 5ul in // g let x1 = getx p in let y1 = gety p in let z1 = getz p in fsquare tmp1 x1; // tmp1 = a fsquare tmp2 y1; // tmp2 = b fsum tmp3 tmp1 tmp2; // tmp3 = tmp1 + tmp2 = h fdifference tmp4 tmp1 tmp2; // tmp4 = tmp1 - tmp2 = g fsquare tmp1 z1; // tmp1 = z1 * z1 times_2 tmp1 tmp1 // tmp1 = 2 * tmp1 = c inline_for_extraction noextract val point_double_step_2: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p /\ F51.felem_fits h (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let c = F51.fevalh h0 (gsub tmp 0ul 5ul) in let h = F51.fevalh h0 (gsub tmp 10ul 5ul) in let g = F51.fevalh h0 (gsub tmp 15ul 5ul) in let e = h `SC.fsub` ((x1 `SC.fadd` y1) `SC.fmul` (x1 `SC.fadd` y1)) in let f = c `SC.fadd` g in F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g)) let point_double_step_2 p tmp = let tmp1 = sub tmp 0ul 5ul in // c, f let tmp2 = sub tmp 5ul 5ul in // e let tmp3 = sub tmp 10ul 5ul in // h let tmp4 = sub tmp 15ul 5ul in // g let x1 = getx p in let y1 = gety p in fsum tmp2 x1 y1; // tmp2 = x1 + y1 fsquare tmp2 tmp2; // tmp2 = (x1 + y1) ** 2 reduce_513 tmp3; fdifference tmp2 tmp3 tmp2; // tmp2 = tmp3 - tmp2 = h - (x1 + y1) ** 2 = e reduce_513 tmp1; reduce_513 tmp4; fsum tmp1 tmp1 tmp4 // tmp1 = c + g = tmp1 + tmp4 = f inline_for_extraction noextract val point_double_: out:point -> p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h tmp /\ eq_or_disjoint out p /\ disjoint tmp p /\ disjoint tmp out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_double (F51.point_eval h0 p))
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointDouble.fst" }
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.Bignum25519.point -> p: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 20ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Bignum25519.fmul", "Prims.unit", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.gett", "Hacl.Bignum25519.getz", "Hacl.Bignum25519.gety", "Hacl.Bignum25519.getx", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Hacl.Impl.Ed25519.PointDouble.point_double_step_2", "Hacl.Impl.Ed25519.PointDouble.point_double_step_1" ]
[]
false
true
false
false
false
let point_double_ out p tmp =
point_double_step_1 p tmp; point_double_step_2 p tmp; let tmp_f = sub tmp 0ul 5ul in let tmp_e = sub tmp 5ul 5ul in let tmp_h = sub tmp 10ul 5ul in let tmp_g = sub tmp 15ul 5ul in let x3 = getx out in let y3 = gety out in let z3 = getz out in let t3 = gett out in fmul x3 tmp_e tmp_f; fmul y3 tmp_g tmp_h; fmul t3 tmp_e tmp_h; fmul z3 tmp_f tmp_g
false
Hacl.Impl.Ed25519.PointDouble.fst
Hacl.Impl.Ed25519.PointDouble.point_double
val point_double: out:point -> p:point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_double (F51.point_eval h0 p))
val point_double: out:point -> p:point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_double (F51.point_eval h0 p))
let point_double out p = push_frame(); let tmp = create 20ul (u64 0) in point_double_ out p tmp; pop_frame()
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointDouble.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 134, "start_col": 0, "start_line": 130 }
module Hacl.Impl.Ed25519.PointDouble module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_double_step_1: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let a = x1 `SC.fmul` x1 in let b = y1 `SC.fmul` y1 in let c = 2 `SC.fmul` (z1 `SC.fmul` z1) in let h = a `SC.fadd` b in let g = a `SC.fsub` b in F51.felem_fits h1 (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == c)) let point_double_step_1 p tmp = let tmp1 = sub tmp 0ul 5ul in // c let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in // h let tmp4 = sub tmp 15ul 5ul in // g let x1 = getx p in let y1 = gety p in let z1 = getz p in fsquare tmp1 x1; // tmp1 = a fsquare tmp2 y1; // tmp2 = b fsum tmp3 tmp1 tmp2; // tmp3 = tmp1 + tmp2 = h fdifference tmp4 tmp1 tmp2; // tmp4 = tmp1 - tmp2 = g fsquare tmp1 z1; // tmp1 = z1 * z1 times_2 tmp1 tmp1 // tmp1 = 2 * tmp1 = c inline_for_extraction noextract val point_double_step_2: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p /\ F51.felem_fits h (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let c = F51.fevalh h0 (gsub tmp 0ul 5ul) in let h = F51.fevalh h0 (gsub tmp 10ul 5ul) in let g = F51.fevalh h0 (gsub tmp 15ul 5ul) in let e = h `SC.fsub` ((x1 `SC.fadd` y1) `SC.fmul` (x1 `SC.fadd` y1)) in let f = c `SC.fadd` g in F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g)) let point_double_step_2 p tmp = let tmp1 = sub tmp 0ul 5ul in // c, f let tmp2 = sub tmp 5ul 5ul in // e let tmp3 = sub tmp 10ul 5ul in // h let tmp4 = sub tmp 15ul 5ul in // g let x1 = getx p in let y1 = gety p in fsum tmp2 x1 y1; // tmp2 = x1 + y1 fsquare tmp2 tmp2; // tmp2 = (x1 + y1) ** 2 reduce_513 tmp3; fdifference tmp2 tmp3 tmp2; // tmp2 = tmp3 - tmp2 = h - (x1 + y1) ** 2 = e reduce_513 tmp1; reduce_513 tmp4; fsum tmp1 tmp1 tmp4 // tmp1 = c + g = tmp1 + tmp4 = f inline_for_extraction noextract val point_double_: out:point -> p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h tmp /\ eq_or_disjoint out p /\ disjoint tmp p /\ disjoint tmp out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_double (F51.point_eval h0 p)) let point_double_ out p tmp = point_double_step_1 p tmp; point_double_step_2 p tmp; let tmp_f = sub tmp 0ul 5ul in let tmp_e = sub tmp 5ul 5ul in let tmp_h = sub tmp 10ul 5ul in let tmp_g = sub tmp 15ul 5ul in let x3 = getx out in let y3 = gety out in let z3 = getz out in let t3 = gett out in fmul x3 tmp_e tmp_f; fmul y3 tmp_g tmp_h; fmul t3 tmp_e tmp_h; fmul z3 tmp_f tmp_g val point_double: out:point -> p:point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_double (F51.point_eval h0 p))
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointDouble.fst" }
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.Bignum25519.point -> p: Hacl.Bignum25519.point -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.point", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Ed25519.PointDouble.point_double_", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let point_double out p =
push_frame (); let tmp = create 20ul (u64 0) in point_double_ out p tmp; pop_frame ()
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.get_type_info
val get_type_info (e: env) (t: term) : Tac (option type_info)
val get_type_info (e: env) (t: term) : Tac (option type_info)
let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 113, "start_col": 0, "start_line": 110 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option FStar.InteractiveHelpers.ExploreTerm.type_info)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.None", "FStar.InteractiveHelpers.ExploreTerm.type_info", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.InteractiveHelpers.ExploreTerm.get_type_info_from_type", "FStar.InteractiveHelpers.ExploreTerm.safe_tc" ]
[]
false
true
false
false
false
let get_type_info (e: env) (t: term) : Tac (option type_info) =
match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty)
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.subst_binder_in_comp
val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp
val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp
let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 201, "start_col": 0, "start_line": 200 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> b: FStar.Stubs.Reflection.Types.binder -> t: FStar.Stubs.Reflection.Types.term -> c: FStar.Stubs.Reflection.Types.comp -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.comp
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.comp", "FStar.InteractiveHelpers.ExploreTerm.subst_bv_in_comp", "FStar.Reflection.V1.Derived.bv_of_binder", "FStar.Stubs.Reflection.Types.typ", "FStar.Tactics.V1.Derived.binder_sort" ]
[]
false
true
false
false
false
let subst_binder_in_comp e b t c =
subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.inst_comp_once
val inst_comp_once : env -> comp -> term -> Tac comp
val inst_comp_once : env -> comp -> term -> Tac comp
let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 263, "start_col": 0, "start_line": 255 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> c: FStar.Stubs.Reflection.Types.comp -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.comp
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.binder", "FStar.InteractiveHelpers.ExploreTerm.subst_binder_in_comp", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.InteractiveHelpers.Base.mfail", "FStar.Stubs.Tactics.V1.Builtins.inspect", "FStar.Stubs.Reflection.Types.typ", "FStar.InteractiveHelpers.ExploreTerm.unfold_until_arrow", "FStar.InteractiveHelpers.ExploreTerm.get_comp_ret_type" ]
[]
false
true
false
false
false
let inst_comp_once e c t =
let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> mfail "inst_comp_once: inconsistent state"
false
Hacl.Impl.Ed25519.PointDouble.fst
Hacl.Impl.Ed25519.PointDouble.point_double_step_1
val point_double_step_1: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let a = x1 `SC.fmul` x1 in let b = y1 `SC.fmul` y1 in let c = 2 `SC.fmul` (z1 `SC.fmul` z1) in let h = a `SC.fadd` b in let g = a `SC.fsub` b in F51.felem_fits h1 (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == c))
val point_double_step_1: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let a = x1 `SC.fmul` x1 in let b = y1 `SC.fmul` y1 in let c = 2 `SC.fmul` (z1 `SC.fmul` z1) in let h = a `SC.fadd` b in let g = a `SC.fsub` b in F51.felem_fits h1 (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == c))
let point_double_step_1 p tmp = let tmp1 = sub tmp 0ul 5ul in // c let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in // h let tmp4 = sub tmp 15ul 5ul in // g let x1 = getx p in let y1 = gety p in let z1 = getz p in fsquare tmp1 x1; // tmp1 = a fsquare tmp2 y1; // tmp2 = b fsum tmp3 tmp1 tmp2; // tmp3 = tmp1 + tmp2 = h fdifference tmp4 tmp1 tmp2; // tmp4 = tmp1 - tmp2 = g fsquare tmp1 z1; // tmp1 = z1 * z1 times_2 tmp1 tmp1
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointDouble.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 50, "start_col": 0, "start_line": 35 }
module Hacl.Impl.Ed25519.PointDouble module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_double_step_1: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let a = x1 `SC.fmul` x1 in let b = y1 `SC.fmul` y1 in let c = 2 `SC.fmul` (z1 `SC.fmul` z1) in let h = a `SC.fadd` b in let g = a `SC.fsub` b in F51.felem_fits h1 (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == c))
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointDouble.fst" }
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 20ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Bignum25519.times_2", "Prims.unit", "Hacl.Bignum25519.fsquare", "Hacl.Bignum25519.fdifference", "Hacl.Bignum25519.fsum", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.getz", "Hacl.Bignum25519.gety", "Hacl.Bignum25519.getx", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
false
true
false
false
false
let point_double_step_1 p tmp =
let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let x1 = getx p in let y1 = gety p in let z1 = getz p in fsquare tmp1 x1; fsquare tmp2 y1; fsum tmp3 tmp1 tmp2; fdifference tmp4 tmp1 tmp2; fsquare tmp1 z1; times_2 tmp1 tmp1
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm._abs_update_typ
val _abs_update_typ (b: binder) (ty: typ) (pl: list binder) (e: env) : Tac typ_or_comp
val _abs_update_typ (b: binder) (ty: typ) (pl: list binder) (e: env) : Tac typ_or_comp
let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 300, "start_col": 0, "start_line": 285 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.binder -> ty: FStar.Stubs.Reflection.Types.typ -> pl: Prims.list FStar.Stubs.Reflection.Types.binder -> e: FStar.Stubs.Reflection.Types.env -> FStar.Tactics.Effect.Tac FStar.InteractiveHelpers.ExploreTerm.typ_or_comp
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.typ", "Prims.list", "FStar.Stubs.Reflection.Types.env", "FStar.Tactics.V1.Derived.try_with", "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "Prims.unit", "FStar.Stubs.Reflection.Types.comp", "FStar.InteractiveHelpers.ExploreTerm.TC_Comp", "Prims.Cons", "FStar.InteractiveHelpers.ExploreTerm.subst_binder_in_comp", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Tactics.V1.Builtins.pack", "FStar.Stubs.Reflection.V1.Data.Tv_Var", "FStar.Reflection.V1.Derived.bv_of_binder", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.InteractiveHelpers.Base.mfail", "FStar.Stubs.Tactics.V1.Builtins.inspect", "FStar.InteractiveHelpers.ExploreTerm.unfold_until_arrow", "Prims.exn", "Prims.string", "Prims.op_Hat", "FStar.Stubs.Tactics.V1.Builtins.term_to_string", "FStar.Tactics.Effect.raise" ]
[]
false
true
false
false
false
let _abs_update_typ (b: binder) (ty: typ) (pl: list binder) (e: env) : Tac typ_or_comp =
try let ty' = unfold_until_arrow e ty in match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> mfail "_abs_update_typ: inconsistent state" with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.unfold_until_arrow
val unfold_until_arrow : env -> typ -> Tac typ
val unfold_until_arrow : env -> typ -> Tac typ
let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 251, "start_col": 0, "start_line": 206 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> ty0: FStar.Stubs.Reflection.Types.typ -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.typ
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.typ", "Prims.bool", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.Types.fv", "FStar.InteractiveHelpers.ExploreTerm.unfold_until_arrow", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Data.argv", "Prims.list", "FStar.Reflection.V1.Derived.mk_app", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.InteractiveHelpers.Base.mfail", "Prims.string", "Prims.op_Hat", "FStar.Stubs.Tactics.V1.Builtins.term_to_string", "FStar.Stubs.Tactics.V1.Builtins.inspect", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.V1.SyntaxHelpers.collect_app", "FStar.Stubs.Reflection.Types.bv", "FStar.Pervasives.Native.option", "Prims.op_Equality", "FStar.Reflection.V1.Derived.flatten_name", "FStar.Stubs.Reflection.V1.Builtins.inspect_fv", "FStar.Stubs.Tactics.V1.Builtins.norm_term_env", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.Nil", "FStar.Stubs.Tactics.V1.Builtins.pack", "FStar.Stubs.Reflection.V1.Data.Tv_FVar", "FStar.Stubs.Reflection.V1.Data.uu___is_Tv_Arrow" ]
[ "recursion" ]
false
true
false
false
false
let rec unfold_until_arrow e ty0 =
if Tv_Arrow? (inspect ty0) then ty0 else let ty = norm_term_env e [] ty0 in let unfold_fv (fv: fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in let ty' = norm_term_env e [delta_only [fvn]] ty in match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' in match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> let hd, args = collect_app ty in (match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0)) | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0)
false
Hacl.Impl.BignumQ.Mul.fst
Hacl.Impl.BignumQ.Mul.add_modq
val add_modq: z:qelemB -> x:qelemB -> y:qelemB -> Stack unit (requires fun h -> live h z /\ live h x /\ live h y /\ qelem_fits h x (1, 1, 1, 1, 1) /\ qelem_fits h y (1, 1, 1, 1, 1) /\ as_nat h x < S.q /\ as_nat h y < S.q) (ensures fun h0 _ h1 -> modifies (loc z) h0 h1 /\ qelem_fits h1 z (1, 1, 1, 1, 1) /\ as_nat h1 z == (as_nat h0 x + as_nat h0 y) % S.q)
val add_modq: z:qelemB -> x:qelemB -> y:qelemB -> Stack unit (requires fun h -> live h z /\ live h x /\ live h y /\ qelem_fits h x (1, 1, 1, 1, 1) /\ qelem_fits h y (1, 1, 1, 1, 1) /\ as_nat h x < S.q /\ as_nat h y < S.q) (ensures fun h0 _ h1 -> modifies (loc z) h0 h1 /\ qelem_fits h1 z (1, 1, 1, 1, 1) /\ as_nat h1 z == (as_nat h0 x + as_nat h0 y) % S.q)
let add_modq out x y = let (x0, x1, x2, x3, x4) = (x.(0ul), x.(1ul), x.(2ul), x.(3ul), x.(4ul)) in let (y0, y1, y2, y3, y4) = (y.(0ul), y.(1ul), y.(2ul), y.(3ul), y.(4ul)) in let (z0, z1, z2, z3, z4) = add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) in out.(0ul) <- z0; out.(1ul) <- z1; out.(2ul) <- z2; out.(3ul) <- z3; out.(4ul) <- z4
{ "file_name": "code/ed25519/Hacl.Impl.BignumQ.Mul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 49, "start_col": 0, "start_line": 41 }
module Hacl.Impl.BignumQ.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer include Hacl.Spec.BignumQ.Mul #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" [@CInline] let barrett_reduction z t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = (t.(0ul), t.(1ul), t.(2ul), t.(3ul), t.(4ul), t.(5ul), t.(6ul), t.(7ul), t.(8ul), t.(9ul)) in let (z0, z1, z2, z3, z4)= barrett_reduction5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in z.(0ul) <- z0; z.(1ul) <- z1; z.(2ul) <- z2; z.(3ul) <- z3; z.(4ul) <- z4 [@CInline] let mul_modq out x y = push_frame (); let tmp = create 10ul (u64 0) in let (x0, x1, x2, x3, x4) = (x.(0ul), x.(1ul), x.(2ul), x.(3ul), x.(4ul)) in let (y0, y1, y2, y3, y4) = (y.(0ul), y.(1ul), y.(2ul), y.(3ul), y.(4ul)) in let (z0, z1, z2, z3, z4, z5, z6, z7, z8, z9) = mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) in Hacl.Spec.BignumQ.Lemmas.lemma_mul_lt (as_nat5 (x0, x1, x2, x3, x4)) (pow2 256) (as_nat5 (y0, y1, y2, y3, y4)) (pow2 256); assert_norm (pow2 256 * pow2 256 = pow2 512); Hacl.Bignum25519.make_u64_10 tmp z0 z1 z2 z3 z4 z5 z6 z7 z8 z9; barrett_reduction out tmp; pop_frame ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.BignumQ.Mul.fst.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.BignumQ.Mul.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
z: Hacl.Impl.BignumQ.Mul.qelemB -> x: Hacl.Impl.BignumQ.Mul.qelemB -> y: Hacl.Impl.BignumQ.Mul.qelemB -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.BignumQ.Mul.qelemB", "Lib.IntTypes.uint64", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t", "Prims.unit", "Hacl.Spec.BignumQ.Definitions.qelem5", "Hacl.Spec.BignumQ.Mul.add_modq5", "FStar.Pervasives.Native.Mktuple5", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT" ]
[]
false
true
false
false
false
let add_modq out x y =
let x0, x1, x2, x3, x4 = (x.(0ul), x.(1ul), x.(2ul), x.(3ul), x.(4ul)) in let y0, y1, y2, y3, y4 = (y.(0ul), y.(1ul), y.(2ul), y.(3ul), y.(4ul)) in let z0, z1, z2, z3, z4 = add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) in out.(0ul) <- z0; out.(1ul) <- z1; out.(2ul) <- z2; out.(3ul) <- z3; out.(4ul) <- z4
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.get_comp_ret_type
val get_comp_ret_type : comp -> Tot typ
val get_comp_ret_type : comp -> Tot typ
let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 127, "start_col": 0, "start_line": 123 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: FStar.Stubs.Reflection.Types.comp -> FStar.Stubs.Reflection.Types.typ
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V1.Builtins.inspect_comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V1.Data.universes", "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.V1.Data.argv" ]
[]
false
false
false
true
false
let get_comp_ret_type c =
match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit)
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.explorer
val explorer : a: Type -> Type
let explorer (a : Type) = a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 431, "start_col": 0, "start_line": 429 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort /// TODO: for now I need to use universe 0 for type a because otherwise it doesn't /// type check /// ctrl_flag: /// - Continue: continue exploring the term /// - Skip: don't explore the sub-terms of this term /// - Abort: stop exploration /// TODO: we might want a more precise control (like: don't explore the type of the /// ascription but explore its body) /// Note that ``explore_term`` doesn't use the environment parameter besides pushing /// binders and passing it to ``f``, which means that you can give it arbitrary /// environments, ``explore_term`` itself won't fail (but the passed function might).
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.InteractiveHelpers.Base.genv", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Pervasives.Native.option", "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Stubs.Tactics.Types.ctrl_flag" ]
[]
false
false
false
true
true
let explorer (a: Type) =
a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag)
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.params_of_typ_or_comp
val params_of_typ_or_comp (c: typ_or_comp) : list binder
val params_of_typ_or_comp (c: typ_or_comp) : list binder
let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 172, "start_col": 0, "start_line": 170 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: FStar.InteractiveHelpers.ExploreTerm.typ_or_comp -> Prims.list FStar.Stubs.Reflection.Types.binder
Prims.Tot
[ "total" ]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Stubs.Reflection.Types.typ", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "Prims.nat", "FStar.Stubs.Reflection.Types.comp" ]
[]
false
false
false
true
false
let params_of_typ_or_comp (c: typ_or_comp) : list binder =
match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.num_unflushed_of_typ_or_comp
val num_unflushed_of_typ_or_comp (c: typ_or_comp) : nat
val num_unflushed_of_typ_or_comp (c: typ_or_comp) : nat
let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 176, "start_col": 0, "start_line": 174 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: FStar.InteractiveHelpers.ExploreTerm.typ_or_comp -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Stubs.Reflection.Types.typ", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "Prims.nat", "FStar.Stubs.Reflection.Types.comp" ]
[]
false
false
false
true
false
let num_unflushed_of_typ_or_comp (c: typ_or_comp) : nat =
match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.typ_or_comp_to_string
val typ_or_comp_to_string (tyc: typ_or_comp) : Tac string
val typ_or_comp_to_string (tyc: typ_or_comp) : Tac string
let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 167, "start_col": 0, "start_line": 160 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tyc: FStar.InteractiveHelpers.ExploreTerm.typ_or_comp -> FStar.Tactics.Effect.Tac Prims.string
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Stubs.Reflection.Types.typ", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "Prims.nat", "Prims.op_Hat", "Prims.string", "Prims.string_of_int", "FStar.InteractiveHelpers.Base.list_to_string", "FStar.Tactics.V1.Derived.name_of_binder", "FStar.Stubs.Tactics.V1.Builtins.term_to_string", "FStar.Stubs.Reflection.Types.comp", "FStar.InteractiveHelpers.Base.acomp_to_string" ]
[]
false
true
false
false
false
let typ_or_comp_to_string (tyc: typ_or_comp) : Tac string =
match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed
false
Hacl.Impl.BignumQ.Mul.fst
Hacl.Impl.BignumQ.Mul.mul_modq
val mul_modq: z:qelemB -> x:qelemB -> y:qelemB -> Stack unit (requires fun h -> live h z /\ live h x /\ live h y /\ qelem_fits h x (1, 1, 1, 1, 1) /\ qelem_fits h y (1, 1, 1, 1, 1) /\ as_nat h x < pow2 256 /\ as_nat h y < pow2 256) (ensures fun h0 _ h1 -> modifies (loc z) h0 h1 /\ qelem_fits h1 z (1, 1, 1, 1, 1) /\ as_nat h1 z == (as_nat h0 x * as_nat h0 y) % S.q)
val mul_modq: z:qelemB -> x:qelemB -> y:qelemB -> Stack unit (requires fun h -> live h z /\ live h x /\ live h y /\ qelem_fits h x (1, 1, 1, 1, 1) /\ qelem_fits h y (1, 1, 1, 1, 1) /\ as_nat h x < pow2 256 /\ as_nat h y < pow2 256) (ensures fun h0 _ h1 -> modifies (loc z) h0 h1 /\ qelem_fits h1 z (1, 1, 1, 1, 1) /\ as_nat h1 z == (as_nat h0 x * as_nat h0 y) % S.q)
let mul_modq out x y = push_frame (); let tmp = create 10ul (u64 0) in let (x0, x1, x2, x3, x4) = (x.(0ul), x.(1ul), x.(2ul), x.(3ul), x.(4ul)) in let (y0, y1, y2, y3, y4) = (y.(0ul), y.(1ul), y.(2ul), y.(3ul), y.(4ul)) in let (z0, z1, z2, z3, z4, z5, z6, z7, z8, z9) = mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) in Hacl.Spec.BignumQ.Lemmas.lemma_mul_lt (as_nat5 (x0, x1, x2, x3, x4)) (pow2 256) (as_nat5 (y0, y1, y2, y3, y4)) (pow2 256); assert_norm (pow2 256 * pow2 256 = pow2 512); Hacl.Bignum25519.make_u64_10 tmp z0 z1 z2 z3 z4 z5 z6 z7 z8 z9; barrett_reduction out tmp; pop_frame ()
{ "file_name": "code/ed25519/Hacl.Impl.BignumQ.Mul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 37, "start_col": 0, "start_line": 27 }
module Hacl.Impl.BignumQ.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer include Hacl.Spec.BignumQ.Mul #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" [@CInline] let barrett_reduction z t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = (t.(0ul), t.(1ul), t.(2ul), t.(3ul), t.(4ul), t.(5ul), t.(6ul), t.(7ul), t.(8ul), t.(9ul)) in let (z0, z1, z2, z3, z4)= barrett_reduction5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in z.(0ul) <- z0; z.(1ul) <- z1; z.(2ul) <- z2; z.(3ul) <- z3; z.(4ul) <- z4
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.BignumQ.Mul.fst.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.BignumQ.Mul.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
z: Hacl.Impl.BignumQ.Mul.qelemB -> x: Hacl.Impl.BignumQ.Mul.qelemB -> y: Hacl.Impl.BignumQ.Mul.qelemB -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.BignumQ.Mul.qelemB", "Lib.IntTypes.uint64", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.BignumQ.Mul.barrett_reduction", "Hacl.Bignum25519.make_u64_10", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Hacl.Spec.BignumQ.Lemmas.lemma_mul_lt", "Hacl.Spec.BignumQ.Definitions.as_nat5", "FStar.Pervasives.Native.Mktuple5", "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Hacl.Spec.BignumQ.Mul.mul_5", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let mul_modq out x y =
push_frame (); let tmp = create 10ul (u64 0) in let x0, x1, x2, x3, x4 = (x.(0ul), x.(1ul), x.(2ul), x.(3ul), x.(4ul)) in let y0, y1, y2, y3, y4 = (y.(0ul), y.(1ul), y.(2ul), y.(3ul), y.(4ul)) in let z0, z1, z2, z3, z4, z5, z6, z7, z8, z9 = mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) in Hacl.Spec.BignumQ.Lemmas.lemma_mul_lt (as_nat5 (x0, x1, x2, x3, x4)) (pow2 256) (as_nat5 (y0, y1, y2, y3, y4)) (pow2 256); assert_norm (pow2 256 * pow2 256 = pow2 512); Hacl.Bignum25519.make_u64_10 tmp z0 z1 z2 z3 z4 z5 z6 z7 z8 z9; barrett_reduction out tmp; pop_frame ()
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.abs_free_in
val abs_free_in : genv -> term -> Tac (list (bv & typ))
val abs_free_in : genv -> term -> Tac (list (bv & typ))
let abs_free_in ge t = let fvl = free_in t in let absl = List.rev (genv_abstract_bvs ge) in let is_free_in_term bv = Some? (List.Tot.find (bv_eq bv) fvl) in let absfree = List.Tot.concatMap (fun (bv, ty) -> if is_free_in_term bv then [bv,ty] else []) absl in absfree
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 607, "start_col": 0, "start_line": 598 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort /// TODO: for now I need to use universe 0 for type a because otherwise it doesn't /// type check /// ctrl_flag: /// - Continue: continue exploring the term /// - Skip: don't explore the sub-terms of this term /// - Abort: stop exploration /// TODO: we might want a more precise control (like: don't explore the type of the /// ascription but explore its body) /// Note that ``explore_term`` doesn't use the environment parameter besides pushing /// binders and passing it to ``f``, which means that you can give it arbitrary /// environments, ``explore_term`` itself won't fail (but the passed function might). let explorer (a : Type) = a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag) // TODO: use more let bind_expl (#a : Type) (x : a) (f1 f2 : a -> Tac (a & ctrl_flag)) : Tac (a & ctrl_flag) = let x1, flag1 = f1 x in if flag1 = Continue then f2 x1 else x1, convert_ctrl_flag flag1 // TODO: change the signature to move the dbg flag val explore_term : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge : genv (* the list of terms traversed so far (first is most recent) with the environment * at the time they were traversed *) -> parents : list (genv & term_view) -> c : option typ_or_comp -> t:term -> Tac (a & ctrl_flag) val explore_pattern : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge:genv -> pat:pattern -> Tac (genv & a & ctrl_flag) (* TODO: carry around the list of encompassing terms *) let rec explore_term dbg dfs #a f x ge0 pl0 c0 t0 = print_dbg dbg ("[> explore_term: " ^ term_construct t0 ^ ":\n" ^ term_to_string t0); let tv0 = inspect t0 in let x0, flag = f x ge0 pl0 c0 tv0 in let pl1 = (ge0, tv0) :: pl0 in if flag = Continue then begin match tv0 with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ -> x0, Continue | Tv_App hd (a,qual) -> (* Explore the argument - we update the target typ_or_comp when doing so. * Note that the only way to get the correct target type is to deconstruct * the type of the head *) let a_c = safe_arg_typ_or_comp dbg ge0.env hd in print_dbg dbg ("Tv_App: updated target typ_or_comp to:\n" ^ option_to_string typ_or_comp_to_string a_c); let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 a_c a in (* Explore the head - no type information here: we can compute it, * but it seems useless (or maybe use it only if it is not Total) *) if flag1 = Continue then explore_term dbg dfs f x1 ge0 pl1 None hd else x1, convert_ctrl_flag flag1 | Tv_Abs br body -> let ge1 = genv_push_binder ge0 br false None in let c1 = abs_update_opt_typ_or_comp br c0 ge1.env in explore_term dbg dfs f x0 ge1 pl1 c1 body | Tv_Arrow br c0 -> x0, Continue (* TODO: we might want to explore that *) | Tv_Type _ -> x0, Continue | Tv_Refine bv sort ref -> let bvv = inspect_bv bv in let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 None sort in if flag1 = Continue then let ge1 = genv_push_bv ge0 bv sort false None in explore_term dbg dfs f x1 ge1 pl1 None ref else x1, convert_ctrl_flag flag1 | Tv_Const _ -> x0, Continue | Tv_Uvar _ _ -> x0, Continue | Tv_Let recf attrs bv ty def body -> (* Binding definition exploration - for the target computation: initially we * used the type of the definition, however it is often unnecessarily complex. * Now, we use the type of the binder used for the binding. *) let def_c = Some (TC_Typ ty [] 0) in let explore_def x = explore_term dbg dfs f x ge0 pl1 def_c def in (* Exploration of the following instructions *) let ge1 = genv_push_bv ge0 bv ty false (Some def) in let explore_next x = explore_term dbg dfs f x ge1 pl1 c0 body in (* Perform the exploration in the proper order *) let expl1, expl2 = if dfs then explore_next, explore_def else explore_def, explore_next in bind_expl x0 expl1 expl2 | Tv_Match scrutinee _ret_opt branches -> //AR: TODO: need to account for returns annotation here (* Auxiliary function to explore the branches *) let explore_branch (x_flag : a & ctrl_flag) (br : branch) : Tac (a & ctrl_flag)= let x0, flag = x_flag in if flag = Continue then let pat, branch_body = br in (* Explore the pattern *) let ge1, x1, flag1 = explore_pattern dbg dfs #a f x0 ge0 pat in if flag1 = Continue then (* Explore the branch body *) explore_term dbg dfs #a f x1 ge1 pl1 c0 branch_body else x1, convert_ctrl_flag flag1 (* Don't convert the flag *) else x0, flag in (* Explore the scrutinee *) let scrut_c = safe_typ_or_comp dbg ge0.env scrutinee in let x1 = explore_term dbg dfs #a f x0 ge0 pl1 scrut_c scrutinee in (* Explore the branches *) fold_left explore_branch x1 branches | Tv_AscribedT e ty tac _ -> let c1 = Some (TC_Typ ty [] 0) in let x1, flag = explore_term dbg dfs #a f x0 ge0 pl1 None ty in if flag = Continue then explore_term dbg dfs #a f x1 ge0 pl1 c1 e else x1, convert_ctrl_flag flag | Tv_AscribedC e c1 tac _ -> (* TODO: explore the comp *) explore_term dbg dfs #a f x0 ge0 pl1 (Some (TC_Comp c1 [] 0)) e | _ -> (* Unknown *) x0, Continue end else x0, convert_ctrl_flag flag and explore_pattern dbg dfs #a f x ge0 pat = print_dbg dbg ("[> explore_pattern:"); match pat with | Pat_Constant _ -> ge0, x, Continue | Pat_Cons fv us patterns -> let explore_pat ge_x_flag pat = let ge0, x, flag = ge_x_flag in let pat1, _ = pat in if flag = Continue then explore_pattern dbg dfs #a f x ge0 pat1 else (* Don't convert the flag *) ge0, x, flag in fold_left explore_pat (ge0, x, Continue) patterns | Pat_Var bv st -> let ge1 = genv_push_bv ge0 bv (unseal st) false None in ge1, x, Continue | Pat_Dot_Term _ -> ge0, x, Continue (*** Variables in a term *) /// Returns the list of free variables contained in a term val free_in : term -> Tac (list bv) let free_in t = let same_name (bv1 bv2 : bv) : Tac bool = name_of_bv bv1 = name_of_bv bv2 in let update_free (fl:list bv) (ge:genv) (pl:list (genv & term_view)) (c:option typ_or_comp) (tv:term_view) : Tac (list bv & ctrl_flag) = match tv with | Tv_Var bv | Tv_BVar bv -> (* Check if the binding was not introduced during the traversal *) begin match genv_get_from_name ge (name_of_bv bv) with | None -> (* Check if we didn't already count the binding *) let fl' = if Tactics.tryFind (same_name bv) fl then fl else bv :: fl in fl', Continue | Some _ -> fl, Continue end | _ -> fl, Continue in let e = top_env () in (* we actually don't care about the environment *) let ge = mk_genv e [] [] in List.Tot.rev (fst (explore_term false false update_free [] ge [] None t)) /// Returns the list of abstract variables appearing in a term, in the order in /// which they were introduced in the context.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ge: FStar.InteractiveHelpers.Base.genv -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (Prims.list (FStar.Stubs.Reflection.Types.bv * FStar.Stubs.Reflection.Types.typ))
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.InteractiveHelpers.Base.genv", "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.typ", "FStar.List.Tot.Base.concatMap", "Prims.Cons", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "Prims.bool", "FStar.Pervasives.Native.uu___is_Some", "Prims.b2t", "FStar.InteractiveHelpers.Base.bv_eq", "FStar.List.Tot.Base.find", "FStar.List.Tot.Base.rev", "FStar.InteractiveHelpers.Base.genv_abstract_bvs", "FStar.InteractiveHelpers.ExploreTerm.free_in" ]
[]
false
true
false
false
false
let abs_free_in ge t =
let fvl = free_in t in let absl = List.rev (genv_abstract_bvs ge) in let is_free_in_term bv = Some? (List.Tot.find (bv_eq bv) fvl) in let absfree = List.Tot.concatMap (fun (bv, ty) -> if is_free_in_term bv then [bv, ty] else []) absl in absfree
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.term_has_shadowed_variables
val term_has_shadowed_variables : genv -> term -> Tac bool
val term_has_shadowed_variables : genv -> term -> Tac bool
let term_has_shadowed_variables ge t = let fvl = free_in t in Some? (List.Tot.tryFind (bv_is_shadowed ge) fvl)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 619, "start_col": 0, "start_line": 617 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort /// TODO: for now I need to use universe 0 for type a because otherwise it doesn't /// type check /// ctrl_flag: /// - Continue: continue exploring the term /// - Skip: don't explore the sub-terms of this term /// - Abort: stop exploration /// TODO: we might want a more precise control (like: don't explore the type of the /// ascription but explore its body) /// Note that ``explore_term`` doesn't use the environment parameter besides pushing /// binders and passing it to ``f``, which means that you can give it arbitrary /// environments, ``explore_term`` itself won't fail (but the passed function might). let explorer (a : Type) = a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag) // TODO: use more let bind_expl (#a : Type) (x : a) (f1 f2 : a -> Tac (a & ctrl_flag)) : Tac (a & ctrl_flag) = let x1, flag1 = f1 x in if flag1 = Continue then f2 x1 else x1, convert_ctrl_flag flag1 // TODO: change the signature to move the dbg flag val explore_term : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge : genv (* the list of terms traversed so far (first is most recent) with the environment * at the time they were traversed *) -> parents : list (genv & term_view) -> c : option typ_or_comp -> t:term -> Tac (a & ctrl_flag) val explore_pattern : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge:genv -> pat:pattern -> Tac (genv & a & ctrl_flag) (* TODO: carry around the list of encompassing terms *) let rec explore_term dbg dfs #a f x ge0 pl0 c0 t0 = print_dbg dbg ("[> explore_term: " ^ term_construct t0 ^ ":\n" ^ term_to_string t0); let tv0 = inspect t0 in let x0, flag = f x ge0 pl0 c0 tv0 in let pl1 = (ge0, tv0) :: pl0 in if flag = Continue then begin match tv0 with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ -> x0, Continue | Tv_App hd (a,qual) -> (* Explore the argument - we update the target typ_or_comp when doing so. * Note that the only way to get the correct target type is to deconstruct * the type of the head *) let a_c = safe_arg_typ_or_comp dbg ge0.env hd in print_dbg dbg ("Tv_App: updated target typ_or_comp to:\n" ^ option_to_string typ_or_comp_to_string a_c); let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 a_c a in (* Explore the head - no type information here: we can compute it, * but it seems useless (or maybe use it only if it is not Total) *) if flag1 = Continue then explore_term dbg dfs f x1 ge0 pl1 None hd else x1, convert_ctrl_flag flag1 | Tv_Abs br body -> let ge1 = genv_push_binder ge0 br false None in let c1 = abs_update_opt_typ_or_comp br c0 ge1.env in explore_term dbg dfs f x0 ge1 pl1 c1 body | Tv_Arrow br c0 -> x0, Continue (* TODO: we might want to explore that *) | Tv_Type _ -> x0, Continue | Tv_Refine bv sort ref -> let bvv = inspect_bv bv in let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 None sort in if flag1 = Continue then let ge1 = genv_push_bv ge0 bv sort false None in explore_term dbg dfs f x1 ge1 pl1 None ref else x1, convert_ctrl_flag flag1 | Tv_Const _ -> x0, Continue | Tv_Uvar _ _ -> x0, Continue | Tv_Let recf attrs bv ty def body -> (* Binding definition exploration - for the target computation: initially we * used the type of the definition, however it is often unnecessarily complex. * Now, we use the type of the binder used for the binding. *) let def_c = Some (TC_Typ ty [] 0) in let explore_def x = explore_term dbg dfs f x ge0 pl1 def_c def in (* Exploration of the following instructions *) let ge1 = genv_push_bv ge0 bv ty false (Some def) in let explore_next x = explore_term dbg dfs f x ge1 pl1 c0 body in (* Perform the exploration in the proper order *) let expl1, expl2 = if dfs then explore_next, explore_def else explore_def, explore_next in bind_expl x0 expl1 expl2 | Tv_Match scrutinee _ret_opt branches -> //AR: TODO: need to account for returns annotation here (* Auxiliary function to explore the branches *) let explore_branch (x_flag : a & ctrl_flag) (br : branch) : Tac (a & ctrl_flag)= let x0, flag = x_flag in if flag = Continue then let pat, branch_body = br in (* Explore the pattern *) let ge1, x1, flag1 = explore_pattern dbg dfs #a f x0 ge0 pat in if flag1 = Continue then (* Explore the branch body *) explore_term dbg dfs #a f x1 ge1 pl1 c0 branch_body else x1, convert_ctrl_flag flag1 (* Don't convert the flag *) else x0, flag in (* Explore the scrutinee *) let scrut_c = safe_typ_or_comp dbg ge0.env scrutinee in let x1 = explore_term dbg dfs #a f x0 ge0 pl1 scrut_c scrutinee in (* Explore the branches *) fold_left explore_branch x1 branches | Tv_AscribedT e ty tac _ -> let c1 = Some (TC_Typ ty [] 0) in let x1, flag = explore_term dbg dfs #a f x0 ge0 pl1 None ty in if flag = Continue then explore_term dbg dfs #a f x1 ge0 pl1 c1 e else x1, convert_ctrl_flag flag | Tv_AscribedC e c1 tac _ -> (* TODO: explore the comp *) explore_term dbg dfs #a f x0 ge0 pl1 (Some (TC_Comp c1 [] 0)) e | _ -> (* Unknown *) x0, Continue end else x0, convert_ctrl_flag flag and explore_pattern dbg dfs #a f x ge0 pat = print_dbg dbg ("[> explore_pattern:"); match pat with | Pat_Constant _ -> ge0, x, Continue | Pat_Cons fv us patterns -> let explore_pat ge_x_flag pat = let ge0, x, flag = ge_x_flag in let pat1, _ = pat in if flag = Continue then explore_pattern dbg dfs #a f x ge0 pat1 else (* Don't convert the flag *) ge0, x, flag in fold_left explore_pat (ge0, x, Continue) patterns | Pat_Var bv st -> let ge1 = genv_push_bv ge0 bv (unseal st) false None in ge1, x, Continue | Pat_Dot_Term _ -> ge0, x, Continue (*** Variables in a term *) /// Returns the list of free variables contained in a term val free_in : term -> Tac (list bv) let free_in t = let same_name (bv1 bv2 : bv) : Tac bool = name_of_bv bv1 = name_of_bv bv2 in let update_free (fl:list bv) (ge:genv) (pl:list (genv & term_view)) (c:option typ_or_comp) (tv:term_view) : Tac (list bv & ctrl_flag) = match tv with | Tv_Var bv | Tv_BVar bv -> (* Check if the binding was not introduced during the traversal *) begin match genv_get_from_name ge (name_of_bv bv) with | None -> (* Check if we didn't already count the binding *) let fl' = if Tactics.tryFind (same_name bv) fl then fl else bv :: fl in fl', Continue | Some _ -> fl, Continue end | _ -> fl, Continue in let e = top_env () in (* we actually don't care about the environment *) let ge = mk_genv e [] [] in List.Tot.rev (fst (explore_term false false update_free [] ge [] None t)) /// Returns the list of abstract variables appearing in a term, in the order in /// which they were introduced in the context. val abs_free_in : genv -> term -> Tac (list (bv & typ)) let abs_free_in ge t = let fvl = free_in t in let absl = List.rev (genv_abstract_bvs ge) in let is_free_in_term bv = Some? (List.Tot.find (bv_eq bv) fvl) in let absfree = List.Tot.concatMap (fun (bv, ty) -> if is_free_in_term bv then [bv,ty] else []) absl in absfree /// Returns the list of free shadowed variables appearing in a term. val shadowed_free_in : genv -> term -> Tac (list bv) let shadowed_free_in ge t = let fvl = free_in t in List.Tot.filter (fun bv -> bv_is_shadowed ge bv) fvl /// Returns true if a term contains variables which are shadowed in a given environment
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ge: FStar.InteractiveHelpers.Base.genv -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.InteractiveHelpers.Base.genv", "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.uu___is_Some", "FStar.Stubs.Reflection.Types.bv", "FStar.List.Tot.Base.tryFind", "FStar.InteractiveHelpers.Base.bv_is_shadowed", "Prims.bool", "Prims.list", "FStar.InteractiveHelpers.ExploreTerm.free_in" ]
[]
false
true
false
false
false
let term_has_shadowed_variables ge t =
let fvl = free_in t in Some? (List.Tot.tryFind (bv_is_shadowed ge) fvl)
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.shadowed_free_in
val shadowed_free_in : genv -> term -> Tac (list bv)
val shadowed_free_in : genv -> term -> Tac (list bv)
let shadowed_free_in ge t = let fvl = free_in t in List.Tot.filter (fun bv -> bv_is_shadowed ge bv) fvl
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 613, "start_col": 0, "start_line": 611 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort /// TODO: for now I need to use universe 0 for type a because otherwise it doesn't /// type check /// ctrl_flag: /// - Continue: continue exploring the term /// - Skip: don't explore the sub-terms of this term /// - Abort: stop exploration /// TODO: we might want a more precise control (like: don't explore the type of the /// ascription but explore its body) /// Note that ``explore_term`` doesn't use the environment parameter besides pushing /// binders and passing it to ``f``, which means that you can give it arbitrary /// environments, ``explore_term`` itself won't fail (but the passed function might). let explorer (a : Type) = a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag) // TODO: use more let bind_expl (#a : Type) (x : a) (f1 f2 : a -> Tac (a & ctrl_flag)) : Tac (a & ctrl_flag) = let x1, flag1 = f1 x in if flag1 = Continue then f2 x1 else x1, convert_ctrl_flag flag1 // TODO: change the signature to move the dbg flag val explore_term : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge : genv (* the list of terms traversed so far (first is most recent) with the environment * at the time they were traversed *) -> parents : list (genv & term_view) -> c : option typ_or_comp -> t:term -> Tac (a & ctrl_flag) val explore_pattern : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge:genv -> pat:pattern -> Tac (genv & a & ctrl_flag) (* TODO: carry around the list of encompassing terms *) let rec explore_term dbg dfs #a f x ge0 pl0 c0 t0 = print_dbg dbg ("[> explore_term: " ^ term_construct t0 ^ ":\n" ^ term_to_string t0); let tv0 = inspect t0 in let x0, flag = f x ge0 pl0 c0 tv0 in let pl1 = (ge0, tv0) :: pl0 in if flag = Continue then begin match tv0 with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ -> x0, Continue | Tv_App hd (a,qual) -> (* Explore the argument - we update the target typ_or_comp when doing so. * Note that the only way to get the correct target type is to deconstruct * the type of the head *) let a_c = safe_arg_typ_or_comp dbg ge0.env hd in print_dbg dbg ("Tv_App: updated target typ_or_comp to:\n" ^ option_to_string typ_or_comp_to_string a_c); let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 a_c a in (* Explore the head - no type information here: we can compute it, * but it seems useless (or maybe use it only if it is not Total) *) if flag1 = Continue then explore_term dbg dfs f x1 ge0 pl1 None hd else x1, convert_ctrl_flag flag1 | Tv_Abs br body -> let ge1 = genv_push_binder ge0 br false None in let c1 = abs_update_opt_typ_or_comp br c0 ge1.env in explore_term dbg dfs f x0 ge1 pl1 c1 body | Tv_Arrow br c0 -> x0, Continue (* TODO: we might want to explore that *) | Tv_Type _ -> x0, Continue | Tv_Refine bv sort ref -> let bvv = inspect_bv bv in let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 None sort in if flag1 = Continue then let ge1 = genv_push_bv ge0 bv sort false None in explore_term dbg dfs f x1 ge1 pl1 None ref else x1, convert_ctrl_flag flag1 | Tv_Const _ -> x0, Continue | Tv_Uvar _ _ -> x0, Continue | Tv_Let recf attrs bv ty def body -> (* Binding definition exploration - for the target computation: initially we * used the type of the definition, however it is often unnecessarily complex. * Now, we use the type of the binder used for the binding. *) let def_c = Some (TC_Typ ty [] 0) in let explore_def x = explore_term dbg dfs f x ge0 pl1 def_c def in (* Exploration of the following instructions *) let ge1 = genv_push_bv ge0 bv ty false (Some def) in let explore_next x = explore_term dbg dfs f x ge1 pl1 c0 body in (* Perform the exploration in the proper order *) let expl1, expl2 = if dfs then explore_next, explore_def else explore_def, explore_next in bind_expl x0 expl1 expl2 | Tv_Match scrutinee _ret_opt branches -> //AR: TODO: need to account for returns annotation here (* Auxiliary function to explore the branches *) let explore_branch (x_flag : a & ctrl_flag) (br : branch) : Tac (a & ctrl_flag)= let x0, flag = x_flag in if flag = Continue then let pat, branch_body = br in (* Explore the pattern *) let ge1, x1, flag1 = explore_pattern dbg dfs #a f x0 ge0 pat in if flag1 = Continue then (* Explore the branch body *) explore_term dbg dfs #a f x1 ge1 pl1 c0 branch_body else x1, convert_ctrl_flag flag1 (* Don't convert the flag *) else x0, flag in (* Explore the scrutinee *) let scrut_c = safe_typ_or_comp dbg ge0.env scrutinee in let x1 = explore_term dbg dfs #a f x0 ge0 pl1 scrut_c scrutinee in (* Explore the branches *) fold_left explore_branch x1 branches | Tv_AscribedT e ty tac _ -> let c1 = Some (TC_Typ ty [] 0) in let x1, flag = explore_term dbg dfs #a f x0 ge0 pl1 None ty in if flag = Continue then explore_term dbg dfs #a f x1 ge0 pl1 c1 e else x1, convert_ctrl_flag flag | Tv_AscribedC e c1 tac _ -> (* TODO: explore the comp *) explore_term dbg dfs #a f x0 ge0 pl1 (Some (TC_Comp c1 [] 0)) e | _ -> (* Unknown *) x0, Continue end else x0, convert_ctrl_flag flag and explore_pattern dbg dfs #a f x ge0 pat = print_dbg dbg ("[> explore_pattern:"); match pat with | Pat_Constant _ -> ge0, x, Continue | Pat_Cons fv us patterns -> let explore_pat ge_x_flag pat = let ge0, x, flag = ge_x_flag in let pat1, _ = pat in if flag = Continue then explore_pattern dbg dfs #a f x ge0 pat1 else (* Don't convert the flag *) ge0, x, flag in fold_left explore_pat (ge0, x, Continue) patterns | Pat_Var bv st -> let ge1 = genv_push_bv ge0 bv (unseal st) false None in ge1, x, Continue | Pat_Dot_Term _ -> ge0, x, Continue (*** Variables in a term *) /// Returns the list of free variables contained in a term val free_in : term -> Tac (list bv) let free_in t = let same_name (bv1 bv2 : bv) : Tac bool = name_of_bv bv1 = name_of_bv bv2 in let update_free (fl:list bv) (ge:genv) (pl:list (genv & term_view)) (c:option typ_or_comp) (tv:term_view) : Tac (list bv & ctrl_flag) = match tv with | Tv_Var bv | Tv_BVar bv -> (* Check if the binding was not introduced during the traversal *) begin match genv_get_from_name ge (name_of_bv bv) with | None -> (* Check if we didn't already count the binding *) let fl' = if Tactics.tryFind (same_name bv) fl then fl else bv :: fl in fl', Continue | Some _ -> fl, Continue end | _ -> fl, Continue in let e = top_env () in (* we actually don't care about the environment *) let ge = mk_genv e [] [] in List.Tot.rev (fst (explore_term false false update_free [] ge [] None t)) /// Returns the list of abstract variables appearing in a term, in the order in /// which they were introduced in the context. val abs_free_in : genv -> term -> Tac (list (bv & typ)) let abs_free_in ge t = let fvl = free_in t in let absl = List.rev (genv_abstract_bvs ge) in let is_free_in_term bv = Some? (List.Tot.find (bv_eq bv) fvl) in let absfree = List.Tot.concatMap (fun (bv, ty) -> if is_free_in_term bv then [bv,ty] else []) absl in absfree /// Returns the list of free shadowed variables appearing in a term.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ge: FStar.InteractiveHelpers.Base.genv -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (Prims.list FStar.Stubs.Reflection.Types.bv)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.InteractiveHelpers.Base.genv", "FStar.Stubs.Reflection.Types.term", "FStar.List.Tot.Base.filter", "FStar.Stubs.Reflection.Types.bv", "FStar.InteractiveHelpers.Base.bv_is_shadowed", "Prims.bool", "Prims.list", "FStar.InteractiveHelpers.ExploreTerm.free_in" ]
[]
false
true
false
false
false
let shadowed_free_in ge t =
let fvl = free_in t in List.Tot.filter (fun bv -> bv_is_shadowed ge bv) fvl
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.inst_comp
val inst_comp : env -> comp -> list term -> Tac comp
val inst_comp : env -> comp -> list term -> Tac comp
let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl'
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 274, "start_col": 0, "start_line": 266 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Stubs.Reflection.Types.env -> c: FStar.Stubs.Reflection.Types.comp -> tl: Prims.list FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.comp
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.comp", "Prims.list", "FStar.Stubs.Reflection.Types.term", "FStar.InteractiveHelpers.ExploreTerm.inst_comp", "FStar.Tactics.V1.Derived.try_with", "Prims.unit", "FStar.InteractiveHelpers.ExploreTerm.inst_comp_once", "Prims.exn", "Prims.string", "FStar.InteractiveHelpers.Base.mfail", "Prims.op_Hat", "FStar.Tactics.Effect.raise" ]
[ "recursion" ]
false
true
false
false
false
let rec inst_comp e c tl =
match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl'
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.safe_typ_or_comp
val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)})
val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)})
let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 193, "start_col": 0, "start_line": 182 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dbg: Prims.bool -> e: FStar.Stubs.Reflection.Types.env -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (opt: FStar.Pervasives.Native.option FStar.InteractiveHelpers.ExploreTerm.typ_or_comp {Some? opt ==> TC_Comp? (Some?.v opt)})
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.bool", "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.None", "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Pervasives.Native.option", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.InteractiveHelpers.ExploreTerm.uu___is_TC_Comp", "FStar.Pervasives.Native.__proj__Some__item__v", "Prims.unit", "FStar.InteractiveHelpers.Base.print_dbg", "Prims.string", "Prims.op_Hat", "FStar.Stubs.Tactics.V1.Builtins.term_to_string", "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.Some", "FStar.InteractiveHelpers.ExploreTerm.TC_Comp", "Prims.Nil", "FStar.Stubs.Reflection.Types.binder", "FStar.InteractiveHelpers.Base.acomp_to_string", "FStar.InteractiveHelpers.ExploreTerm.safe_tcc" ]
[]
false
true
false
false
false
let safe_typ_or_comp dbg e t =
match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0)
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.abs_update_typ_or_comp
val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp
val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp
let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 312, "start_col": 0, "start_line": 302 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.binder -> c: FStar.InteractiveHelpers.ExploreTerm.typ_or_comp -> e: FStar.Stubs.Reflection.Types.env -> FStar.Tactics.Effect.Tac FStar.InteractiveHelpers.ExploreTerm.typ_or_comp
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.typ", "Prims.list", "Prims.nat", "FStar.InteractiveHelpers.ExploreTerm.TC_Typ", "Prims.Cons", "Prims.op_Addition", "FStar.Stubs.Reflection.Types.comp", "FStar.InteractiveHelpers.ExploreTerm.TC_Comp" ]
[]
false
true
false
false
false
let abs_update_typ_or_comp (b: binder) (c: typ_or_comp) (e: env) : Tac typ_or_comp =
match c with | TC_Typ v pl n -> TC_Typ v (b :: pl) (n + 1) | TC_Comp v pl n -> TC_Comp v (b :: pl) (n + 1)
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.abs_update_opt_typ_or_comp
val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp)
val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp)
let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 324, "start_col": 0, "start_line": 316 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.binder -> opt_c: FStar.Pervasives.Native.option FStar.InteractiveHelpers.ExploreTerm.typ_or_comp -> e: FStar.Stubs.Reflection.Types.env -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option FStar.InteractiveHelpers.ExploreTerm.typ_or_comp)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.Native.option", "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Stubs.Reflection.Types.env", "FStar.Pervasives.Native.None", "FStar.Tactics.V1.Derived.try_with", "Prims.unit", "FStar.Pervasives.Native.Some", "FStar.InteractiveHelpers.ExploreTerm.abs_update_typ_or_comp", "Prims.exn", "Prims.string", "FStar.Tactics.Effect.raise" ]
[]
false
true
false
false
false
let abs_update_opt_typ_or_comp b opt_c e =
match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.convert_ctrl_flag
val convert_ctrl_flag : flag: FStar.Stubs.Tactics.Types.ctrl_flag -> FStar.Stubs.Tactics.Types.ctrl_flag
let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 415, "start_col": 0, "start_line": 411 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
flag: FStar.Stubs.Tactics.Types.ctrl_flag -> FStar.Stubs.Tactics.Types.ctrl_flag
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Tactics.Types.ctrl_flag", "FStar.Stubs.Tactics.Types.Continue", "FStar.Stubs.Tactics.Types.Abort" ]
[]
false
false
false
true
false
let convert_ctrl_flag (flag: ctrl_flag) =
match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.print
val print (name: string) (oprs: list instr_print_operand) : instr_print
val print (name: string) (oprs: list instr_print_operand) : instr_print
let print (name:string) (oprs:list instr_print_operand) : instr_print = Print name POpcode oprs
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 95, "end_line": 72, "start_col": 0, "start_line": 72 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args [@instr_attr] let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args noeq type instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) = { i_eval:instr_eval_t outs args; i_printer:instr_print_t outs args; // havoc_flags isn't used here, but we still need it in the type to track the semantics of each instr_t } let instr_eval #_ #_ #_ ins = ins.i_eval let rec instr_printer_args (args:list instr_operand) (f:instr_print_t_args args) (oprs:instr_operands_t_args args) : instr_print = match args with | [] -> f | i::args -> ( match i with | IOpEx i -> // REVIEW: triggers F* -> OCaml bug: let f:arrow (instr_operand_t i) (instr_print_t_args args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_args args (coerce #(arrow (instr_operand_t i) (instr_print_t_args args)) #(instr_print_t_args ((IOpEx i)::args)) f o) oprs | IOpIm _ -> instr_printer_args args (coerce f) (coerce #(instr_operands_t_args args) oprs) ) let rec instr_printer_outs (outs:list instr_out) (args:list instr_operand) (f:instr_print_t outs args) (oprs:instr_operands_t outs args) : instr_print = match outs with | [] -> instr_printer_args args f oprs // | (_, i)::outs -> | (b, i)::outs -> ( match i with | IOpEx i -> // let f:arrow (instr_operand_t i) (instr_print_t outs args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_outs outs args (coerce #(arrow (instr_operand_t i) (instr_print_t outs args)) #(instr_print_t ((b, (IOpEx i))::outs) args) f o) oprs | IOpIm _ -> instr_printer_outs outs args (coerce f) (coerce #(instr_operands_t outs args) oprs) ) let instr_printer #outs #args #_ ins oprs = instr_printer_outs outs args ins.i_printer oprs let make_ins (#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc) (#f:normal (instr_eval_t outs args)) (print:normal (instr_print_t outs args)) : instr_dep outs args havoc_flags f = {i_printer = print; i_eval = f}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
name: Prims.string -> oprs: Prims.list Vale.X64.Instruction_s.instr_print_operand -> Vale.X64.Instruction_s.instr_print
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "Prims.list", "Vale.X64.Instruction_s.instr_print_operand", "Vale.X64.Instruction_s.Print", "Vale.X64.Instruction_s.POpcode", "Vale.X64.Instruction_s.instr_print" ]
[]
false
false
false
true
false
let print (name: string) (oprs: list instr_print_operand) : instr_print =
Print name POpcode oprs
false
EverParse3d.Actions.BackendFlag.fst
EverParse3d.Actions.BackendFlag.backend_flag
val backend_flag : EverParse3d.Actions.Base.backend_flag_t
val backend_flag : EverParse3d.Actions.Base.backend_flag_t
let backend_flag = EverParse3d.Actions.Base.BackendFlagExtern
{ "file_name": "src/3d/prelude/extern/EverParse3d.Actions.BackendFlag.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 61, "end_line": 2, "start_col": 0, "start_line": 2 }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "EverParse3d.Actions.Base.fsti.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.BackendFlag.fst" }
[ { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 8, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverParse3d.Actions.Base.backend_flag_t
Prims.Tot
[ "total" ]
[]
[ "EverParse3d.Actions.Base.BackendFlagExtern" ]
[]
false
false
false
true
false
let backend_flag =
EverParse3d.Actions.Base.BackendFlagExtern
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.bind_expl
val bind_expl (#a: Type) (x: a) (f1 f2: (a -> Tac (a & ctrl_flag))) : Tac (a & ctrl_flag)
val bind_expl (#a: Type) (x: a) (f1 f2: (a -> Tac (a & ctrl_flag))) : Tac (a & ctrl_flag)
let bind_expl (#a : Type) (x : a) (f1 f2 : a -> Tac (a & ctrl_flag)) : Tac (a & ctrl_flag) = let x1, flag1 = f1 x in if flag1 = Continue then f2 x1 else x1, convert_ctrl_flag flag1
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 438, "start_col": 0, "start_line": 434 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort /// TODO: for now I need to use universe 0 for type a because otherwise it doesn't /// type check /// ctrl_flag: /// - Continue: continue exploring the term /// - Skip: don't explore the sub-terms of this term /// - Abort: stop exploration /// TODO: we might want a more precise control (like: don't explore the type of the /// ascription but explore its body) /// Note that ``explore_term`` doesn't use the environment parameter besides pushing /// binders and passing it to ``f``, which means that you can give it arbitrary /// environments, ``explore_term`` itself won't fail (but the passed function might). let explorer (a : Type) = a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> f1: (_: a -> FStar.Tactics.Effect.Tac (a * FStar.Stubs.Tactics.Types.ctrl_flag)) -> f2: (_: a -> FStar.Tactics.Effect.Tac (a * FStar.Stubs.Tactics.Types.ctrl_flag)) -> FStar.Tactics.Effect.Tac (a * FStar.Stubs.Tactics.Types.ctrl_flag)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Tactics.Types.ctrl_flag", "Prims.op_Equality", "FStar.Stubs.Tactics.Types.Continue", "Prims.bool", "FStar.Pervasives.Native.Mktuple2", "FStar.InteractiveHelpers.ExploreTerm.convert_ctrl_flag" ]
[]
false
true
false
false
false
let bind_expl (#a: Type) (x: a) (f1 f2: (a -> Tac (a & ctrl_flag))) : Tac (a & ctrl_flag) =
let x1, flag1 = f1 x in if flag1 = Continue then f2 x1 else x1, convert_ctrl_flag flag1
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.print_s
val print_s (name: string) (oprs: list instr_print_operand) : instr_print
val print_s (name: string) (oprs: list instr_print_operand) : instr_print
let print_s (name:string) (oprs:list instr_print_operand) : instr_print = Print name PSuffix oprs
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 97, "end_line": 73, "start_col": 0, "start_line": 73 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args [@instr_attr] let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args noeq type instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) = { i_eval:instr_eval_t outs args; i_printer:instr_print_t outs args; // havoc_flags isn't used here, but we still need it in the type to track the semantics of each instr_t } let instr_eval #_ #_ #_ ins = ins.i_eval let rec instr_printer_args (args:list instr_operand) (f:instr_print_t_args args) (oprs:instr_operands_t_args args) : instr_print = match args with | [] -> f | i::args -> ( match i with | IOpEx i -> // REVIEW: triggers F* -> OCaml bug: let f:arrow (instr_operand_t i) (instr_print_t_args args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_args args (coerce #(arrow (instr_operand_t i) (instr_print_t_args args)) #(instr_print_t_args ((IOpEx i)::args)) f o) oprs | IOpIm _ -> instr_printer_args args (coerce f) (coerce #(instr_operands_t_args args) oprs) ) let rec instr_printer_outs (outs:list instr_out) (args:list instr_operand) (f:instr_print_t outs args) (oprs:instr_operands_t outs args) : instr_print = match outs with | [] -> instr_printer_args args f oprs // | (_, i)::outs -> | (b, i)::outs -> ( match i with | IOpEx i -> // let f:arrow (instr_operand_t i) (instr_print_t outs args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_outs outs args (coerce #(arrow (instr_operand_t i) (instr_print_t outs args)) #(instr_print_t ((b, (IOpEx i))::outs) args) f o) oprs | IOpIm _ -> instr_printer_outs outs args (coerce f) (coerce #(instr_operands_t outs args) oprs) ) let instr_printer #outs #args #_ ins oprs = instr_printer_outs outs args ins.i_printer oprs let make_ins (#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc) (#f:normal (instr_eval_t outs args)) (print:normal (instr_print_t outs args)) : instr_dep outs args havoc_flags f = {i_printer = print; i_eval = f}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
name: Prims.string -> oprs: Prims.list Vale.X64.Instruction_s.instr_print_operand -> Vale.X64.Instruction_s.instr_print
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "Prims.list", "Vale.X64.Instruction_s.instr_print_operand", "Vale.X64.Instruction_s.Print", "Vale.X64.Instruction_s.PSuffix", "Vale.X64.Instruction_s.instr_print" ]
[]
false
false
false
true
false
let print_s (name: string) (oprs: list instr_print_operand) : instr_print =
Print name PSuffix oprs
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.safe_arg_typ_or_comp
val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)})
val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)})
let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 404, "start_col": 0, "start_line": 382 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dbg: Prims.bool -> e: FStar.Stubs.Reflection.Types.env -> hd: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (opt: FStar.Pervasives.Native.option FStar.InteractiveHelpers.ExploreTerm.typ_or_comp {Some? opt ==> TC_Typ? (Some?.v opt)})
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.bool", "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.None", "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.Pervasives.Native.option", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.InteractiveHelpers.ExploreTerm.uu___is_TC_Typ", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.Some", "FStar.InteractiveHelpers.ExploreTerm.TC_Typ", "FStar.Reflection.V1.Derived.type_of_binder", "Prims.Nil", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Stubs.Tactics.V1.Builtins.inspect", "Prims.unit", "FStar.InteractiveHelpers.Base.print_dbg", "Prims.string", "Prims.op_Hat", "FStar.Stubs.Tactics.V1.Builtins.term_to_string", "FStar.Stubs.Reflection.Types.typ", "FStar.InteractiveHelpers.ExploreTerm.unfold_until_arrow", "FStar.Stubs.Reflection.V1.Data.uu___is_Tv_Arrow", "FStar.InteractiveHelpers.ExploreTerm.safe_tc" ]
[]
false
true
false
false
false
let safe_arg_typ_or_comp dbg e hd =
print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then (print_dbg dbg "no need to unfold the type"; ty) else (print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : " ^ term_to_string ty); ty) in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.instr_print_t
val instr_print_t (outs: list instr_out) (args: list instr_operand) : Type0
val instr_print_t (outs: list instr_out) (args: list instr_operand) : Type0
let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 17, "start_col": 0, "start_line": 13 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
outs: Prims.list Vale.X64.Instruction_s.instr_out -> args: Prims.list Vale.X64.Instruction_s.instr_operand -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_print_t_args", "Vale.X64.Instruction_s.instr_operand_inout", "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.arrow", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Instruction_s.instr_print_t", "Vale.X64.Instruction_s.instr_operand_implicit" ]
[ "recursion" ]
false
false
false
true
true
let rec instr_print_t (outs: list instr_out) (args: list instr_operand) : Type0 =
match outs with | [] -> instr_print_t_args args | (_, IOpEx i) :: outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _) :: outs -> instr_print_t outs args
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.instr_print_t_args
val instr_print_t_args (args: list instr_operand) : Type0
val instr_print_t_args (args: list instr_operand) : Type0
let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 10, "start_col": 0, "start_line": 6 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
args: Prims.list Vale.X64.Instruction_s.instr_operand -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_print", "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.arrow", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Instruction_s.instr_print_t_args", "Vale.X64.Instruction_s.instr_operand_implicit" ]
[ "recursion" ]
false
false
false
true
true
let rec instr_print_t_args (args: list instr_operand) : Type0 =
match args with | [] -> instr_print | IOpEx i :: args -> arrow (instr_operand_t i) (instr_print_t_args args) | IOpIm _ :: args -> instr_print_t_args args
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm._flush_typ_or_comp_comp
val _flush_typ_or_comp_comp (dbg: bool) (e: env) (rem: list binder) (inst: list ((bv & typ) & term)) (c: comp) : Tac comp
val _flush_typ_or_comp_comp (dbg: bool) (e: env) (rem: list binder) (inst: list ((bv & typ) & term)) (c: comp) : Tac comp
let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem)
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 86, "end_line": 359, "start_col": 0, "start_line": 336 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dbg: Prims.bool -> e: FStar.Stubs.Reflection.Types.env -> rem: Prims.list FStar.Stubs.Reflection.Types.binder -> inst: Prims.list ((FStar.Stubs.Reflection.Types.bv * FStar.Stubs.Reflection.Types.typ) * FStar.Stubs.Reflection.Types.term) -> c: FStar.Stubs.Reflection.Types.comp -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.comp
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.bool", "FStar.Stubs.Reflection.Types.env", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.comp", "FStar.InteractiveHelpers.ExploreTerm._flush_typ_or_comp_comp", "Prims.Cons", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Tactics.V1.Builtins.pack", "FStar.Stubs.Reflection.V1.Data.Tv_Var", "FStar.Reflection.V1.Derived.bv_of_binder", "FStar.Tactics.V1.Derived.binder_sort", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.InteractiveHelpers.Base.mfail", "Prims.string", "Prims.op_Hat", "FStar.InteractiveHelpers.Base.list_to_string", "FStar.Tactics.V1.Derived.name_of_binder", "FStar.InteractiveHelpers.Base.acomp_to_string", "FStar.Stubs.Tactics.V1.Builtins.inspect", "Prims.Nil", "FStar.InteractiveHelpers.ExploreTerm.get_comp_ret_type", "FStar.Stubs.Reflection.V1.Data.uu___is_Tv_Arrow", "FStar.InteractiveHelpers.Base.apply_subst_in_comp", "FStar.List.Tot.Base.rev" ]
[ "recursion" ]
false
true
false
false
false
let rec _flush_typ_or_comp_comp (dbg: bool) (e: env) (rem: list binder) (inst: list ((bv & typ) & term)) (c: comp) : Tac comp =
let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> flush c inst | b :: rem' -> let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b))) :: inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem )
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.free_in
val free_in : term -> Tac (list bv)
val free_in : term -> Tac (list bv)
let free_in t = let same_name (bv1 bv2 : bv) : Tac bool = name_of_bv bv1 = name_of_bv bv2 in let update_free (fl:list bv) (ge:genv) (pl:list (genv & term_view)) (c:option typ_or_comp) (tv:term_view) : Tac (list bv & ctrl_flag) = match tv with | Tv_Var bv | Tv_BVar bv -> (* Check if the binding was not introduced during the traversal *) begin match genv_get_from_name ge (name_of_bv bv) with | None -> (* Check if we didn't already count the binding *) let fl' = if Tactics.tryFind (same_name bv) fl then fl else bv :: fl in fl', Continue | Some _ -> fl, Continue end | _ -> fl, Continue in let e = top_env () in (* we actually don't care about the environment *) let ge = mk_genv e [] [] in List.Tot.rev (fst (explore_term false false update_free [] ge [] None t))
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 75, "end_line": 593, "start_col": 0, "start_line": 572 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort /// TODO: for now I need to use universe 0 for type a because otherwise it doesn't /// type check /// ctrl_flag: /// - Continue: continue exploring the term /// - Skip: don't explore the sub-terms of this term /// - Abort: stop exploration /// TODO: we might want a more precise control (like: don't explore the type of the /// ascription but explore its body) /// Note that ``explore_term`` doesn't use the environment parameter besides pushing /// binders and passing it to ``f``, which means that you can give it arbitrary /// environments, ``explore_term`` itself won't fail (but the passed function might). let explorer (a : Type) = a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag) // TODO: use more let bind_expl (#a : Type) (x : a) (f1 f2 : a -> Tac (a & ctrl_flag)) : Tac (a & ctrl_flag) = let x1, flag1 = f1 x in if flag1 = Continue then f2 x1 else x1, convert_ctrl_flag flag1 // TODO: change the signature to move the dbg flag val explore_term : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge : genv (* the list of terms traversed so far (first is most recent) with the environment * at the time they were traversed *) -> parents : list (genv & term_view) -> c : option typ_or_comp -> t:term -> Tac (a & ctrl_flag) val explore_pattern : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge:genv -> pat:pattern -> Tac (genv & a & ctrl_flag) (* TODO: carry around the list of encompassing terms *) let rec explore_term dbg dfs #a f x ge0 pl0 c0 t0 = print_dbg dbg ("[> explore_term: " ^ term_construct t0 ^ ":\n" ^ term_to_string t0); let tv0 = inspect t0 in let x0, flag = f x ge0 pl0 c0 tv0 in let pl1 = (ge0, tv0) :: pl0 in if flag = Continue then begin match tv0 with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ -> x0, Continue | Tv_App hd (a,qual) -> (* Explore the argument - we update the target typ_or_comp when doing so. * Note that the only way to get the correct target type is to deconstruct * the type of the head *) let a_c = safe_arg_typ_or_comp dbg ge0.env hd in print_dbg dbg ("Tv_App: updated target typ_or_comp to:\n" ^ option_to_string typ_or_comp_to_string a_c); let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 a_c a in (* Explore the head - no type information here: we can compute it, * but it seems useless (or maybe use it only if it is not Total) *) if flag1 = Continue then explore_term dbg dfs f x1 ge0 pl1 None hd else x1, convert_ctrl_flag flag1 | Tv_Abs br body -> let ge1 = genv_push_binder ge0 br false None in let c1 = abs_update_opt_typ_or_comp br c0 ge1.env in explore_term dbg dfs f x0 ge1 pl1 c1 body | Tv_Arrow br c0 -> x0, Continue (* TODO: we might want to explore that *) | Tv_Type _ -> x0, Continue | Tv_Refine bv sort ref -> let bvv = inspect_bv bv in let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 None sort in if flag1 = Continue then let ge1 = genv_push_bv ge0 bv sort false None in explore_term dbg dfs f x1 ge1 pl1 None ref else x1, convert_ctrl_flag flag1 | Tv_Const _ -> x0, Continue | Tv_Uvar _ _ -> x0, Continue | Tv_Let recf attrs bv ty def body -> (* Binding definition exploration - for the target computation: initially we * used the type of the definition, however it is often unnecessarily complex. * Now, we use the type of the binder used for the binding. *) let def_c = Some (TC_Typ ty [] 0) in let explore_def x = explore_term dbg dfs f x ge0 pl1 def_c def in (* Exploration of the following instructions *) let ge1 = genv_push_bv ge0 bv ty false (Some def) in let explore_next x = explore_term dbg dfs f x ge1 pl1 c0 body in (* Perform the exploration in the proper order *) let expl1, expl2 = if dfs then explore_next, explore_def else explore_def, explore_next in bind_expl x0 expl1 expl2 | Tv_Match scrutinee _ret_opt branches -> //AR: TODO: need to account for returns annotation here (* Auxiliary function to explore the branches *) let explore_branch (x_flag : a & ctrl_flag) (br : branch) : Tac (a & ctrl_flag)= let x0, flag = x_flag in if flag = Continue then let pat, branch_body = br in (* Explore the pattern *) let ge1, x1, flag1 = explore_pattern dbg dfs #a f x0 ge0 pat in if flag1 = Continue then (* Explore the branch body *) explore_term dbg dfs #a f x1 ge1 pl1 c0 branch_body else x1, convert_ctrl_flag flag1 (* Don't convert the flag *) else x0, flag in (* Explore the scrutinee *) let scrut_c = safe_typ_or_comp dbg ge0.env scrutinee in let x1 = explore_term dbg dfs #a f x0 ge0 pl1 scrut_c scrutinee in (* Explore the branches *) fold_left explore_branch x1 branches | Tv_AscribedT e ty tac _ -> let c1 = Some (TC_Typ ty [] 0) in let x1, flag = explore_term dbg dfs #a f x0 ge0 pl1 None ty in if flag = Continue then explore_term dbg dfs #a f x1 ge0 pl1 c1 e else x1, convert_ctrl_flag flag | Tv_AscribedC e c1 tac _ -> (* TODO: explore the comp *) explore_term dbg dfs #a f x0 ge0 pl1 (Some (TC_Comp c1 [] 0)) e | _ -> (* Unknown *) x0, Continue end else x0, convert_ctrl_flag flag and explore_pattern dbg dfs #a f x ge0 pat = print_dbg dbg ("[> explore_pattern:"); match pat with | Pat_Constant _ -> ge0, x, Continue | Pat_Cons fv us patterns -> let explore_pat ge_x_flag pat = let ge0, x, flag = ge_x_flag in let pat1, _ = pat in if flag = Continue then explore_pattern dbg dfs #a f x ge0 pat1 else (* Don't convert the flag *) ge0, x, flag in fold_left explore_pat (ge0, x, Continue) patterns | Pat_Var bv st -> let ge1 = genv_push_bv ge0 bv (unseal st) false None in ge1, x, Continue | Pat_Dot_Term _ -> ge0, x, Continue (*** Variables in a term *) /// Returns the list of free variables contained in a term
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (Prims.list FStar.Stubs.Reflection.Types.bv)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.List.Tot.Base.rev", "FStar.Stubs.Reflection.Types.bv", "Prims.list", "FStar.Pervasives.Native.fst", "FStar.Stubs.Tactics.Types.ctrl_flag", "FStar.Pervasives.Native.tuple2", "FStar.InteractiveHelpers.ExploreTerm.explore_term", "Prims.Nil", "FStar.InteractiveHelpers.Base.genv", "FStar.Stubs.Reflection.V1.Data.term_view", "FStar.Pervasives.Native.None", "FStar.InteractiveHelpers.ExploreTerm.typ_or_comp", "FStar.InteractiveHelpers.Base.mk_genv", "FStar.Pervasives.Native.tuple3", "FStar.Stubs.Reflection.Types.typ", "Prims.bool", "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Tactics.V1.Builtins.top_env", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Tactics.Types.Continue", "Prims.Cons", "FStar.Tactics.Util.tryFind", "FStar.InteractiveHelpers.Base.genv_get_from_name", "Prims.string", "FStar.Tactics.V1.Derived.name_of_bv", "Prims.op_Equality" ]
[]
false
true
false
false
false
let free_in t =
let same_name (bv1 bv2: bv) : Tac bool = name_of_bv bv1 = name_of_bv bv2 in let update_free (fl: list bv) (ge: genv) (pl: list (genv & term_view)) (c: option typ_or_comp) (tv: term_view) : Tac (list bv & ctrl_flag) = match tv with | Tv_Var bv | Tv_BVar bv -> (match genv_get_from_name ge (name_of_bv bv) with | None -> let fl' = if Tactics.tryFind (same_name bv) fl then fl else bv :: fl in fl', Continue | Some _ -> fl, Continue) | _ -> fl, Continue in let e = top_env () in let ge = mk_genv e [] [] in List.Tot.rev (fst (explore_term false false update_free [] ge [] None t))
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.instr_printer_args
val instr_printer_args (args: list instr_operand) (f: instr_print_t_args args) (oprs: instr_operands_t_args args) : instr_print
val instr_printer_args (args: list instr_operand) (f: instr_print_t_args args) (oprs: instr_operands_t_args args) : instr_print
let rec instr_printer_args (args:list instr_operand) (f:instr_print_t_args args) (oprs:instr_operands_t_args args) : instr_print = match args with | [] -> f | i::args -> ( match i with | IOpEx i -> // REVIEW: triggers F* -> OCaml bug: let f:arrow (instr_operand_t i) (instr_print_t_args args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_args args (coerce #(arrow (instr_operand_t i) (instr_print_t_args args)) #(instr_print_t_args ((IOpEx i)::args)) f o) oprs | IOpIm _ -> instr_printer_args args (coerce f) (coerce #(instr_operands_t_args args) oprs) )
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 42, "start_col": 0, "start_line": 27 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args [@instr_attr] let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args noeq type instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) = { i_eval:instr_eval_t outs args; i_printer:instr_print_t outs args; // havoc_flags isn't used here, but we still need it in the type to track the semantics of each instr_t } let instr_eval #_ #_ #_ ins = ins.i_eval
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
args: Prims.list Vale.X64.Instruction_s.instr_operand -> f: Vale.X64.Instruction_s.instr_print_t_args args -> oprs: Vale.X64.Instruction_s.instr_operands_t_args args -> Vale.X64.Instruction_s.instr_print
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_print_t_args", "Vale.X64.Instruction_s.instr_operands_t_args", "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Instruction_s.instr_printer_args", "Vale.X64.Instruction_s.coerce", "Vale.X64.Instruction_s.arrow", "Prims.Cons", "Vale.X64.Instruction_s.IOpEx", "Vale.X64.Instruction_s.instr_print", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.instr_operand_implicit" ]
[ "recursion" ]
false
false
false
false
false
let rec instr_printer_args (args: list instr_operand) (f: instr_print_t_args args) (oprs: instr_operands_t_args args) : instr_print =
match args with | [] -> f | i :: args -> (match i with | IOpEx i -> let o, oprs = coerce oprs in instr_printer_args args (coerce #(arrow (instr_operand_t i) (instr_print_t_args args)) #(instr_print_t_args ((IOpEx i) :: args)) f o) oprs | IOpIm _ -> instr_printer_args args (coerce f) (coerce #(instr_operands_t_args args) oprs))
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.make_ins
val make_ins (#outs: list instr_out) (#args: list instr_operand) (#havoc_flags: flag_havoc) (#f: normal (instr_eval_t outs args)) (print: normal (instr_print_t outs args)) : instr_dep outs args havoc_flags f
val make_ins (#outs: list instr_out) (#args: list instr_operand) (#havoc_flags: flag_havoc) (#f: normal (instr_eval_t outs args)) (print: normal (instr_print_t outs args)) : instr_dep outs args havoc_flags f
let make_ins (#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc) (#f:normal (instr_eval_t outs args)) (print:normal (instr_print_t outs args)) : instr_dep outs args havoc_flags f = {i_printer = print; i_eval = f}
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 70, "start_col": 0, "start_line": 65 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args [@instr_attr] let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args noeq type instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) = { i_eval:instr_eval_t outs args; i_printer:instr_print_t outs args; // havoc_flags isn't used here, but we still need it in the type to track the semantics of each instr_t } let instr_eval #_ #_ #_ ins = ins.i_eval let rec instr_printer_args (args:list instr_operand) (f:instr_print_t_args args) (oprs:instr_operands_t_args args) : instr_print = match args with | [] -> f | i::args -> ( match i with | IOpEx i -> // REVIEW: triggers F* -> OCaml bug: let f:arrow (instr_operand_t i) (instr_print_t_args args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_args args (coerce #(arrow (instr_operand_t i) (instr_print_t_args args)) #(instr_print_t_args ((IOpEx i)::args)) f o) oprs | IOpIm _ -> instr_printer_args args (coerce f) (coerce #(instr_operands_t_args args) oprs) ) let rec instr_printer_outs (outs:list instr_out) (args:list instr_operand) (f:instr_print_t outs args) (oprs:instr_operands_t outs args) : instr_print = match outs with | [] -> instr_printer_args args f oprs // | (_, i)::outs -> | (b, i)::outs -> ( match i with | IOpEx i -> // let f:arrow (instr_operand_t i) (instr_print_t outs args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_outs outs args (coerce #(arrow (instr_operand_t i) (instr_print_t outs args)) #(instr_print_t ((b, (IOpEx i))::outs) args) f o) oprs | IOpIm _ -> instr_printer_outs outs args (coerce f) (coerce #(instr_operands_t outs args) oprs) ) let instr_printer #outs #args #_ ins oprs = instr_printer_outs outs args ins.i_printer oprs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
print: Vale.X64.Instruction_s.normal (Vale.X64.Instruction_s.instr_print_t outs args) -> Vale.X64.Instruction_s.instr_dep outs args havoc_flags f
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.flag_havoc", "Vale.X64.Instruction_s.normal", "Vale.X64.Instruction_s.instr_eval_t", "Vale.X64.Instruction_s.instr_print_t", "Vale.X64.Instruction_s.Mkinstr_t", "Vale.X64.Instruction_s.instr_dep" ]
[]
false
false
false
false
false
let make_ins (#outs: list instr_out) (#args: list instr_operand) (#havoc_flags: flag_havoc) (#f: normal (instr_eval_t outs args)) (print: normal (instr_print_t outs args)) : instr_dep outs args havoc_flags f =
{ i_printer = print; i_eval = f }
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.instr_eval
val instr_eval (#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc) (i:instr_t outs args havoc_flags) // : normal (instr_eval_t outs args) : norm [zeta; iota; delta_attr [`%instr_attr]] (instr_eval_t outs args)
val instr_eval (#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc) (i:instr_t outs args havoc_flags) // : normal (instr_eval_t outs args) : norm [zeta; iota; delta_attr [`%instr_attr]] (instr_eval_t outs args)
let instr_eval #_ #_ #_ ins = ins.i_eval
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 25, "start_col": 0, "start_line": 25 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args [@instr_attr] let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args noeq type instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) = { i_eval:instr_eval_t outs args; i_printer:instr_print_t outs args; // havoc_flags isn't used here, but we still need it in the type to track the semantics of each instr_t }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Vale.X64.Instruction_s.instr_t outs args havoc_flags -> FStar.Pervasives.norm [ FStar.Pervasives.zeta; FStar.Pervasives.iota; FStar.Pervasives.delta_attr ["Vale.X64.Instruction_s.instr_attr"] ] (Vale.X64.Instruction_s.instr_eval_t outs args)
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.flag_havoc", "Vale.X64.Instruction_s.instr_t", "Vale.X64.Instruction_s.__proj__Mkinstr_t__item__i_eval", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "Vale.X64.Instruction_s.instr_eval_t" ]
[]
false
false
false
false
false
let instr_eval #_ #_ #_ ins =
ins.i_eval
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.instr_printer
val instr_printer (#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc) (i:instr_t outs args havoc_flags) (oprs:normal (instr_operands_t outs args)) : instr_print
val instr_printer (#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc) (i:instr_t outs args havoc_flags) (oprs:normal (instr_operands_t outs args)) : instr_print
let instr_printer #outs #args #_ ins oprs = instr_printer_outs outs args ins.i_printer oprs
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 63, "start_col": 0, "start_line": 62 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args [@instr_attr] let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args noeq type instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) = { i_eval:instr_eval_t outs args; i_printer:instr_print_t outs args; // havoc_flags isn't used here, but we still need it in the type to track the semantics of each instr_t } let instr_eval #_ #_ #_ ins = ins.i_eval let rec instr_printer_args (args:list instr_operand) (f:instr_print_t_args args) (oprs:instr_operands_t_args args) : instr_print = match args with | [] -> f | i::args -> ( match i with | IOpEx i -> // REVIEW: triggers F* -> OCaml bug: let f:arrow (instr_operand_t i) (instr_print_t_args args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_args args (coerce #(arrow (instr_operand_t i) (instr_print_t_args args)) #(instr_print_t_args ((IOpEx i)::args)) f o) oprs | IOpIm _ -> instr_printer_args args (coerce f) (coerce #(instr_operands_t_args args) oprs) ) let rec instr_printer_outs (outs:list instr_out) (args:list instr_operand) (f:instr_print_t outs args) (oprs:instr_operands_t outs args) : instr_print = match outs with | [] -> instr_printer_args args f oprs // | (_, i)::outs -> | (b, i)::outs -> ( match i with | IOpEx i -> // let f:arrow (instr_operand_t i) (instr_print_t outs args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_outs outs args (coerce #(arrow (instr_operand_t i) (instr_print_t outs args)) #(instr_print_t ((b, (IOpEx i))::outs) args) f o) oprs | IOpIm _ -> instr_printer_outs outs args (coerce f) (coerce #(instr_operands_t outs args) oprs) )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Vale.X64.Instruction_s.instr_t outs args havoc_flags -> oprs: Vale.X64.Instruction_s.normal (Vale.X64.Instruction_s.instr_operands_t outs args) -> Vale.X64.Instruction_s.instr_print
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.flag_havoc", "Vale.X64.Instruction_s.instr_t", "Vale.X64.Instruction_s.normal", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.instr_printer_outs", "Vale.X64.Instruction_s.__proj__Mkinstr_t__item__i_printer", "Vale.X64.Instruction_s.instr_print" ]
[]
false
false
false
false
false
let instr_printer #outs #args #_ ins oprs =
instr_printer_outs outs args ins.i_printer oprs
false
Vale.X64.Instruction_s.fst
Vale.X64.Instruction_s.instr_printer_outs
val instr_printer_outs (outs: list instr_out) (args: list instr_operand) (f: instr_print_t outs args) (oprs: instr_operands_t outs args) : instr_print
val instr_printer_outs (outs: list instr_out) (args: list instr_operand) (f: instr_print_t outs args) (oprs: instr_operands_t outs args) : instr_print
let rec instr_printer_outs (outs:list instr_out) (args:list instr_operand) (f:instr_print_t outs args) (oprs:instr_operands_t outs args) : instr_print = match outs with | [] -> instr_printer_args args f oprs // | (_, i)::outs -> | (b, i)::outs -> ( match i with | IOpEx i -> // let f:arrow (instr_operand_t i) (instr_print_t outs args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_outs outs args (coerce #(arrow (instr_operand_t i) (instr_print_t outs args)) #(instr_print_t ((b, (IOpEx i))::outs) args) f o) oprs | IOpIm _ -> instr_printer_outs outs args (coerce f) (coerce #(instr_operands_t outs args) oprs) )
{ "file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 60, "start_col": 0, "start_line": 44 }
module Vale.X64.Instruction_s open FStar.Mul // only trusted specification files should friend this module [@instr_attr] let rec instr_print_t_args (args:list instr_operand) : Type0 = match args with | [] -> instr_print | (IOpEx i)::args -> arrow (instr_operand_t i) (instr_print_t_args args) | (IOpIm _)::args -> instr_print_t_args args [@instr_attr] let rec instr_print_t (outs:list instr_out) (args:list instr_operand) : Type0 = match outs with | [] -> instr_print_t_args args | (_, IOpEx i)::outs -> arrow (instr_operand_t i) (instr_print_t outs args) | (_, IOpIm _)::outs -> instr_print_t outs args noeq type instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) = { i_eval:instr_eval_t outs args; i_printer:instr_print_t outs args; // havoc_flags isn't used here, but we still need it in the type to track the semantics of each instr_t } let instr_eval #_ #_ #_ ins = ins.i_eval let rec instr_printer_args (args:list instr_operand) (f:instr_print_t_args args) (oprs:instr_operands_t_args args) : instr_print = match args with | [] -> f | i::args -> ( match i with | IOpEx i -> // REVIEW: triggers F* -> OCaml bug: let f:arrow (instr_operand_t i) (instr_print_t_args args) = coerce f in let (o, oprs) = coerce oprs in instr_printer_args args (coerce #(arrow (instr_operand_t i) (instr_print_t_args args)) #(instr_print_t_args ((IOpEx i)::args)) f o) oprs | IOpIm _ -> instr_printer_args args (coerce f) (coerce #(instr_operands_t_args args) oprs) )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Instruction_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
outs: Prims.list Vale.X64.Instruction_s.instr_out -> args: Prims.list Vale.X64.Instruction_s.instr_operand -> f: Vale.X64.Instruction_s.instr_print_t outs args -> oprs: Vale.X64.Instruction_s.instr_operands_t outs args -> Vale.X64.Instruction_s.instr_print
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_print_t", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.instr_printer_args", "Vale.X64.Instruction_s.instr_operand_inout", "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Instruction_s.instr_printer_outs", "Vale.X64.Instruction_s.coerce", "Vale.X64.Instruction_s.arrow", "Prims.Cons", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Instruction_s.IOpEx", "Vale.X64.Instruction_s.instr_print", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.instr_operand_implicit" ]
[ "recursion" ]
false
false
false
false
false
let rec instr_printer_outs (outs: list instr_out) (args: list instr_operand) (f: instr_print_t outs args) (oprs: instr_operands_t outs args) : instr_print =
match outs with | [] -> instr_printer_args args f oprs | (b, i) :: outs -> (match i with | IOpEx i -> let o, oprs = coerce oprs in instr_printer_outs outs args (coerce #(arrow (instr_operand_t i) (instr_print_t outs args)) #(instr_print_t ((b, (IOpEx i)) :: outs) args) f o) oprs | IOpIm _ -> instr_printer_outs outs args (coerce f) (coerce #(instr_operands_t outs args) oprs) )
false
Hacl.Impl.Ed25519.PointDouble.fst
Hacl.Impl.Ed25519.PointDouble.point_double_step_2
val point_double_step_2: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p /\ F51.felem_fits h (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let c = F51.fevalh h0 (gsub tmp 0ul 5ul) in let h = F51.fevalh h0 (gsub tmp 10ul 5ul) in let g = F51.fevalh h0 (gsub tmp 15ul 5ul) in let e = h `SC.fsub` ((x1 `SC.fadd` y1) `SC.fmul` (x1 `SC.fadd` y1)) in let f = c `SC.fadd` g in F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g))
val point_double_step_2: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p /\ F51.felem_fits h (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let c = F51.fevalh h0 (gsub tmp 0ul 5ul) in let h = F51.fevalh h0 (gsub tmp 10ul 5ul) in let g = F51.fevalh h0 (gsub tmp 15ul 5ul) in let e = h `SC.fsub` ((x1 `SC.fadd` y1) `SC.fmul` (x1 `SC.fadd` y1)) in let f = c `SC.fadd` g in F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g))
let point_double_step_2 p tmp = let tmp1 = sub tmp 0ul 5ul in // c, f let tmp2 = sub tmp 5ul 5ul in // e let tmp3 = sub tmp 10ul 5ul in // h let tmp4 = sub tmp 15ul 5ul in // g let x1 = getx p in let y1 = gety p in fsum tmp2 x1 y1; // tmp2 = x1 + y1 fsquare tmp2 tmp2; // tmp2 = (x1 + y1) ** 2 reduce_513 tmp3; fdifference tmp2 tmp3 tmp2; // tmp2 = tmp3 - tmp2 = h - (x1 + y1) ** 2 = e reduce_513 tmp1; reduce_513 tmp4; fsum tmp1 tmp1 tmp4
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointDouble.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 92, "start_col": 0, "start_line": 77 }
module Hacl.Impl.Ed25519.PointDouble module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_double_step_1: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let a = x1 `SC.fmul` x1 in let b = y1 `SC.fmul` y1 in let c = 2 `SC.fmul` (z1 `SC.fmul` z1) in let h = a `SC.fadd` b in let g = a `SC.fsub` b in F51.felem_fits h1 (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (2, 4, 2, 2, 2) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == c)) let point_double_step_1 p tmp = let tmp1 = sub tmp 0ul 5ul in // c let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in // h let tmp4 = sub tmp 15ul 5ul in // g let x1 = getx p in let y1 = gety p in let z1 = getz p in fsquare tmp1 x1; // tmp1 = a fsquare tmp2 y1; // tmp2 = b fsum tmp3 tmp1 tmp2; // tmp3 = tmp1 + tmp2 = h fdifference tmp4 tmp1 tmp2; // tmp4 = tmp1 - tmp2 = g fsquare tmp1 z1; // tmp1 = z1 * z1 times_2 tmp1 tmp1 // tmp1 = 2 * tmp1 = c inline_for_extraction noextract val point_double_step_2: p:point -> tmp:lbuffer uint64 20ul -> Stack unit (requires fun h -> live h p /\ live h tmp /\ disjoint p tmp /\ F51.point_inv_t h p /\ F51.felem_fits h (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h (gsub tmp 0ul 5ul) (2, 4, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1, y1, z1, t1 = F51.point_eval h0 p in let c = F51.fevalh h0 (gsub tmp 0ul 5ul) in let h = F51.fevalh h0 (gsub tmp 10ul 5ul) in let g = F51.fevalh h0 (gsub tmp 15ul 5ul) in let e = h `SC.fsub` ((x1 `SC.fadd` y1) `SC.fmul` (x1 `SC.fadd` y1)) in let f = c `SC.fadd` g in F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 10ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 15ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == h /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == g))
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointDouble.fst" }
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 20ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Bignum25519.fsum", "Prims.unit", "Hacl.Bignum25519.reduce_513", "Hacl.Bignum25519.fdifference", "Hacl.Bignum25519.fsquare", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.gety", "Hacl.Bignum25519.getx", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
false
true
false
false
false
let point_double_step_2 p tmp =
let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let x1 = getx p in let y1 = gety p in fsum tmp2 x1 y1; fsquare tmp2 tmp2; reduce_513 tmp3; fdifference tmp2 tmp3 tmp2; reduce_513 tmp1; reduce_513 tmp4; fsum tmp1 tmp1 tmp4
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.vale_full_heap
val vale_full_heap : Type
let vale_full_heap = M.vale_full_heap
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 27, "start_col": 7, "start_line": 27 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Memory.vale_full_heap" ]
[]
false
false
false
true
true
let vale_full_heap =
M.vale_full_heap
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.vale_heap
val vale_heap : Type
let vale_heap = M.vale_heap
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 26, "start_col": 7, "start_line": 26 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Memory.vale_heap" ]
[]
false
false
false
true
true
let vale_heap =
M.vale_heap
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_subscript
val va_subscript (#a: eqtype) (#b: Type) (x: Map.t a b) (y: a) : Tot b
val va_subscript (#a: eqtype) (#b: Type) (x: Map.t a b) (y: a) : Tot b
let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 87, "end_line": 36, "start_col": 7, "start_line": 36 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Map.t a b -> y: a -> b
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.Map.t", "FStar.Map.sel" ]
[]
false
false
false
false
false
let va_subscript (#a: eqtype) (#b: Type) (x: Map.t a b) (y: a) : Tot b =
Map.sel x y
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_hd
val va_hd : projectee: _: Prims.list _ {Cons? _} -> _
let va_hd = Cons?.hd
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 38, "start_col": 7, "start_line": 38 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
projectee: _: Prims.list _ {Cons? _} -> _
Prims.Tot
[ "total" ]
[]
[ "Prims.__proj__Cons__item__hd", "Prims.list", "Prims.b2t", "Prims.uu___is_Cons" ]
[]
false
false
false
false
false
let va_hd =
Cons?.hd
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_reveal_eq
val va_reveal_eq : s: Prims.string -> x: ax -> x': ax -> Prims.logical
let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x'
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 109, "end_line": 43, "start_col": 19, "start_line": 43 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.string -> x: ax -> x': ax -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "Prims.eq2", "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.delta_only", "Prims.Nil", "Prims.logical" ]
[]
false
false
false
true
true
let va_reveal_eq (#ax: Type) (s: string) (x x': ax) =
norm [zeta; delta_only [s]] #ax x == x'
false
Vale.AES.X64.GCMencryptOpt.fsti
Vale.AES.X64.GCMencryptOpt.va_wp_Gctr_blocks128
val va_wp_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
val va_wp_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
let va_wp_Gctr_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b) (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r10:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32) (va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_sM) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key (va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_sM == 0 ==> Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) ==> va_k va_sM (())))
{ "file_name": "obj/Vale.AES.X64.GCMencryptOpt.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 173, "start_col": 0, "start_line": 143 }
module Vale.AES.X64.GCMencryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.OptPublic let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = aesni_enabled /\ avx_enabled /\ (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_LE alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_LE alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ s128 heap0 keys_b == round_keys //-- Gctr_register val va_code_Gctr_register : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_register : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_register : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_register alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.create #quad32 1 (va_get_xmm 8 va_sM)) == Vale.AES.GCTR_s.gctr_encrypt_LE (va_get_xmm 0 va_s0) (Vale.Def.Types_s.le_quad32_to_bytes (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0))) alg key /\ va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block (va_get_xmm 0 va_s0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) alg key 0) /\ va_state_eq va_sM (va_update_reg64 rR12 va_sM (va_update_flags va_sM (va_update_xmm 8 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))))))) [@ va_qattr] let va_wp_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0)) /\ (forall (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm8:quad32) (va_x_efl:Vale.X64.Flags.t) (va_x_r12:nat64) . let va_sM = va_upd_reg64 rR12 va_x_r12 (va_upd_flags va_x_efl (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 va_s0))))) in va_get_ok va_sM /\ (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.create #quad32 1 (va_get_xmm 8 va_sM)) == Vale.AES.GCTR_s.gctr_encrypt_LE (va_get_xmm 0 va_s0) (Vale.Def.Types_s.le_quad32_to_bytes (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0))) alg key /\ va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block (va_get_xmm 0 va_s0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) alg key 0) ==> va_k va_sM (()))) val va_wpProof_Gctr_register : alg:algorithm -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gctr_register alg key round_keys keys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_register alg) ([va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 8; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Gctr_register (alg:algorithm) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) = (va_QProc (va_code_Gctr_register alg) ([va_Mod_reg64 rR12; va_Mod_flags; va_Mod_xmm 8; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0]) (va_wp_Gctr_register alg key round_keys keys_b) (va_wpProof_Gctr_register alg key round_keys keys_b)) //-- //-- Gctr_blocks128 val va_code_Gctr_blocks128 : alg:algorithm -> Tot va_code val va_codegen_success_Gctr_blocks128 : alg:algorithm -> Tot va_pbool val va_lemma_Gctr_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gctr_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b) (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_sM) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key (va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_sM == 0 ==> Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.GCMencryptOpt.fsti" }
[ { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> in_b: Vale.X64.Memory.buffer128 -> out_b: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_b: Vale.X64.Memory.buffer128 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.sse_enabled", "Prims.l_or", "Vale.X64.Decls.buffers_disjoint128", "Prims.eq2", "Vale.X64.Decls.validSrcAddrs128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.validDstAddrs128", "Vale.X64.Machine_s.rRdi", "Prims.op_LessThan", "Prims.op_Addition", "Prims.op_Multiply", "Vale.X64.Machine_s.pow2_64", "Prims.nat", "Vale.X64.Decls.buffer_length", "Vale.X64.Memory.vuint128", "Vale.X64.Machine_s.pow2_32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.X64.Decls.va_get_xmm", "Vale.Def.Words_s.Mkfour", "Vale.AES.X64.GCMencryptOpt.aes_reqs", "Vale.X64.Machine_s.rR8", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "Prims.l_Forall", "Vale.X64.InsBasic.vale_heap", "Vale.X64.Memory.nat64", "Vale.X64.Flags.t", "Prims.l_imp", "Vale.X64.Decls.modifies_buffer128", "Vale.AES.GCTR.gctr_partial", "Vale.X64.Decls.s128", "Vale.Def.Types_s.quad32", "Vale.AES.GCTR.inc32lite", "Prims.int", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_mem_heaplet", "Vale.X64.Decls.va_upd_xmm", "Vale.X64.Decls.va_upd_reg64", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rRbx", "Vale.X64.Decls.va_upd_mem" ]
[]
false
false
false
true
true
let va_wp_Gctr_blocks128 (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b) (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled) /\ (forall (va_x_mem: vale_heap) (va_x_rbx: nat64) (va_x_r11: nat64) (va_x_r10: nat64) (va_x_xmm0: quad32) (va_x_xmm1: quad32) (va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_xmm4: quad32) (va_x_xmm5: quad32) (va_x_xmm6: quad32) (va_x_xmm11: quad32) (va_x_xmm10: quad32) (va_x_heap1: vale_heap) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_mem va_x_mem va_s0)))))))))))) )) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_sM) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key (va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_sM == 0 ==> Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) ==> va_k va_sM (())))
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_reveal_opaque
val va_reveal_opaque : s: Prims.string -> x: _ -> FStar.Pervasives.Lemma (ensures FStar.Pervasives.norm [FStar.Pervasives.zeta; FStar.Pervasives.delta_only [s]] x == x)
let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]]
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 66, "end_line": 44, "start_col": 0, "start_line": 44 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized?
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.string -> x: _ -> FStar.Pervasives.Lemma (ensures FStar.Pervasives.norm [FStar.Pervasives.zeta; FStar.Pervasives.delta_only [s]] x == x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.string", "FStar.Pervasives.norm_spec", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.delta_only", "Prims.Nil", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.norm", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let va_reveal_opaque (s: string) =
norm_spec [zeta; delta_only [s]]
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_int_at_least
val va_int_at_least : k: Prims.int -> Type0
let va_int_at_least (k:int) = i:int{i >= k}
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 51, "start_col": 0, "start_line": 51 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Prims.int -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual" ]
[]
false
false
false
true
true
let va_int_at_least (k: int) =
i: int{i >= k}
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.heaplet_id
val heaplet_id : Type0
let heaplet_id = M.heaplet_id
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 28, "start_col": 7, "start_line": 28 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Memory.heaplet_id" ]
[]
false
false
false
true
true
let heaplet_id =
M.heaplet_id
false
FStar.InteractiveHelpers.ExploreTerm.fst
FStar.InteractiveHelpers.ExploreTerm.explore_pattern
val explore_pattern : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge:genv -> pat:pattern -> Tac (genv & a & ctrl_flag)
val explore_pattern : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge:genv -> pat:pattern -> Tac (genv & a & ctrl_flag)
let rec explore_term dbg dfs #a f x ge0 pl0 c0 t0 = print_dbg dbg ("[> explore_term: " ^ term_construct t0 ^ ":\n" ^ term_to_string t0); let tv0 = inspect t0 in let x0, flag = f x ge0 pl0 c0 tv0 in let pl1 = (ge0, tv0) :: pl0 in if flag = Continue then begin match tv0 with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ -> x0, Continue | Tv_App hd (a,qual) -> (* Explore the argument - we update the target typ_or_comp when doing so. * Note that the only way to get the correct target type is to deconstruct * the type of the head *) let a_c = safe_arg_typ_or_comp dbg ge0.env hd in print_dbg dbg ("Tv_App: updated target typ_or_comp to:\n" ^ option_to_string typ_or_comp_to_string a_c); let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 a_c a in (* Explore the head - no type information here: we can compute it, * but it seems useless (or maybe use it only if it is not Total) *) if flag1 = Continue then explore_term dbg dfs f x1 ge0 pl1 None hd else x1, convert_ctrl_flag flag1 | Tv_Abs br body -> let ge1 = genv_push_binder ge0 br false None in let c1 = abs_update_opt_typ_or_comp br c0 ge1.env in explore_term dbg dfs f x0 ge1 pl1 c1 body | Tv_Arrow br c0 -> x0, Continue (* TODO: we might want to explore that *) | Tv_Type _ -> x0, Continue | Tv_Refine bv sort ref -> let bvv = inspect_bv bv in let x1, flag1 = explore_term dbg dfs f x0 ge0 pl1 None sort in if flag1 = Continue then let ge1 = genv_push_bv ge0 bv sort false None in explore_term dbg dfs f x1 ge1 pl1 None ref else x1, convert_ctrl_flag flag1 | Tv_Const _ -> x0, Continue | Tv_Uvar _ _ -> x0, Continue | Tv_Let recf attrs bv ty def body -> (* Binding definition exploration - for the target computation: initially we * used the type of the definition, however it is often unnecessarily complex. * Now, we use the type of the binder used for the binding. *) let def_c = Some (TC_Typ ty [] 0) in let explore_def x = explore_term dbg dfs f x ge0 pl1 def_c def in (* Exploration of the following instructions *) let ge1 = genv_push_bv ge0 bv ty false (Some def) in let explore_next x = explore_term dbg dfs f x ge1 pl1 c0 body in (* Perform the exploration in the proper order *) let expl1, expl2 = if dfs then explore_next, explore_def else explore_def, explore_next in bind_expl x0 expl1 expl2 | Tv_Match scrutinee _ret_opt branches -> //AR: TODO: need to account for returns annotation here (* Auxiliary function to explore the branches *) let explore_branch (x_flag : a & ctrl_flag) (br : branch) : Tac (a & ctrl_flag)= let x0, flag = x_flag in if flag = Continue then let pat, branch_body = br in (* Explore the pattern *) let ge1, x1, flag1 = explore_pattern dbg dfs #a f x0 ge0 pat in if flag1 = Continue then (* Explore the branch body *) explore_term dbg dfs #a f x1 ge1 pl1 c0 branch_body else x1, convert_ctrl_flag flag1 (* Don't convert the flag *) else x0, flag in (* Explore the scrutinee *) let scrut_c = safe_typ_or_comp dbg ge0.env scrutinee in let x1 = explore_term dbg dfs #a f x0 ge0 pl1 scrut_c scrutinee in (* Explore the branches *) fold_left explore_branch x1 branches | Tv_AscribedT e ty tac _ -> let c1 = Some (TC_Typ ty [] 0) in let x1, flag = explore_term dbg dfs #a f x0 ge0 pl1 None ty in if flag = Continue then explore_term dbg dfs #a f x1 ge0 pl1 c1 e else x1, convert_ctrl_flag flag | Tv_AscribedC e c1 tac _ -> (* TODO: explore the comp *) explore_term dbg dfs #a f x0 ge0 pl1 (Some (TC_Comp c1 [] 0)) e | _ -> (* Unknown *) x0, Continue end else x0, convert_ctrl_flag flag and explore_pattern dbg dfs #a f x ge0 pat = print_dbg dbg ("[> explore_pattern:"); match pat with | Pat_Constant _ -> ge0, x, Continue | Pat_Cons fv us patterns -> let explore_pat ge_x_flag pat = let ge0, x, flag = ge_x_flag in let pat1, _ = pat in if flag = Continue then explore_pattern dbg dfs #a f x ge0 pat1 else (* Don't convert the flag *) ge0, x, flag in fold_left explore_pat (ge0, x, Continue) patterns | Pat_Var bv st -> let ge1 = genv_push_bv ge0 bv (unseal st) false None in ge1, x, Continue | Pat_Dot_Term _ -> ge0, x, Continue
{ "file_name": "ulib/experimental/FStar.InteractiveHelpers.ExploreTerm.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 567, "start_col": 0, "start_line": 466 }
module FStar.InteractiveHelpers.ExploreTerm open FStar.List open FStar.Tactics open FStar.Mul open FStar.InteractiveHelpers.Base #push-options "--z3rlimit 15 --fuel 0 --ifuel 1" (*** Types and effects *) /// Define utilities to handle and carry types and effects (**** Type analysis *) /// Retrieve and deconstruct a type/effect /// Some constants //let prims_true_qn = "Prims.l_True" //let prims_true_term = `Prims.l_True let pure_effect_qn = "Prims.PURE" let pure_hoare_effect_qn = "Prims.Pure" let stack_effect_qn = "FStar.HyperStack.ST.Stack" let st_effect_qn = "FStar.HyperStack.ST.ST" /// Return the qualifier of a comp as a string val comp_qualifier (c : comp) : Tac string #push-options "--ifuel 1" let comp_qualifier (c : comp) : Tac string = match inspect_comp c with | C_Total _ -> "C_Total" | C_GTotal _ -> "C_GTotal" | C_Lemma _ _ _ -> "C_Lemma" | C_Eff _ _ _ _ _ -> "C_Eff" #pop-options /// Effect information: we list the current supported effects type effect_type = | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure | E_Stack | E_ST | E_Unknown val effect_type_to_string : effect_type -> string #push-options "--ifuel 1" let effect_type_to_string ety = match ety with | E_Total -> "E_Total" | E_GTotal -> "E_GTotal" | E_Lemma -> "E_Lemma" | E_PURE -> "E_PURE" | E_Pure -> "E_Pure" | E_Stack -> "E_Stack" | E_ST -> "E_ST" | E_Unknown -> "E_Unknown" #pop-options val effect_name_to_type (ename : name) : Tot effect_type let effect_name_to_type (ename : name) : Tot effect_type = let ename = flatten_name ename in if ename = pure_effect_qn then E_PURE else if ename = pure_hoare_effect_qn then E_Pure else if ename = stack_effect_qn then E_Stack else if ename = st_effect_qn then E_ST else E_Unknown val effect_type_is_pure : effect_type -> Tot bool let effect_type_is_pure etype = match etype with | E_Total | E_GTotal | E_Lemma | E_PURE | E_Pure -> true | E_Stack | E_ST | E_Unknown -> false /// Type information noeq type type_info = { ty : typ; (* the type without refinement *) refin : option term; } let mk_type_info = Mktype_info val type_info_to_string : type_info -> Tac string let type_info_to_string info = "Mktype_info (" ^ term_to_string info.ty ^ ") (" ^ option_to_string term_to_string info.refin ^ ")" let unit_type_info = mk_type_info (`unit) None val safe_tc (e:env) (t:term) : Tac (option term) let safe_tc e t = try Some (tc e t) with | _ -> None val safe_tcc (e:env) (t:term) : Tac (option comp) let safe_tcc e t = try Some (tcc e t) with | _ -> None let get_type_info_from_type (ty:typ) : Tac type_info = match inspect ty with | Tv_Refine bv sort refin -> let raw_type = prettify_term false sort in let b : binder = mk_binder bv sort in let refin = prettify_term false refin in let refin = pack (Tv_Abs b refin) in mk_type_info raw_type (Some refin) | _ -> let ty = prettify_term false ty in mk_type_info ty None #push-options "--ifuel 1" let get_type_info (e:env) (t:term) : Tac (option type_info) = match safe_tc e t with | None -> None | Some ty -> Some (get_type_info_from_type ty) #pop-options val get_total_or_gtotal_ret_type : comp -> Tot (option typ) let get_total_or_gtotal_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty -> Some ret_ty | _ -> None val get_comp_ret_type : comp -> Tot typ let get_comp_ret_type c = match inspect_comp c with | C_Total ret_ty | C_GTotal ret_ty | C_Eff _ _ ret_ty _ _ -> ret_ty | C_Lemma _ _ _ -> (`unit) val is_total_or_gtotal : comp -> Tot bool let is_total_or_gtotal c = Some? (get_total_or_gtotal_ret_type c) val is_unit_type : typ -> Tac bool let is_unit_type ty = match inspect ty with | Tv_FVar fv -> fv_eq_name fv Reflection.Const.unit_lid | _ -> false (**** typ_or_comp *) /// This type is used to store typing information. /// We use it mostly to track what the target type/computation is for a term, /// while exploring this term. It is especially useful to generate post-conditions, /// for example. We store the list of abstractions encountered so far at the /// same time. /// Note that in order to keep track of the type correctly, whenever we encounter /// an abstraction in the term, we need to check that the term' type is an arrow, /// in which case we need to do a substitution (the arrow takes as first parameter /// which is not the same as the abstraction's binder). As the substitution is costly /// (we do it by using the normalizer, but the "final" return term is the whole /// function's body type, which is often super big) we do it lazily: we count how /// many parameters we have encountered and not substituted, and "flush" when we /// really need to inspect the typ_or_comp. // TODO: actually we only need to carry a comp (if typ: consider it total) (* TODO: remove the instantiation: instantiate incrementally *) noeq type typ_or_comp = | TC_Typ : v:typ -> pl:list binder -> num_unflushed:nat -> typ_or_comp | TC_Comp : v:comp -> pl:list binder -> num_unflushed:nat -> typ_or_comp let typ_or_comp_to_string (tyc : typ_or_comp) : Tac string = match tyc with | TC_Typ v pl num_unflushed -> "TC_Typ (" ^ term_to_string v ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed | TC_Comp c pl num_unflushed -> "TC_Comp (" ^ acomp_to_string c ^ ") " ^ list_to_string (fun b -> name_of_binder b) pl ^ " " ^ string_of_int num_unflushed /// Return the list of parameters stored in a ``typ_or_comp`` let params_of_typ_or_comp (c : typ_or_comp) : list binder = match c with | TC_Typ _ pl _ | TC_Comp _ pl _ -> pl let num_unflushed_of_typ_or_comp (c : typ_or_comp) : nat = match c with | TC_Typ _ _ n | TC_Comp _ _ n -> n /// Compute a ``typ_or_comp`` from the type of a term // TODO: try to get a more precise comp val safe_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Comp? (Some?.v opt)}) let safe_typ_or_comp dbg e t = match safe_tcc e t with | None -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: None"); None | Some c -> print_dbg dbg ("[> safe_typ_or_comp:" ^ "\n-term: " ^ term_to_string t ^ "\n-comp: " ^ acomp_to_string c); Some (TC_Comp c [] 0) val subst_bv_in_comp : env -> bv -> typ -> term -> comp -> Tac comp let subst_bv_in_comp e b sort t c = apply_subst_in_comp e c [((b, sort), t)] val subst_binder_in_comp : env -> binder -> term -> comp -> Tac comp let subst_binder_in_comp e b t c = subst_bv_in_comp e (bv_of_binder b) (binder_sort b) t c /// Utility for computations: unfold a type until it is of the form Tv_Arrow _ _, /// fail otherwise val unfold_until_arrow : env -> typ -> Tac typ let rec unfold_until_arrow e ty0 = if Tv_Arrow? (inspect ty0) then ty0 else begin (* Start by normalizing the term - note that this operation is expensive *) let ty = norm_term_env e [] ty0 in (* Helper to unfold top-level identifiers *) let unfold_fv (fv : fv) : Tac term = let ty = pack (Tv_FVar fv) in let fvn = flatten_name (inspect_fv fv) in (* unfold the top level binding, check that it has changed, and recurse *) let ty' = norm_term_env e [delta_only [fvn]] ty in (* I'm not confident about using eq_term here *) begin match inspect ty' with | Tv_FVar fv' -> if flatten_name (inspect_fv fv') = fvn then mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) else ty' | _ -> ty' end in (* Inspect *) match inspect ty with | Tv_Arrow _ _ -> ty | Tv_FVar fv -> (* Try to unfold the top-level identifier and recurse *) let ty' = unfold_fv fv in unfold_until_arrow e ty' | Tv_App _ _ -> (* Strip all the parameters, try to unfold the head and recurse *) let hd, args = collect_app ty in begin match inspect hd with | Tv_FVar fv -> let hd' = unfold_fv fv in let ty' = mk_app hd' args in unfold_until_arrow e ty' | _ -> mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end | Tv_Refine bv sort ref -> unfold_until_arrow e sort | Tv_AscribedT body _ _ _ | Tv_AscribedC body _ _ _ -> unfold_until_arrow e body | _ -> (* Other situations: don't know what to do *) mfail ("unfold_until_arrow: could not unfold: " ^ term_to_string ty0) end /// Instantiate a comp val inst_comp_once : env -> comp -> term -> Tac comp let inst_comp_once e c t = let ty = get_comp_ret_type c in let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> subst_binder_in_comp e b1 t c1 | _ -> (* Inconsistent state *) mfail "inst_comp_once: inconsistent state" end val inst_comp : env -> comp -> list term -> Tac comp let rec inst_comp e c tl = match tl with | [] -> c | t :: tl' -> let c' = try inst_comp_once e c t with | MetaAnalysis msg -> mfail ("inst_comp: error: " ^ msg) | err -> raise err in inst_comp e c' tl' /// Update the current ``typ_or_comp`` before going into the body of an abstraction. /// Explanations: /// In the case we dive into a term of the form: /// [> (fun x -> body) : y:ty -> body_type /// we need to substitute y with x in body_type to get the proper type for body. /// Note that we checked, and in practice the binders are indeed different. // TODO: actually, we updated it to do a lazy instantiation val abs_update_typ_or_comp : binder -> typ_or_comp -> env -> Tac typ_or_comp let _abs_update_typ (b:binder) (ty:typ) (pl:list binder) (e:env) : Tac typ_or_comp = (* Try to reveal an arrow *) try let ty' = unfold_until_arrow e ty in begin match inspect ty' with | Tv_Arrow b1 c1 -> let c1' = subst_binder_in_comp e b1 (pack (Tv_Var (bv_of_binder b))) c1 in TC_Comp c1' (b :: pl) 0 | _ -> (* Inconsistent state *) mfail "_abs_update_typ: inconsistent state" end with | MetaAnalysis msg -> mfail ("_abs_update_typ: could not find an arrow in: " ^ term_to_string ty ^ ":\n" ^ msg) | err -> raise err let abs_update_typ_or_comp (b:binder) (c : typ_or_comp) (e:env) : Tac typ_or_comp = match c with (*| TC_Typ v pl n -> _abs_update_typ b v pl e | TC_Comp v pl n -> (* Note that the computation is not necessarily pure, in which case we might * want to do something with the effect arguments (pre, post...) - for * now we just ignore them *) let ty = get_comp_ret_type v in _abs_update_typ b ty pl e *) | TC_Typ v pl n -> TC_Typ v (b::pl) (n+1) | TC_Comp v pl n -> TC_Comp v (b::pl) (n+1) val abs_update_opt_typ_or_comp : binder -> option typ_or_comp -> env -> Tac (option typ_or_comp) let abs_update_opt_typ_or_comp b opt_c e = match opt_c with | None -> None | Some c -> try let c = abs_update_typ_or_comp b c e in Some c with | MetaAnalysis msg -> None | err -> raise err /// Flush the instantiation stored in a ``typ_or_comp`` val flush_typ_or_comp : bool -> env -> typ_or_comp -> Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) /// Strip all the arrows we can without doing any instantiation. When we can't /// strip arrows anymore, do the instantiation at once. /// We keep track of two list of binders: /// - the remaining binders /// - the instantiation corresponding to the arrows we have stripped so far, and /// which will be applied all at once let rec _flush_typ_or_comp_comp (dbg : bool) (e:env) (rem : list binder) (inst : list ((bv & typ) & term)) (c:comp) : Tac comp = let flush c inst = let inst = List.rev inst in apply_subst_in_comp e c inst in match rem with | [] -> (* No more binders: flush *) flush c inst | b :: rem' -> (* Check if the return type is an arrow, if not flush and normalize *) let ty = get_comp_ret_type c in let ty, inst' = if Tv_Arrow? (inspect ty) then ty, inst else get_comp_ret_type (flush c inst), [] in match inspect ty with | Tv_Arrow b' c' -> _flush_typ_or_comp_comp dbg e rem' (((bv_of_binder b', binder_sort b'), pack (Tv_Var (bv_of_binder b)))::inst) c' | _ -> mfail ("_flush_typ_or_comp: inconsistent state" ^ "\n-comp: " ^ acomp_to_string c ^ "\n-remaning binders: " ^ list_to_string (fun b -> name_of_binder b) rem) let flush_typ_or_comp dbg e tyc = let flush_comp pl n c : Tac (tyc:typ_or_comp{num_unflushed_of_typ_or_comp tyc = 0}) = let pl', _ = List.Tot.splitAt n pl in let pl' = List.rev pl' in let c = _flush_typ_or_comp_comp dbg e pl' [] c in TC_Comp c pl 0 in try begin match tyc with | TC_Typ ty pl n -> let c = pack_comp (C_Total ty) in flush_comp pl n c | TC_Comp c pl n -> flush_comp pl n c end with | MetaAnalysis msg -> mfail ("flush_typ_or_comp failed on: " ^ typ_or_comp_to_string tyc ^ ":\n" ^ msg) | err -> raise err /// Compute the target ``typ_or_comp`` for an argument by the type of the head: /// in `hd a`, if `hd` has type `t -> ...`, use `t` val safe_arg_typ_or_comp : bool -> env -> term -> Tac (opt:option typ_or_comp{Some? opt ==> TC_Typ? (Some?.v opt)}) let safe_arg_typ_or_comp dbg e hd = print_dbg dbg ("safe_arg_typ_or_comp: " ^ term_to_string hd); match safe_tc e hd with | None -> None | Some ty -> print_dbg dbg ("hd type: " ^ term_to_string ty); let ty = if Tv_Arrow? (inspect ty) then begin print_dbg dbg "no need to unfold the type"; ty end else begin print_dbg dbg "need to unfold the type"; let ty = unfold_until_arrow e ty in print_dbg dbg ("result of unfolding : "^ term_to_string ty); ty end in match inspect ty with | Tv_Arrow b c -> Some (TC_Typ (type_of_binder b) [] 0) | _ -> None /// Exploring a term (*** Term exploration *) /// Explore a term, correctly updating the environment when traversing abstractions let convert_ctrl_flag (flag : ctrl_flag) = match flag with | Continue -> Continue | Skip -> Continue | Abort -> Abort /// TODO: for now I need to use universe 0 for type a because otherwise it doesn't /// type check /// ctrl_flag: /// - Continue: continue exploring the term /// - Skip: don't explore the sub-terms of this term /// - Abort: stop exploration /// TODO: we might want a more precise control (like: don't explore the type of the /// ascription but explore its body) /// Note that ``explore_term`` doesn't use the environment parameter besides pushing /// binders and passing it to ``f``, which means that you can give it arbitrary /// environments, ``explore_term`` itself won't fail (but the passed function might). let explorer (a : Type) = a -> genv -> list (genv & term_view) -> option typ_or_comp -> term_view -> Tac (a & ctrl_flag) // TODO: use more let bind_expl (#a : Type) (x : a) (f1 f2 : a -> Tac (a & ctrl_flag)) : Tac (a & ctrl_flag) = let x1, flag1 = f1 x in if flag1 = Continue then f2 x1 else x1, convert_ctrl_flag flag1 // TODO: change the signature to move the dbg flag val explore_term : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge : genv (* the list of terms traversed so far (first is most recent) with the environment * at the time they were traversed *) -> parents : list (genv & term_view) -> c : option typ_or_comp -> t:term -> Tac (a & ctrl_flag) val explore_pattern : dbg : bool -> dfs : bool (* depth-first search *) -> #a : Type0 -> f : explorer a -> x : a -> ge:genv -> pat:pattern -> Tac (genv & a & ctrl_flag)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Const.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.InteractiveHelpers.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.InteractiveHelpers.ExploreTerm.fst" }
[ { "abbrev": false, "full_module": "FStar.InteractiveHelpers.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.List", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.InteractiveHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 15, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dbg: Prims.bool -> dfs: Prims.bool -> f: FStar.InteractiveHelpers.ExploreTerm.explorer a -> x: a -> ge: FStar.InteractiveHelpers.Base.genv -> pat: FStar.Stubs.Reflection.V1.Data.pattern -> FStar.Tactics.Effect.Tac ((FStar.InteractiveHelpers.Base.genv * a) * FStar.Stubs.Tactics.Types.ctrl_flag)
FStar.Tactics.Effect.Tac
[]
[ "explore_term", "explore_pattern" ]
[ "Prims.bool", "FStar.InteractiveHelpers.ExploreTerm.explorer", "FStar.InteractiveHelpers.Base.genv", "FStar.Stubs.Reflection.V1.Data.pattern", "FStar.Stubs.Reflection.V1.Data.vconst", "FStar.Pervasives.Native.Mktuple3", "FStar.Stubs.Tactics.Types.ctrl_flag", "FStar.Stubs.Tactics.Types.Continue", "FStar.Pervasives.Native.tuple3", "FStar.Stubs.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V1.Data.universes", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.Util.fold_left", "Prims.op_Equality", "FStar.InteractiveHelpers.ExploreTerm.explore_pattern", "FStar.Stubs.Reflection.Types.bv", "FStar.Sealed.sealed", "FStar.Stubs.Reflection.Types.typ", "FStar.InteractiveHelpers.Base.genv_push_bv", "FStar.Pervasives.Native.None", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.Unseal.unseal", "Prims.unit", "FStar.InteractiveHelpers.Base.print_dbg" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec explore_pattern dbg dfs #a f x ge0 pat =
print_dbg dbg ("[> explore_pattern:"); match pat with | Pat_Constant _ -> ge0, x, Continue | Pat_Cons fv us patterns -> let explore_pat ge_x_flag pat = let ge0, x, flag = ge_x_flag in let pat1, _ = pat in if flag = Continue then explore_pattern dbg dfs #a f x ge0 pat1 else ge0, x, flag in fold_left explore_pat (ge0, x, Continue) patterns | Pat_Var bv st -> let ge1 = genv_push_bv ge0 bv (unseal st) false None in ge1, x, Continue | Pat_Dot_Term _ -> ge0, x, Continue
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_int_at_most
val va_int_at_most : k: Prims.int -> Type0
let va_int_at_most (k:int) = i:int{i <= k}
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 52, "start_col": 0, "start_line": 52 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Prims.int -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let va_int_at_most (k: int) =
i: int{i <= k}
false
Hacl.Impl.BignumQ.Mul.fst
Hacl.Impl.BignumQ.Mul.barrett_reduction
val barrett_reduction: z:qelemB -> t:qelem_wide -> Stack unit (requires fun h -> live h z /\ live h t /\ qelem_wide_fits h t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat h t < pow2 512) (ensures fun h0 _ h1 -> modifies (loc z) h0 h1 /\ qelem_fits h1 z (1, 1, 1, 1, 1) /\ as_nat h1 z == wide_as_nat h0 t % S.q)
val barrett_reduction: z:qelemB -> t:qelem_wide -> Stack unit (requires fun h -> live h z /\ live h t /\ qelem_wide_fits h t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat h t < pow2 512) (ensures fun h0 _ h1 -> modifies (loc z) h0 h1 /\ qelem_fits h1 z (1, 1, 1, 1, 1) /\ as_nat h1 z == wide_as_nat h0 t % S.q)
let barrett_reduction z t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = (t.(0ul), t.(1ul), t.(2ul), t.(3ul), t.(4ul), t.(5ul), t.(6ul), t.(7ul), t.(8ul), t.(9ul)) in let (z0, z1, z2, z3, z4)= barrett_reduction5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in z.(0ul) <- z0; z.(1ul) <- z1; z.(2ul) <- z2; z.(3ul) <- z3; z.(4ul) <- z4
{ "file_name": "code/ed25519/Hacl.Impl.BignumQ.Mul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 23, "start_col": 0, "start_line": 15 }
module Hacl.Impl.BignumQ.Mul module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer include Hacl.Spec.BignumQ.Mul #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.BignumQ.Mul.fst.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.BignumQ.Mul.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
z: Hacl.Impl.BignumQ.Mul.qelemB -> t: Hacl.Impl.BignumQ.Mul.qelem_wide -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.BignumQ.Mul.qelemB", "Hacl.Impl.BignumQ.Mul.qelem_wide", "Lib.IntTypes.uint64", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t", "Prims.unit", "Hacl.Spec.BignumQ.Definitions.qelem5", "Hacl.Spec.BignumQ.Mul.barrett_reduction5", "FStar.Pervasives.Native.Mktuple10", "FStar.Pervasives.Native.tuple10", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT" ]
[]
false
true
false
false
false
let barrett_reduction z t =
let t0, t1, t2, t3, t4, t5, t6, t7, t8, t9 = (t.(0ul), t.(1ul), t.(2ul), t.(3ul), t.(4ul), t.(5ul), t.(6ul), t.(7ul), t.(8ul), t.(9ul)) in let z0, z1, z2, z3, z4 = barrett_reduction5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in z.(0ul) <- z0; z.(1ul) <- z1; z.(2ul) <- z2; z.(3ul) <- z3; z.(4ul) <- z4
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_update
val va_update : _: FStar.Map.t _ _ -> _: _ -> _: _ -> FStar.Map.t _ _
let va_update = Map.upd
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 37, "start_col": 7, "start_line": 37 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: FStar.Map.t _ _ -> _: _ -> _: _ -> FStar.Map.t _ _
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.Map.upd", "FStar.Map.t" ]
[]
false
false
false
false
false
let va_update =
Map.upd
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_int_range
val va_int_range : k1: Prims.int -> k2: Prims.int -> Type0
let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2}
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 53, "start_col": 0, "start_line": 53 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k}
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k1: Prims.int -> k2: Prims.int -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let va_int_range (k1 k2: int) =
i: int{k1 <= i /\ i <= k2}
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_codes
val va_codes : Type0
let va_codes = list va_code
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 57, "start_col": 7, "start_line": 57 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.PPC64LE.Decls.va_code" ]
[]
false
false
false
true
true
let va_codes =
list va_code
false
Vale.PPC64LE.Decls.fsti
Vale.PPC64LE.Decls.va_operand_Mem64
val va_operand_Mem64 : Type0
let va_operand_Mem64 = maddr
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Decls.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 63, "start_col": 7, "start_line": 63 }
module Vale.PPC64LE.Decls // This interface should hide all of Semantics_s. // (It should not refer to Semantics_s, directly or indirectly.) // It should not refer to StateLemmas_i or Print_s, // because they refer to Semantics_s. // Regs_i and State_i are ok, because they do not refer to Semantics_s. open FStar.Mul open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.Arch.HeapTypes_s open Vale.Arch.HeapImpl open Vale.Arch.Heap module M = Vale.PPC64LE.Memory module SI = Vale.PPC64LE.Stack_i module Map16 = Vale.Lib.Map16 module VSS = Vale.PPC64LE.Stack_Sems val same_heap_types : squash (vale_full_heap == heap_impl) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x unfold let from_heap_impl (heap:heap_impl) : vale_full_heap = coerce heap unfold let vale_heap = M.vale_heap unfold let vale_full_heap = M.vale_full_heap unfold let heaplet_id = M.heaplet_id val xer_ov (xer:xer_t) : bool val xer_ca (xer:xer_t) : bool val update_xer_ov (xer:xer_t) (new_xer_ov:bool) : xer_t val update_xer_ca (xer:xer_t) (new_xer_ca:bool) : xer_t //unfold let va_subscript = Map.sel unfold let va_subscript (#a:eqtype) (#b:Type) (x:Map.t a b) (y:a) : Tot b = Map.sel x y unfold let va_update = Map.upd unfold let va_hd = Cons?.hd //unfold let va_tl = Cons?.tl // F* inlines "let ... = va_tl ..." more than we'd like; revised definition below suppresses this // REVIEW: FStar.Pervasives.reveal_opaque doesn't include zeta, so it fails for recursive functions // REVIEW: why is x' necessary to keep x from being normalized? [@va_qattr] unfold let va_reveal_eq (#ax:Type) (s:string) (x x':ax) = norm [zeta; delta_only [s]] #ax x == x' let va_reveal_opaque (s:string) = norm_spec [zeta; delta_only [s]] // hide 'if' so that x and y get fully normalized let va_if (#a:Type) (b:bool) (x:(_:unit{b}) -> a) (y:(_:unit{~b}) -> a) : a = if b then x () else y () // Type aliases let va_int_at_least (k:int) = i:int{i >= k} let va_int_at_most (k:int) = i:int{i <= k} let va_int_range (k1 k2:int) = i:int{k1 <= i /\ i <= k2} val ins : Type0 val ocmp : Type0 unfold let va_code = precode ins ocmp unfold let va_codes = list va_code let va_tl (cs:va_codes) : Ghost va_codes (requires Cons? cs) (ensures fun tl -> tl == Cons?.tl cs) = Cons?.tl cs unfold let va_state = state val va_fuel : Type0 unfold let reg_opr = reg
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_Sems.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Decls.fsti" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_Sems", "short_module": "VSS" }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Stack_i", "short_module": "SI" }, { "abbrev": true, "full_module": "Vale.PPC64LE.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Machine_s.maddr" ]
[]
false
false
false
true
true
let va_operand_Mem64 =
maddr
false