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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Vale.Def.Types_s.fst | Vale.Def.Types_s.le_seq_quad32_to_bytes_length | val le_seq_quad32_to_bytes_length (s: seq quad32)
: Lemma (ensures length (le_seq_quad32_to_bytes s) == 16 * (length s))
[SMTPat (length (le_seq_quad32_to_bytes s))] | val le_seq_quad32_to_bytes_length (s: seq quad32)
: Lemma (ensures length (le_seq_quad32_to_bytes s) == 16 * (length s))
[SMTPat (length (le_seq_quad32_to_bytes s))] | let le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma
(ensures length (le_seq_quad32_to_bytes s) == 16 * (length s))
[SMTPat (length (le_seq_quad32_to_bytes s))]
=
le_seq_quad32_to_bytes_reveal () | {
"file_name": "vale/specs/defs/Vale.Def.Types_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 107,
"start_col": 0,
"start_line": 103
} | module Vale.Def.Types_s
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Lib.Seqs_s
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
unfold let nat64 = Vale.Def.Words_s.nat64
let add_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x + y < n then x + y else x + y - n
let sub_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x - y >= 0 then x - y else x - y + n
// abstract bitwise operations on integers:
assume val iand : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ixor : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ior : #n:nat -> a:natN n -> b:natN n -> natN n
assume val inot : #n:nat -> a:natN n -> natN n
assume val ishl : #n:nat -> a:natN n -> s:int -> natN n
assume val ishr : #n:nat -> a:natN n -> s:int -> natN n
// Alias
unfold let nat32_xor (x y:nat32) : nat32 = ixor x y
type twobits:eqtype = natN 4
type bits_of_byte:eqtype = four twobits
let byte_to_twobits (b:nat8) : bits_of_byte = nat_to_four_unfold 2 b
type double32:eqtype = two nat32
type quad32:eqtype = four nat32
let quad32_xor_def (x y:quad32) : quad32 = four_map2 nat32_xor x y
[@"opaque_to_smt"] let quad32_xor = opaque_make quad32_xor_def
irreducible let quad32_xor_reveal = opaque_revealer (`%quad32_xor) quad32_xor quad32_xor_def
let select_word (q:quad32) (selector:twobits) : nat32 = four_select q selector
let insert_nat32 (q:quad32) (n:nat32) (i:twobits) : quad32 = four_insert q n i
let insert_nat64_def (q:quad32) (n:nat64) (i:nat1) : quad32 =
two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 n) i)
[@"opaque_to_smt"] let insert_nat64 = opaque_make insert_nat64_def
irreducible let insert_nat64_reveal = opaque_revealer (`%insert_nat64) insert_nat64 insert_nat64_def
open FStar.Seq
let le_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_LE b)
let nat32_to_le_bytes (n:nat32) : b:seq4 nat8 {
le_bytes_to_nat32 b == n} =
let b = four_to_seq_LE (nat_to_four 8 n) in
assume (le_bytes_to_nat32 b == n);
b
let be_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_BE b)
let nat32_to_be_bytes (n:nat32) : b:seq4 nat8 { be_bytes_to_nat32 b == n } =
let b = four_to_seq_BE (nat_to_four 8 n) in
assume (be_bytes_to_nat32 b == n);
b
assume val be_bytes_to_nat32_to_be_bytes (b:seq4 nat8) :
Lemma (nat32_to_be_bytes (be_bytes_to_nat32 b) == b)
let le_bytes_to_nat64_def (b:seq nat8) : Pure nat64 (requires length b == 8) (ensures fun _ -> True) =
two_to_nat 32 (seq_to_two_LE (seq_nat8_to_seq_nat32_LE b))
[@"opaque_to_smt"] let le_bytes_to_nat64 = opaque_make le_bytes_to_nat64_def
irreducible let le_bytes_to_nat64_reveal = opaque_revealer (`%le_bytes_to_nat64) le_bytes_to_nat64 le_bytes_to_nat64_def
let le_nat64_to_bytes_def (b:nat64) : Pure (seq nat8) (requires True) (ensures fun s -> length s == 8) =
seq_nat32_to_seq_nat8_LE (two_to_seq_LE (nat_to_two 32 b))
[@"opaque_to_smt"] let le_nat64_to_bytes = opaque_make le_nat64_to_bytes_def
irreducible let le_nat64_to_bytes_reveal = opaque_revealer (`%le_nat64_to_bytes) le_nat64_to_bytes le_nat64_to_bytes_def
let le_bytes_to_quad32_def (b:seq nat8) : Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b))
[@"opaque_to_smt"] let le_bytes_to_quad32 = opaque_make le_bytes_to_quad32_def
irreducible let le_bytes_to_quad32_reveal = opaque_revealer (`%le_bytes_to_quad32) le_bytes_to_quad32 le_bytes_to_quad32_def
let be_bytes_to_quad32_def (b:seq nat8) : Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b))
[@"opaque_to_smt"] let be_bytes_to_quad32 = opaque_make be_bytes_to_quad32_def
irreducible let be_bytes_to_quad32_reveal = opaque_revealer (`%be_bytes_to_quad32) be_bytes_to_quad32 be_bytes_to_quad32_def
[@"opaque_to_smt"]
let le_quad32_to_bytes (b:quad32) : Pure (seq nat8) (requires True) (ensures fun s -> length s == 16) =
seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))
let le_seq_quad32_to_bytes_def (b:seq quad32) : seq nat8 =
seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE b)
[@"opaque_to_smt"] let le_seq_quad32_to_bytes = opaque_make le_seq_quad32_to_bytes_def
irreducible let le_seq_quad32_to_bytes_reveal = opaque_revealer (`%le_seq_quad32_to_bytes) le_seq_quad32_to_bytes le_seq_quad32_to_bytes_def | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Types_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"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: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.length (Vale.Def.Types_s.le_seq_quad32_to_bytes s) ==
16 * FStar.Seq.Base.length s)
[SMTPat (FStar.Seq.Base.length (Vale.Def.Types_s.le_seq_quad32_to_bytes s))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Mul.op_Star",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.nat",
"Prims.Nil"
] | [] | true | false | true | false | false | let le_seq_quad32_to_bytes_length (s: seq quad32)
: Lemma (ensures length (le_seq_quad32_to_bytes s) == 16 * (length s))
[SMTPat (length (le_seq_quad32_to_bytes s))] =
| le_seq_quad32_to_bytes_reveal () | false |
Vale.Def.Types_s.fst | Vale.Def.Types_s.le_bytes_to_quad32_def | val le_bytes_to_quad32_def (b: seq nat8)
: Pure quad32 (requires length b == 16) (ensures fun _ -> True) | val le_bytes_to_quad32_def (b: seq nat8)
: Pure quad32 (requires length b == 16) (ensures fun _ -> True) | let le_bytes_to_quad32_def (b:seq nat8) : Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) | {
"file_name": "vale/specs/defs/Vale.Def.Types_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 85,
"start_col": 0,
"start_line": 84
} | module Vale.Def.Types_s
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Lib.Seqs_s
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
unfold let nat64 = Vale.Def.Words_s.nat64
let add_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x + y < n then x + y else x + y - n
let sub_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x - y >= 0 then x - y else x - y + n
// abstract bitwise operations on integers:
assume val iand : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ixor : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ior : #n:nat -> a:natN n -> b:natN n -> natN n
assume val inot : #n:nat -> a:natN n -> natN n
assume val ishl : #n:nat -> a:natN n -> s:int -> natN n
assume val ishr : #n:nat -> a:natN n -> s:int -> natN n
// Alias
unfold let nat32_xor (x y:nat32) : nat32 = ixor x y
type twobits:eqtype = natN 4
type bits_of_byte:eqtype = four twobits
let byte_to_twobits (b:nat8) : bits_of_byte = nat_to_four_unfold 2 b
type double32:eqtype = two nat32
type quad32:eqtype = four nat32
let quad32_xor_def (x y:quad32) : quad32 = four_map2 nat32_xor x y
[@"opaque_to_smt"] let quad32_xor = opaque_make quad32_xor_def
irreducible let quad32_xor_reveal = opaque_revealer (`%quad32_xor) quad32_xor quad32_xor_def
let select_word (q:quad32) (selector:twobits) : nat32 = four_select q selector
let insert_nat32 (q:quad32) (n:nat32) (i:twobits) : quad32 = four_insert q n i
let insert_nat64_def (q:quad32) (n:nat64) (i:nat1) : quad32 =
two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 n) i)
[@"opaque_to_smt"] let insert_nat64 = opaque_make insert_nat64_def
irreducible let insert_nat64_reveal = opaque_revealer (`%insert_nat64) insert_nat64 insert_nat64_def
open FStar.Seq
let le_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_LE b)
let nat32_to_le_bytes (n:nat32) : b:seq4 nat8 {
le_bytes_to_nat32 b == n} =
let b = four_to_seq_LE (nat_to_four 8 n) in
assume (le_bytes_to_nat32 b == n);
b
let be_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_BE b)
let nat32_to_be_bytes (n:nat32) : b:seq4 nat8 { be_bytes_to_nat32 b == n } =
let b = four_to_seq_BE (nat_to_four 8 n) in
assume (be_bytes_to_nat32 b == n);
b
assume val be_bytes_to_nat32_to_be_bytes (b:seq4 nat8) :
Lemma (nat32_to_be_bytes (be_bytes_to_nat32 b) == b)
let le_bytes_to_nat64_def (b:seq nat8) : Pure nat64 (requires length b == 8) (ensures fun _ -> True) =
two_to_nat 32 (seq_to_two_LE (seq_nat8_to_seq_nat32_LE b))
[@"opaque_to_smt"] let le_bytes_to_nat64 = opaque_make le_bytes_to_nat64_def
irreducible let le_bytes_to_nat64_reveal = opaque_revealer (`%le_bytes_to_nat64) le_bytes_to_nat64 le_bytes_to_nat64_def
let le_nat64_to_bytes_def (b:nat64) : Pure (seq nat8) (requires True) (ensures fun s -> length s == 8) =
seq_nat32_to_seq_nat8_LE (two_to_seq_LE (nat_to_two 32 b))
[@"opaque_to_smt"] let le_nat64_to_bytes = opaque_make le_nat64_to_bytes_def
irreducible let le_nat64_to_bytes_reveal = opaque_revealer (`%le_nat64_to_bytes) le_nat64_to_bytes le_nat64_to_bytes_def | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Types_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"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 | b: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure Vale.Def.Types_s.quad32 | Prims.Pure | [] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.Def.Words.Seq_s.seq_to_four_LE",
"Vale.Def.Types_s.nat32",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Words_s.four",
"Vale.Def.Words.Four_s.four_to_nat",
"Vale.Def.Words.Seq_s.seq_to_seq_four_LE",
"Vale.Def.Types_s.quad32",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.l_True"
] | [] | false | false | false | false | false | let le_bytes_to_quad32_def (b: seq nat8)
: Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
| seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) | false |
Simplifier.fst | Simplifier.goal_is_true | val goal_is_true: Prims.unit -> Tac unit | val goal_is_true: Prims.unit -> Tac unit | let goal_is_true () : Tac unit =
let g = cur_goal () in
match term_as_formula g with
| True_ -> trivial ()
| r ->
dump ("not syntactically true " ^ term_to_string (quote r));
fail ("not syntactically true " ^ term_to_string (quote r)) | {
"file_name": "examples/tactics/Simplifier.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 65,
"end_line": 27,
"start_col": 0,
"start_line": 21
} | (*
Copyright 2008-2018 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 Simplifier
open FStar.Tactics.V2
open FStar.Tactics.Simplifier | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Simplifier.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Simplifier.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Simplifier",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"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 | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.unit",
"FStar.Tactics.V2.Derived.trivial",
"FStar.Reflection.V2.Formula.formula",
"FStar.Tactics.V2.Derived.fail",
"Prims.string",
"Prims.op_Hat",
"FStar.Stubs.Tactics.V2.Builtins.term_to_string",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Tactics.V2.Builtins.dump",
"FStar.Reflection.V2.Formula.term_as_formula",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Tactics.V2.Derived.cur_goal"
] | [] | false | true | false | false | false | let goal_is_true () : Tac unit =
| let g = cur_goal () in
match term_as_formula g with
| True_ -> trivial ()
| r ->
dump ("not syntactically true " ^ term_to_string (quote r));
fail ("not syntactically true " ^ term_to_string (quote r)) | false |
Vale.Def.Types_s.fst | Vale.Def.Types_s.reverse_bytes_nat32_def | val reverse_bytes_nat32_def (n: nat32) : nat32 | val reverse_bytes_nat32_def (n: nat32) : nat32 | let reverse_bytes_nat32_def (n:nat32) : nat32 =
be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes n)) | {
"file_name": "vale/specs/defs/Vale.Def.Types_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 118,
"start_col": 0,
"start_line": 117
} | module Vale.Def.Types_s
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Lib.Seqs_s
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
unfold let nat64 = Vale.Def.Words_s.nat64
let add_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x + y < n then x + y else x + y - n
let sub_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x - y >= 0 then x - y else x - y + n
// abstract bitwise operations on integers:
assume val iand : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ixor : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ior : #n:nat -> a:natN n -> b:natN n -> natN n
assume val inot : #n:nat -> a:natN n -> natN n
assume val ishl : #n:nat -> a:natN n -> s:int -> natN n
assume val ishr : #n:nat -> a:natN n -> s:int -> natN n
// Alias
unfold let nat32_xor (x y:nat32) : nat32 = ixor x y
type twobits:eqtype = natN 4
type bits_of_byte:eqtype = four twobits
let byte_to_twobits (b:nat8) : bits_of_byte = nat_to_four_unfold 2 b
type double32:eqtype = two nat32
type quad32:eqtype = four nat32
let quad32_xor_def (x y:quad32) : quad32 = four_map2 nat32_xor x y
[@"opaque_to_smt"] let quad32_xor = opaque_make quad32_xor_def
irreducible let quad32_xor_reveal = opaque_revealer (`%quad32_xor) quad32_xor quad32_xor_def
let select_word (q:quad32) (selector:twobits) : nat32 = four_select q selector
let insert_nat32 (q:quad32) (n:nat32) (i:twobits) : quad32 = four_insert q n i
let insert_nat64_def (q:quad32) (n:nat64) (i:nat1) : quad32 =
two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 n) i)
[@"opaque_to_smt"] let insert_nat64 = opaque_make insert_nat64_def
irreducible let insert_nat64_reveal = opaque_revealer (`%insert_nat64) insert_nat64 insert_nat64_def
open FStar.Seq
let le_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_LE b)
let nat32_to_le_bytes (n:nat32) : b:seq4 nat8 {
le_bytes_to_nat32 b == n} =
let b = four_to_seq_LE (nat_to_four 8 n) in
assume (le_bytes_to_nat32 b == n);
b
let be_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_BE b)
let nat32_to_be_bytes (n:nat32) : b:seq4 nat8 { be_bytes_to_nat32 b == n } =
let b = four_to_seq_BE (nat_to_four 8 n) in
assume (be_bytes_to_nat32 b == n);
b
assume val be_bytes_to_nat32_to_be_bytes (b:seq4 nat8) :
Lemma (nat32_to_be_bytes (be_bytes_to_nat32 b) == b)
let le_bytes_to_nat64_def (b:seq nat8) : Pure nat64 (requires length b == 8) (ensures fun _ -> True) =
two_to_nat 32 (seq_to_two_LE (seq_nat8_to_seq_nat32_LE b))
[@"opaque_to_smt"] let le_bytes_to_nat64 = opaque_make le_bytes_to_nat64_def
irreducible let le_bytes_to_nat64_reveal = opaque_revealer (`%le_bytes_to_nat64) le_bytes_to_nat64 le_bytes_to_nat64_def
let le_nat64_to_bytes_def (b:nat64) : Pure (seq nat8) (requires True) (ensures fun s -> length s == 8) =
seq_nat32_to_seq_nat8_LE (two_to_seq_LE (nat_to_two 32 b))
[@"opaque_to_smt"] let le_nat64_to_bytes = opaque_make le_nat64_to_bytes_def
irreducible let le_nat64_to_bytes_reveal = opaque_revealer (`%le_nat64_to_bytes) le_nat64_to_bytes le_nat64_to_bytes_def
let le_bytes_to_quad32_def (b:seq nat8) : Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b))
[@"opaque_to_smt"] let le_bytes_to_quad32 = opaque_make le_bytes_to_quad32_def
irreducible let le_bytes_to_quad32_reveal = opaque_revealer (`%le_bytes_to_quad32) le_bytes_to_quad32 le_bytes_to_quad32_def
let be_bytes_to_quad32_def (b:seq nat8) : Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b))
[@"opaque_to_smt"] let be_bytes_to_quad32 = opaque_make be_bytes_to_quad32_def
irreducible let be_bytes_to_quad32_reveal = opaque_revealer (`%be_bytes_to_quad32) be_bytes_to_quad32 be_bytes_to_quad32_def
[@"opaque_to_smt"]
let le_quad32_to_bytes (b:quad32) : Pure (seq nat8) (requires True) (ensures fun s -> length s == 16) =
seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))
let le_seq_quad32_to_bytes_def (b:seq quad32) : seq nat8 =
seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE b)
[@"opaque_to_smt"] let le_seq_quad32_to_bytes = opaque_make le_seq_quad32_to_bytes_def
irreducible let le_seq_quad32_to_bytes_reveal = opaque_revealer (`%le_seq_quad32_to_bytes) le_seq_quad32_to_bytes le_seq_quad32_to_bytes_def
let le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma
(ensures length (le_seq_quad32_to_bytes s) == 16 * (length s))
[SMTPat (length (le_seq_quad32_to_bytes s))]
=
le_seq_quad32_to_bytes_reveal ()
[@"opaque_to_smt"]
let le_bytes_to_seq_quad32 (b:seq nat8) : Pure (seq quad32) (requires length b % 16 == 0) (ensures fun _ -> True) =
seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b)
[@"opaque_to_smt"]
let be_bytes_to_seq_quad32 (b:seq nat8) : Pure (seq quad32) (requires length b % 16 == 0) (ensures fun _ -> True) =
seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE b) | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Types_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"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 | n: Vale.Def.Types_s.nat32 -> Vale.Def.Types_s.nat32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.be_bytes_to_nat32",
"Vale.Lib.Seqs_s.reverse_seq",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.nat32_to_be_bytes"
] | [] | false | false | false | true | false | let reverse_bytes_nat32_def (n: nat32) : nat32 =
| be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes n)) | false |
Simplifier.fst | Simplifier.test_simplify | val test_simplify: Prims.unit -> Tac unit | val test_simplify: Prims.unit -> Tac unit | let test_simplify () : Tac unit =
simplify ();
or_else goal_is_true (fun () -> dump ""; fail "simplify left open goals") | {
"file_name": "examples/tactics/Simplifier.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 77,
"end_line": 31,
"start_col": 0,
"start_line": 29
} | (*
Copyright 2008-2018 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 Simplifier
open FStar.Tactics.V2
open FStar.Tactics.Simplifier
let goal_is_true () : Tac unit =
let g = cur_goal () in
match term_as_formula g with
| True_ -> trivial ()
| r ->
dump ("not syntactically true " ^ term_to_string (quote r));
fail ("not syntactically true " ^ term_to_string (quote r)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Simplifier.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Simplifier.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Simplifier",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"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 | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.unit",
"FStar.Tactics.V2.Derived.or_else",
"Simplifier.goal_is_true",
"FStar.Tactics.V2.Derived.fail",
"FStar.Stubs.Tactics.V2.Builtins.dump",
"FStar.Tactics.Simplifier.simplify"
] | [] | false | true | false | false | false | let test_simplify () : Tac unit =
| simplify ();
or_else goal_is_true
(fun () ->
dump "";
fail "simplify left open goals") | false |
Steel.Primitive.ForkJoin.Unix.fst | Steel.Primitive.ForkJoin.Unix.kfork | val kfork (#p #q: vprop) (f: (unit -> SteelK unit p (fun _ -> q)))
: SteelK (thread q) p (fun _ -> emp) | val kfork (#p #q: vprop) (f: (unit -> SteelK unit p (fun _ -> q)))
: SteelK (thread q) p (fun _ -> emp) | let kfork (#p:vprop) (#q:vprop) (f : unit -> SteelK unit p (fun _ -> q))
: SteelK (thread q) p (fun _ -> emp)
=
SteelK?.reflect (
fun (#frame:vprop) (#postf:vprop)
(k : (x:(thread q) -> SteelT unit (frame `star` emp) (fun _ -> postf))) ->
noop ();
let t1 () : SteelT unit (emp `star` p) (fun _ -> q) =
let r : steelK unit false p (fun _ -> q) = reify (f ()) in
r #emp #q (fun _ -> idk())
in
let t2 (t:thread q) () : SteelT unit frame (fun _ -> postf) = k t in
let ff () : SteelT unit (p `star` frame) (fun _ -> postf) =
fork #p #q #frame #postf t1 t2
in
ff()) | {
"file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 11,
"end_line": 205,
"start_col": 0,
"start_line": 190
} | (*
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.Primitive.ForkJoin.Unix
(* This module shows that it's possible to layer continuations on top
of SteelT to get a direct style (or Unix style) fork/join. Very much a
prototype for now. *)
open FStar.Ghost
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.Reference
open Steel.Primitive.ForkJoin
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
// (* Some helpers *)
let change_slprop_equiv (p q : vprop)
(proof : squash (p `equiv` q))
: SteelT unit p (fun _ -> q)
= rewrite_slprop p q (fun _ -> proof; reveal_equiv p q)
let change_slprop_imp (p q : vprop)
(proof : squash (p `can_be_split` q))
: SteelT unit p (fun _ -> q)
= rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ())
(* Continuations into unit, but parametrized by the final heap
* proposition and with an implicit framing. I think ideally these would
* also be parametric in the final type (instead of being hardcoded to
* unit) but that means fork needs to be extended to be polymorphic in
* at least one of the branches. *)
type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) =
#frame:vprop -> #postf:vprop ->
f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) ->
SteelT unit (frame `star` pre) (fun _ -> postf)
(* The classic continuation monad *)
let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p =
fun k -> k x
private
let rearrange3 (p q r:vprop) : Lemma
(((p `star` q) `star` r) `equiv` (p `star` (r `star` q)))
= let open FStar.Tactics in
assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by
(norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p))
private
let equiv_symmetric (p1 p2:vprop)
: Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1)
= reveal_equiv p1 p2;
equiv_symmetric (hp_of p1) (hp_of p2);
reveal_equiv p2 p1
private
let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a)
: Lemma (requires can_be_split_forall p q)
(ensures (frame `star` p x) `can_be_split` (frame `star` q x))
= let frame = hp_of frame in
let p = hp_of (p x) in
let q = hp_of (q x) in
reveal_can_be_split ();
assert (slimp p q);
slimp_star p q frame frame;
Steel.Memory.star_commutative p frame;
Steel.Memory.star_commutative q frame
let bind (a:Type) (b:Type)
(#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b)
(#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop)
(#[@@@ framing_implicit] p:squash (can_be_split_forall
(fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g)))
(#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g))
(f:steelK a framed_f pre_f post_f)
(g:(x:a -> steelK b framed_g (pre_g x) post_g))
: steelK b
true
(pre_f `star` frame_f)
(fun y -> post_g y `star` frame_g)
= fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) ->
// Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post)
change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f;
equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) );
f #(frame `star` frame_f) #post
((fun (x:a) ->
// Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post)
change_slprop_imp
(frame `star` (post_f x `star` frame_f))
(frame `star` (pre_g x `star` frame_g))
(can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x);
g x #(frame `star` frame_g) #post
((fun (y:b) -> k y)
<: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post)))
)
<: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post)))
let subcomp (a:Type)
(#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f))
(#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g))
(f:steelK a framed_f pre_f post_f)
: Tot (steelK a framed_g pre_g post_g)
= fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) ->
change_slprop_imp pre_g pre_f ();
f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x)
(can_be_split_forall_frame post_f post_g frame x);
k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf)))
// let if_then_else (a:Type u#aa)
// (#[@@@ framing_implicit] pre1:pre_t)
// (#[@@@ framing_implicit] post1:post_t a)
// (f : steelK a pre1 post1)
// (g : steelK a pre1 post1)
// (p:Type0) : Type =
// steelK a pre1 post1
// We did not define a bind between Div and Steel, so we indicate
// SteelKF as total to be able to reify and compose it when implementing fork
// This module is intended as proof of concept
total
reifiable
reflectable
layered_effect {
SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect
with
repr = steelK;
return = return_;
bind = bind;
subcomp = subcomp
// if_then_else = if_then_else
}
effect SteelK (a:Type) (pre:pre_t) (post:post_t a) =
SteelKBase a false pre post
effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) =
SteelKBase a true pre post
// We would need requires/ensures in SteelK to have a binding with Pure.
// But for our example, Tot is here sufficient
let bind_tot_steelK_ (a:Type) (b:Type)
(#framed:eqtype_as_type bool)
(#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b)
(f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post))
: steelK b
framed
pre
post
= fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) ->
let x = f () in
g x #frame #postf k
polymonadic_bind (PURE, SteelKBase) |> SteelKBase = bind_tot_steelK_
// (* Sanity check *)
let test_lift #p #q (f : unit -> SteelK unit p (fun _ -> q)) : SteelK unit p (fun _ -> q) =
();
f ();
()
(* Identity cont with frame, to eliminate a SteelK *)
let idk (#frame:vprop) (#a:Type) (x:a) : SteelT a frame (fun x -> frame)
= noop(); return x | {
"checked_file": "/",
"dependencies": [
"Steel.Reference.fsti.checked",
"Steel.Primitive.ForkJoin.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Primitive.ForkJoin.Unix.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.Primitive.ForkJoin",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"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": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Primitive.ForkJoin",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Primitive.ForkJoin",
"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 | f: (_: Prims.unit -> Steel.Primitive.ForkJoin.Unix.SteelK Prims.unit)
-> Steel.Primitive.ForkJoin.Unix.SteelK (Steel.Primitive.ForkJoin.thread q) | Steel.Primitive.ForkJoin.Unix.SteelK | [] | [] | [
"Steel.Effect.Common.vprop",
"Prims.unit",
"Steel.Primitive.ForkJoin.thread",
"Steel.Effect.Common.star",
"Steel.Effect.Common.emp",
"Steel.Primitive.ForkJoin.fork",
"Steel.Primitive.ForkJoin.Unix.idk",
"Steel.Primitive.ForkJoin.Unix.steelK",
"Steel.Effect.Atomic.noop",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty"
] | [] | false | true | false | false | false | let kfork (#p #q: vprop) (f: (unit -> SteelK unit p (fun _ -> q)))
: SteelK (thread q) p (fun _ -> emp) =
| SteelK?.reflect (fun
(#frame: vprop)
(#postf: vprop)
(k: (x: (thread q) -> SteelT unit (frame `star` emp) (fun _ -> postf)))
->
noop ();
let t1 () : SteelT unit (emp `star` p) (fun _ -> q) =
let r:steelK unit false p (fun _ -> q) = reify (f ()) in
r #emp #q (fun _ -> idk ())
in
let t2 (t: thread q) () : SteelT unit frame (fun _ -> postf) = k t in
let ff () : SteelT unit (p `star` frame) (fun _ -> postf) = fork #p #q #frame #postf t1 t2 in
ff ()) | false |
Vale.Def.Types_s.fst | Vale.Def.Types_s.reverse_bytes_nat64_def | val reverse_bytes_nat64_def (n: nat64) : nat64 | val reverse_bytes_nat64_def (n: nat64) : nat64 | let reverse_bytes_nat64_def (n:nat64) : nat64 =
let Mktwo n0 n1 = nat_to_two 32 n in
two_to_nat 32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0)) | {
"file_name": "vale/specs/defs/Vale.Def.Types_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 73,
"end_line": 124,
"start_col": 0,
"start_line": 122
} | module Vale.Def.Types_s
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Lib.Seqs_s
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
unfold let nat64 = Vale.Def.Words_s.nat64
let add_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x + y < n then x + y else x + y - n
let sub_wrap (#n:nat) (x:natN n) (y:natN n) : natN n = if x - y >= 0 then x - y else x - y + n
// abstract bitwise operations on integers:
assume val iand : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ixor : #n:nat -> a:natN n -> b:natN n -> natN n
assume val ior : #n:nat -> a:natN n -> b:natN n -> natN n
assume val inot : #n:nat -> a:natN n -> natN n
assume val ishl : #n:nat -> a:natN n -> s:int -> natN n
assume val ishr : #n:nat -> a:natN n -> s:int -> natN n
// Alias
unfold let nat32_xor (x y:nat32) : nat32 = ixor x y
type twobits:eqtype = natN 4
type bits_of_byte:eqtype = four twobits
let byte_to_twobits (b:nat8) : bits_of_byte = nat_to_four_unfold 2 b
type double32:eqtype = two nat32
type quad32:eqtype = four nat32
let quad32_xor_def (x y:quad32) : quad32 = four_map2 nat32_xor x y
[@"opaque_to_smt"] let quad32_xor = opaque_make quad32_xor_def
irreducible let quad32_xor_reveal = opaque_revealer (`%quad32_xor) quad32_xor quad32_xor_def
let select_word (q:quad32) (selector:twobits) : nat32 = four_select q selector
let insert_nat32 (q:quad32) (n:nat32) (i:twobits) : quad32 = four_insert q n i
let insert_nat64_def (q:quad32) (n:nat64) (i:nat1) : quad32 =
two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 n) i)
[@"opaque_to_smt"] let insert_nat64 = opaque_make insert_nat64_def
irreducible let insert_nat64_reveal = opaque_revealer (`%insert_nat64) insert_nat64 insert_nat64_def
open FStar.Seq
let le_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_LE b)
let nat32_to_le_bytes (n:nat32) : b:seq4 nat8 {
le_bytes_to_nat32 b == n} =
let b = four_to_seq_LE (nat_to_four 8 n) in
assume (le_bytes_to_nat32 b == n);
b
let be_bytes_to_nat32 (b:seq4 nat8) : nat32 =
four_to_nat 8 (seq_to_four_BE b)
let nat32_to_be_bytes (n:nat32) : b:seq4 nat8 { be_bytes_to_nat32 b == n } =
let b = four_to_seq_BE (nat_to_four 8 n) in
assume (be_bytes_to_nat32 b == n);
b
assume val be_bytes_to_nat32_to_be_bytes (b:seq4 nat8) :
Lemma (nat32_to_be_bytes (be_bytes_to_nat32 b) == b)
let le_bytes_to_nat64_def (b:seq nat8) : Pure nat64 (requires length b == 8) (ensures fun _ -> True) =
two_to_nat 32 (seq_to_two_LE (seq_nat8_to_seq_nat32_LE b))
[@"opaque_to_smt"] let le_bytes_to_nat64 = opaque_make le_bytes_to_nat64_def
irreducible let le_bytes_to_nat64_reveal = opaque_revealer (`%le_bytes_to_nat64) le_bytes_to_nat64 le_bytes_to_nat64_def
let le_nat64_to_bytes_def (b:nat64) : Pure (seq nat8) (requires True) (ensures fun s -> length s == 8) =
seq_nat32_to_seq_nat8_LE (two_to_seq_LE (nat_to_two 32 b))
[@"opaque_to_smt"] let le_nat64_to_bytes = opaque_make le_nat64_to_bytes_def
irreducible let le_nat64_to_bytes_reveal = opaque_revealer (`%le_nat64_to_bytes) le_nat64_to_bytes le_nat64_to_bytes_def
let le_bytes_to_quad32_def (b:seq nat8) : Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b))
[@"opaque_to_smt"] let le_bytes_to_quad32 = opaque_make le_bytes_to_quad32_def
irreducible let le_bytes_to_quad32_reveal = opaque_revealer (`%le_bytes_to_quad32) le_bytes_to_quad32 le_bytes_to_quad32_def
let be_bytes_to_quad32_def (b:seq nat8) : Pure quad32 (requires length b == 16) (ensures fun _ -> True) =
seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b))
[@"opaque_to_smt"] let be_bytes_to_quad32 = opaque_make be_bytes_to_quad32_def
irreducible let be_bytes_to_quad32_reveal = opaque_revealer (`%be_bytes_to_quad32) be_bytes_to_quad32 be_bytes_to_quad32_def
[@"opaque_to_smt"]
let le_quad32_to_bytes (b:quad32) : Pure (seq nat8) (requires True) (ensures fun s -> length s == 16) =
seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))
let le_seq_quad32_to_bytes_def (b:seq quad32) : seq nat8 =
seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE b)
[@"opaque_to_smt"] let le_seq_quad32_to_bytes = opaque_make le_seq_quad32_to_bytes_def
irreducible let le_seq_quad32_to_bytes_reveal = opaque_revealer (`%le_seq_quad32_to_bytes) le_seq_quad32_to_bytes le_seq_quad32_to_bytes_def
let le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma
(ensures length (le_seq_quad32_to_bytes s) == 16 * (length s))
[SMTPat (length (le_seq_quad32_to_bytes s))]
=
le_seq_quad32_to_bytes_reveal ()
[@"opaque_to_smt"]
let le_bytes_to_seq_quad32 (b:seq nat8) : Pure (seq quad32) (requires length b % 16 == 0) (ensures fun _ -> True) =
seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b)
[@"opaque_to_smt"]
let be_bytes_to_seq_quad32 (b:seq nat8) : Pure (seq quad32) (requires length b % 16 == 0) (ensures fun _ -> True) =
seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE b)
let reverse_bytes_nat32_def (n:nat32) : nat32 =
be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes n))
[@"opaque_to_smt"] let reverse_bytes_nat32 = opaque_make reverse_bytes_nat32_def
irreducible let reverse_bytes_nat32_reveal = opaque_revealer (`%reverse_bytes_nat32) reverse_bytes_nat32 reverse_bytes_nat32_def | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Opaque_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Types_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def",
"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 | n: Vale.Def.Types_s.nat64 -> Vale.Def.Types_s.nat64 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat64",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words.Two_s.two_to_nat",
"Vale.Def.Words_s.Mktwo",
"Vale.Def.Types_s.reverse_bytes_nat32",
"Vale.Def.Words_s.two",
"Vale.Def.Words.Two_s.nat_to_two"
] | [] | false | false | false | true | false | let reverse_bytes_nat64_def (n: nat64) : nat64 =
| let Mktwo n0 n1 = nat_to_two 32 n in
two_to_nat 32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0)) | false |
LowParseWriters.fst | LowParseWriters.valid_rptr | val valid_rptr (p: parser) : memory_invariant -> rptr -> GTot Type0 | val valid_rptr (p: parser) : memory_invariant -> rptr -> GTot Type0 | let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 99,
"start_col": 0,
"start_line": 95
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.LowParse.parser ->
inv: LowParseWriters.memory_invariant ->
x: LowParseWriters.rptr
-> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowParseWriters.rptr",
"Prims.l_and",
"LowStar.Monotonic.Buffer.loc_disjoint",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"FStar.UInt8.t",
"LowStar.Buffer.trivial_preorder",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"LowParseWriters.LowParse.valid_buffer",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0"
] | [] | false | false | false | false | true | let valid_rptr p inv x =
| inv.lwrite `B.loc_disjoint` (B.loc_buffer x.rptr_base) /\ valid_buffer p inv.h0 x.rptr_base | false |
LowParseWriters.fst | LowParseWriters.extract_read_repr_impl | val extract_read_repr_impl
(a:Type u#x)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(l: memory_invariant)
(spec: read_repr_spec a pre post post_err)
(impl: read_repr_impl a pre post post_err l spec)
: HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
)) | val extract_read_repr_impl
(a:Type u#x)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(l: memory_invariant)
(spec: read_repr_spec a pre post post_err)
(impl: read_repr_impl a pre post post_err l spec)
: HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
)) | let extract_read_repr_impl
a pre post post_err l spec impl
=
impl () | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 9,
"end_line": 51,
"start_col": 0,
"start_line": 48
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
pre: Prims.pure_pre ->
post: LowParseWriters.pure_post' a pre ->
post_err: LowParseWriters.pure_post_err pre ->
l: LowParseWriters.memory_invariant ->
spec: LowParseWriters.read_repr_spec a pre post post_err ->
impl: LowParseWriters.read_repr_impl a pre post post_err l spec
-> FStar.HyperStack.ST.Stack (LowParseWriters.result a) | FStar.HyperStack.ST.Stack | [] | [] | [
"Prims.pure_pre",
"LowParseWriters.pure_post'",
"LowParseWriters.pure_post_err",
"LowParseWriters.memory_invariant",
"LowParseWriters.read_repr_spec",
"LowParseWriters.read_repr_impl",
"LowParseWriters.result"
] | [] | false | true | false | false | false | let extract_read_repr_impl a pre post post_err l spec impl =
| impl () | false |
LowParseWriters.fst | LowParseWriters.read_subcomp_impl | val read_subcomp_impl (a:Type)
(pre: pure_pre) (post: pure_post' a pre) (post_err: pure_post_err pre)
(pre': pure_pre) (post': pure_post' a pre') (post_err': pure_post_err pre')
(l:memory_invariant)
(l' : memory_invariant)
(f_subcomp_spec:read_repr_spec a pre post post_err)
(f_subcomp:read_repr_impl a pre post post_err l f_subcomp_spec)
(sq: squash (read_subcomp_cond a pre post post_err pre' post' post_err' l l'))
: Tot (read_repr_impl a pre' post' post_err' l' (read_subcomp_spec a pre post post_err pre' post' post_err' f_subcomp_spec)) | val read_subcomp_impl (a:Type)
(pre: pure_pre) (post: pure_post' a pre) (post_err: pure_post_err pre)
(pre': pure_pre) (post': pure_post' a pre') (post_err': pure_post_err pre')
(l:memory_invariant)
(l' : memory_invariant)
(f_subcomp_spec:read_repr_spec a pre post post_err)
(f_subcomp:read_repr_impl a pre post post_err l f_subcomp_spec)
(sq: squash (read_subcomp_cond a pre post post_err pre' post' post_err' l l'))
: Tot (read_repr_impl a pre' post' post_err' l' (read_subcomp_spec a pre post post_err pre' post' post_err' f_subcomp_spec)) | let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp () | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 68,
"start_col": 0,
"start_line": 65
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
pre: Prims.pure_pre ->
post: LowParseWriters.pure_post' a pre ->
post_err: LowParseWriters.pure_post_err pre ->
pre': Prims.pure_pre ->
post': LowParseWriters.pure_post' a pre' ->
post_err': LowParseWriters.pure_post_err pre' ->
l: LowParseWriters.memory_invariant ->
l': LowParseWriters.memory_invariant ->
f_subcomp_spec: LowParseWriters.read_repr_spec a pre post post_err ->
f_subcomp: LowParseWriters.read_repr_impl a pre post post_err l f_subcomp_spec ->
sq:
Prims.squash (LowParseWriters.read_subcomp_cond a pre post post_err pre' post' post_err' l l')
-> LowParseWriters.read_repr_impl a
pre'
post'
post_err'
l'
(LowParseWriters.read_subcomp_spec a pre post post_err pre' post' post_err' f_subcomp_spec) | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_pre",
"LowParseWriters.pure_post'",
"LowParseWriters.pure_post_err",
"LowParseWriters.memory_invariant",
"LowParseWriters.read_repr_spec",
"LowParseWriters.read_repr_impl",
"Prims.squash",
"LowParseWriters.read_subcomp_cond",
"Prims.unit",
"LowParseWriters.result"
] | [] | false | false | false | false | false | let read_subcomp_impl a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq =
| fun _ -> f_subcomp () | false |
LowParseWriters.fst | LowParseWriters.mk_read_repr_impl | val mk_read_repr_impl
(a:Type u#x)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(l: memory_invariant)
(spec: read_repr_spec a pre post post_err)
(impl: (
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
))
: Tot (read_repr_impl a pre post post_err l spec) | val mk_read_repr_impl
(a:Type u#x)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(l: memory_invariant)
(spec: read_repr_spec a pre post post_err)
(impl: (
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
))
: Tot (read_repr_impl a pre post post_err l spec) | let mk_read_repr_impl
a pre post post_err l spec impl
=
impl | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 6,
"end_line": 46,
"start_col": 0,
"start_line": 43
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
pre: Prims.pure_pre ->
post: LowParseWriters.pure_post' a pre ->
post_err: LowParseWriters.pure_post_err pre ->
l: LowParseWriters.memory_invariant ->
spec: LowParseWriters.read_repr_spec a pre post post_err ->
impl: (_: Prims.unit -> FStar.HyperStack.ST.Stack (LowParseWriters.result a))
-> LowParseWriters.read_repr_impl a pre post post_err l spec | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_pre",
"LowParseWriters.pure_post'",
"LowParseWriters.pure_post_err",
"LowParseWriters.memory_invariant",
"LowParseWriters.read_repr_spec",
"Prims.unit",
"LowParseWriters.result",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"Prims.b2t",
"FStar.Monotonic.HyperHeap.includes",
"FStar.Monotonic.HyperStack.get_tip",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.eq2",
"LowParseWriters.read_repr_impl"
] | [] | false | false | false | false | false | let mk_read_repr_impl a pre post post_err l spec impl =
| impl | false |
LowParseWriters.fst | LowParseWriters.read_return_impl | val read_return_impl
(a:Type) (x:a) (inv: memory_invariant)
: Tot (read_repr_impl a True (fun res -> res == x) (fun _ -> False) inv (read_return_spec a x)) | val read_return_impl
(a:Type) (x:a) (inv: memory_invariant)
: Tot (read_repr_impl a True (fun res -> res == x) (fun _ -> False) inv (read_return_spec a x)) | let read_return_impl
a x inv
= fun _ -> Correct x | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 55,
"start_col": 0,
"start_line": 53
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | a: Type -> x: a -> inv: LowParseWriters.memory_invariant
-> LowParseWriters.read_repr_impl a
Prims.l_True
(fun res -> res == x)
(fun _ -> Prims.l_False)
inv
(LowParseWriters.read_return_spec a x) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.memory_invariant",
"Prims.unit",
"LowParseWriters.Correct",
"LowParseWriters.result"
] | [] | false | false | false | false | false | let read_return_impl a x inv =
| fun _ -> Correct x | false |
LowParseWriters.fst | LowParseWriters.read_repr_impl | val read_repr_impl
(a:Type u#x)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(l: memory_invariant)
(spec: read_repr_spec a pre post post_err)
: Tot Type0 | val read_repr_impl
(a:Type u#x)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(l: memory_invariant)
(spec: read_repr_spec a pre post post_err)
: Tot Type0 | let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
)) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 41,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
pre: Prims.pure_pre ->
post: LowParseWriters.pure_post' a pre ->
post_err: LowParseWriters.pure_post_err pre ->
l: LowParseWriters.memory_invariant ->
spec: LowParseWriters.read_repr_spec a pre post post_err
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_pre",
"LowParseWriters.pure_post'",
"LowParseWriters.pure_post_err",
"LowParseWriters.memory_invariant",
"LowParseWriters.read_repr_spec",
"Prims.unit",
"LowParseWriters.result",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"Prims.b2t",
"FStar.Monotonic.HyperHeap.includes",
"FStar.Monotonic.HyperStack.get_tip",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.eq2"
] | [] | false | false | false | false | true | let read_repr_impl a pre post post_err l spec =
| unit
-> HST.Stack (result a)
(requires
(fun h ->
B.modifies l.lwrite l.h0 h /\ (HS.get_tip l.h0) `HS.includes` (HS.get_tip h) /\ pre))
(ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == spec ())) | false |
LowParseWriters.fst | LowParseWriters.read_bind_impl | val read_bind_impl
(a:Type) (b:Type)
(pre_f: pure_pre) (post_f: pure_post' a pre_f)
(post_err_f: pure_post_err pre_f)
(pre_g: (x:a) -> pure_pre) (post_g: (x:a) -> pure_post' b (pre_g x))
(post_err_g: (x: a) -> pure_post_err (pre_g x))
(f_bind_impl: read_repr_spec a pre_f post_f post_err_f)
(g:(x:a -> read_repr_spec b (pre_g x) (post_g x) (post_err_g x)))
(l: memory_invariant)
(f' : read_repr_impl a pre_f post_f post_err_f l f_bind_impl)
(g' : (x: a -> read_repr_impl b (pre_g x) (post_g x) (post_err_g x) l (g x)))
: Tot (read_repr_impl b _ _ _ l (read_bind_spec a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g)) | val read_bind_impl
(a:Type) (b:Type)
(pre_f: pure_pre) (post_f: pure_post' a pre_f)
(post_err_f: pure_post_err pre_f)
(pre_g: (x:a) -> pure_pre) (post_g: (x:a) -> pure_post' b (pre_g x))
(post_err_g: (x: a) -> pure_post_err (pre_g x))
(f_bind_impl: read_repr_spec a pre_f post_f post_err_f)
(g:(x:a -> read_repr_spec b (pre_g x) (post_g x) (post_err_g x)))
(l: memory_invariant)
(f' : read_repr_impl a pre_f post_f post_err_f l f_bind_impl)
(g' : (x: a -> read_repr_impl b (pre_g x) (post_g x) (post_err_g x) l (g x)))
: Tot (read_repr_impl b _ _ _ l (read_bind_spec a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g)) | let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 22,
"end_line": 63,
"start_col": 0,
"start_line": 57
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
b: Type ->
pre_f: Prims.pure_pre ->
post_f: LowParseWriters.pure_post' a pre_f ->
post_err_f: LowParseWriters.pure_post_err pre_f ->
pre_g: (x: a -> Prims.pure_pre) ->
post_g: (x: a -> LowParseWriters.pure_post' b (pre_g x)) ->
post_err_g: (x: a -> LowParseWriters.pure_post_err (pre_g x)) ->
f_bind_impl: LowParseWriters.read_repr_spec a pre_f post_f post_err_f ->
g: (x: a -> LowParseWriters.read_repr_spec b (pre_g x) (post_g x) (post_err_g x)) ->
l: LowParseWriters.memory_invariant ->
f': LowParseWriters.read_repr_impl a pre_f post_f post_err_f l f_bind_impl ->
g': (x: a -> LowParseWriters.read_repr_impl b (pre_g x) (post_g x) (post_err_g x) l (g x))
-> LowParseWriters.read_repr_impl b
(pre_f /\ (forall (x: a). post_f x ==> pre_g x))
(fun y -> exists (x: a). pre_f /\ post_f x /\ post_g x y)
(fun _ -> pre_f /\ (post_err_f () \/ (exists (x: a). post_f x /\ post_err_g x ())))
l
(LowParseWriters.read_bind_spec a b pre_f post_f post_err_f pre_g post_g post_err_g
f_bind_impl g) | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_pre",
"LowParseWriters.pure_post'",
"LowParseWriters.pure_post_err",
"LowParseWriters.read_repr_spec",
"LowParseWriters.memory_invariant",
"LowParseWriters.read_repr_impl",
"Prims.unit",
"LowParseWriters.result",
"Prims.string",
"LowParseWriters.Error"
] | [] | false | false | false | false | false | let read_bind_impl a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g' =
| fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e | false |
LowParseWriters.fst | LowParseWriters.deref_spec | val deref_spec (#p: parser) (#inv: memory_invariant) (x: ptr p inv) : GTot (Parser?.t p) | val deref_spec (#p: parser) (#inv: memory_invariant) (x: ptr p inv) : GTot (Parser?.t p) | let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 104,
"start_col": 0,
"start_line": 101
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.ptr p inv -> Prims.GTot (Parser?.t p) | Prims.GTot | [
"sometrivial"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowParseWriters.ptr",
"LowParseWriters.LowParse.buffer_contents",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"LowParseWriters.LowParse.__proj__Parser__item__t"
] | [] | false | false | false | false | false | let deref_spec #p #inv x =
| buffer_contents p inv.h0 x.rptr_base | false |
LowParseWriters.fst | LowParseWriters.mk_ptr | val mk_ptr
(p: parser)
(inv: memory_invariant)
(b: B.buffer u8)
(len: U32.t { len == B.len b })
: Pure (ptr p inv)
(requires (valid_buffer p inv.h0 b /\ inv.lwrite `B.loc_disjoint` B.loc_buffer b))
(ensures (fun res -> deref_spec res == buffer_contents p inv.h0 b)) | val mk_ptr
(p: parser)
(inv: memory_invariant)
(b: B.buffer u8)
(len: U32.t { len == B.len b })
: Pure (ptr p inv)
(requires (valid_buffer p inv.h0 b /\ inv.lwrite `B.loc_disjoint` B.loc_buffer b))
(ensures (fun res -> deref_spec res == buffer_contents p inv.h0 b)) | let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
} | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 111,
"start_col": 0,
"start_line": 106
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.LowParse.parser ->
inv: LowParseWriters.memory_invariant ->
b: LowStar.Buffer.buffer LowParseWriters.LowParse.u8 ->
len: FStar.UInt32.t{len == LowStar.Monotonic.Buffer.len b}
-> Prims.Pure (LowParseWriters.ptr p inv) | Prims.Pure | [] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"LowParseWriters.Mkrptr",
"LowParseWriters.ptr"
] | [] | false | false | false | false | false | let mk_ptr p inv b len =
| { rptr_base = b; rptr_len = len } | false |
Selectors.LList2.fst | Selectors.LList2.is_nil | val is_nil (#a:Type0) (ptr:t a)
: Steel bool (llist ptr) (fun _ -> llist ptr)
(requires fun _ -> True)
(ensures fun h0 res h1 ->
(res == true <==> ptr == null_llist #a) /\
v_llist ptr h0 == v_llist ptr h1 /\
res == Nil? (v_llist ptr h1)) | val is_nil (#a:Type0) (ptr:t a)
: Steel bool (llist ptr) (fun _ -> llist ptr)
(requires fun _ -> True)
(ensures fun h0 res h1 ->
(res == true <==> ptr == null_llist #a) /\
v_llist ptr h0 == v_llist ptr h1 /\
res == Nil? (v_llist ptr h1)) | let is_nil
#a ptr
= is_nil' ptr;
return (is_null ptr) | {
"file_name": "share/steel/examples/steel/Selectors.LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 22,
"end_line": 270,
"start_col": 0,
"start_line": 267
} | module Selectors.LList2
open Steel.FractionalPermission
module Mem = Steel.Memory
#push-options "--__no_positivity"
noeq
type cell (a: Type0) = {
tail_fuel: Ghost.erased nat;
next: ref (cell a);
data: a;
}
#pop-options
let next #a (c:cell a) : t a = c.next
let data #a (c:cell a) : a = c.data
let mk_cell #a (n: t a) (d:a) = {
tail_fuel = Ghost.hide 0;
next = n;
data = d
}
let null_llist #a = null
let is_null #a ptr = is_null ptr
let v_null_rewrite
(a: Type0)
(_: t_of emp)
: GTot (list a)
= []
let v_c
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: GTot prop
= (Ghost.reveal c.tail_fuel < Ghost.reveal n) == true // to ensure vprop termination
let v_c_dep
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(c: normal (t_of (vrefine (vptr r) (v_c n r))))
: Tot vprop
= nllist c.tail_fuel c.next
let v_c_l_rewrite
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(res: normal (t_of ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r nllist)))
: Tot (list a)
= let (| c, l |) = res in
c.data :: l
let rec nllist
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
(decreases (Ghost.reveal n))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
let nllist_eq_not_null
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Lemma
(requires (is_null r == false))
(ensures (
nllist a n r == ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
))
= assert_norm (nllist a n r ==
begin if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
end
)
let llist_vdep
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: Tot vprop
= nllist a c.tail_fuel c.next
let llist_vrewrite
(#a: Type0)
(r: t a)
(cl: normal (t_of (vptr r `vdep` llist_vdep r)))
: GTot (list a)
= (dfst cl).data :: dsnd cl
let llist0
(#a: Type0)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else (vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r
let nllist_of_llist0
(#opened: _)
(#a: Type0)
(r: t a)
: SteelGhost (Ghost.erased nat) opened
(llist0 r)
(fun res -> nllist a res r)
(fun _ -> True)
(fun h0 res h1 ->
h0 (llist0 r) == h1 (nllist a res r)
)
=
if is_null r
then begin
let res = Ghost.hide 0 in
change_equal_slprop
(llist0 r)
(nllist a res r);
res
end else begin
change_equal_slprop
(llist0 r)
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r);
elim_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
let gk : normal (Ghost.erased (t_of (vptr r))) = elim_vdep (vptr r) (llist_vdep r) in
let res = Ghost.hide (Ghost.reveal (Ghost.reveal gk).tail_fuel + 1) in
intro_vrefine (vptr r) (v_c res r);
intro_vdep
(vptr r `vrefine` v_c res r)
(llist_vdep r (Ghost.reveal gk))
(v_c_dep res r (nllist a));
intro_vrewrite ((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) (v_c_l_rewrite res r (nllist a));
nllist_eq_not_null a res r;
change_equal_slprop
(((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) `vrewrite` v_c_l_rewrite res r (nllist a))
(nllist a res r);
res
end
let llist0_of_nllist
(#opened: _)
(#a: Type0)
(n: Ghost.erased nat)
(r: t a)
: SteelGhost unit opened
(nllist a n r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 res h1 ->
h1 (llist0 r) == h0 (nllist a n r)
)
=
if is_null r
then begin
change_equal_slprop
(nllist a n r)
(llist0 r);
()
end else begin
nllist_eq_not_null a n r;
change_equal_slprop
(nllist a n r)
(((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a));
elim_vrewrite ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) (v_c_l_rewrite n r (nllist a));
let gk = elim_vdep (vptr r `vrefine` v_c n r) (v_c_dep n r (nllist a)) in
elim_vrefine (vptr r) (v_c n r);
intro_vdep
(vptr r)
(v_c_dep n r (nllist a) (Ghost.reveal gk))
(llist_vdep r);
intro_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
change_equal_slprop
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r)
(llist0 r)
end
let llist_sl
#a r
= hp_of (llist0 r)
let llist_sel
#a r
= fun m -> sel_of (llist0 r) m // eta necessary because sel_of is GTot
let llist_of_llist0
(#opened: _)
(#a: Type)
(r: t a)
: SteelGhost unit opened
(llist0 r)
(fun _ -> llist r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist r) == h0 (llist0 r))
=
change_slprop_rel
(llist0 r)
(llist r)
(fun x y -> x == y)
(fun _ -> ())
let llist0_of_llist
(#opened: _)
(#a: Type)
(r: t a)
: SteelGhost unit opened
(llist r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist0 r) == h0 (llist r))
=
change_slprop_rel
(llist r)
(llist0 r)
(fun x y -> x == y)
(fun _ -> ())
let intro_llist_nil a =
intro_vrewrite emp (v_null_rewrite a);
change_equal_slprop
(emp `vrewrite` v_null_rewrite a)
(llist0 (null_llist #a));
llist_of_llist0 (null_llist #a)
let is_nil' (#opened: _) (#a:Type0) (ptr:t a)
: SteelGhost unit opened (llist ptr) (fun _ -> llist ptr)
(requires fun _ -> True)
(ensures fun h0 _ h1 ->
let res = is_null ptr in
(res == true <==> ptr == null_llist #a) /\
v_llist ptr h0 == v_llist ptr h1 /\
res == Nil? (v_llist ptr h1))
=
let res = is_null ptr in
llist0_of_llist ptr;
if res
then begin
change_equal_slprop
(llist0 ptr)
(emp `vrewrite` v_null_rewrite a);
elim_vrewrite emp (v_null_rewrite a);
intro_vrewrite emp (v_null_rewrite a);
change_equal_slprop
(emp `vrewrite` v_null_rewrite a)
(llist0 ptr)
end else begin
change_equal_slprop
(llist0 ptr)
((vptr ptr `vdep` llist_vdep ptr) `vrewrite` llist_vrewrite ptr);
elim_vrewrite (vptr ptr `vdep` llist_vdep ptr) (llist_vrewrite ptr);
intro_vrewrite (vptr ptr `vdep` llist_vdep ptr) (llist_vrewrite ptr);
change_equal_slprop
((vptr ptr `vdep` llist_vdep ptr) `vrewrite` llist_vrewrite ptr)
(llist0 ptr)
end;
llist_of_llist0 ptr | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Selectors.LList2.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"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": "Selectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Selectors",
"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 | ptr: Selectors.LList2.t a -> Steel.Effect.Steel Prims.bool | Steel.Effect.Steel | [] | [] | [
"Selectors.LList2.t",
"Steel.Effect.Atomic.return",
"Prims.bool",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Selectors.LList2.llist",
"Steel.Effect.Common.vprop",
"Selectors.LList2.is_null",
"Prims.unit",
"Selectors.LList2.is_nil'"
] | [] | false | true | false | false | false | let is_nil #a ptr =
| is_nil' ptr;
return (is_null ptr) | false |
LowParseWriters.fst | LowParseWriters.failwith_impl | val failwith_impl
(a: Type)
(inv: memory_invariant)
(s: string)
: Tot (read_repr_impl a True (fun _ -> False) (fun _ -> True) inv (failwith_spec a s)) | val failwith_impl
(a: Type)
(inv: memory_invariant)
(s: string)
: Tot (read_repr_impl a True (fun _ -> False) (fun _ -> True) inv (failwith_spec a s)) | let failwith_impl
a inv s
= fun _ -> Error s | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 77,
"start_col": 0,
"start_line": 75
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ()) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | a: Type -> inv: LowParseWriters.memory_invariant -> s: Prims.string
-> LowParseWriters.read_repr_impl a
Prims.l_True
(fun _ -> Prims.l_False)
(fun _ -> Prims.l_True)
inv
(LowParseWriters.failwith_spec a s) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.memory_invariant",
"Prims.string",
"Prims.unit",
"LowParseWriters.Error",
"LowParseWriters.result"
] | [] | false | false | false | false | false | let failwith_impl a inv s =
| fun _ -> Error s | false |
LowParseWriters.fst | LowParseWriters.validate_spec | val validate_spec
(p: parser)
(inv: memory_invariant)
(b: B.buffer U8.t)
: Tot (read_repr_spec (ptr p inv & U32.t) (validate_pre inv b) (validate_post p inv b) (validate_post_err p inv b)) | val validate_spec
(p: parser)
(inv: memory_invariant)
(b: B.buffer U8.t)
: Tot (read_repr_spec (ptr p inv & U32.t) (validate_pre inv b) (validate_post p inv b) (validate_post_err p inv b)) | let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 155,
"start_col": 0,
"start_line": 147
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' }) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.LowParse.parser ->
inv: LowParseWriters.memory_invariant ->
b: LowStar.Buffer.buffer FStar.UInt8.t
-> LowParseWriters.read_repr_spec (LowParseWriters.ptr p inv * FStar.UInt32.t)
(LowParseWriters.validate_pre inv b)
(LowParseWriters.validate_post p inv b)
(LowParseWriters.validate_post_err p inv b) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"FStar.UInt8.t",
"Prims.unit",
"LowParseWriters.LowParse.gvalidate",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowParseWriters.Error",
"FStar.Pervasives.Native.tuple2",
"LowParseWriters.ptr",
"FStar.UInt32.t",
"LowParseWriters.Correct",
"FStar.Pervasives.Native.Mktuple2",
"LowParseWriters.rptr",
"LowParseWriters.Mkrptr",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"LowStar.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.result"
] | [] | false | false | false | false | false | let validate_spec p inv b =
| fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b'; rptr_len = pos } in
Correct (x, pos) | false |
Selectors.LList2.fst | Selectors.LList2.llist0_of_llist | val llist0_of_llist (#opened: _) (#a: Type) (r: t a)
: SteelGhost unit
opened
(llist r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist0 r) == h0 (llist r)) | val llist0_of_llist (#opened: _) (#a: Type) (r: t a)
: SteelGhost unit
opened
(llist r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist0 r) == h0 (llist r)) | let llist0_of_llist
(#opened: _)
(#a: Type)
(r: t a)
: SteelGhost unit opened
(llist r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist0 r) == h0 (llist r))
=
change_slprop_rel
(llist r)
(llist0 r)
(fun x y -> x == y)
(fun _ -> ()) | {
"file_name": "share/steel/examples/steel/Selectors.LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 17,
"end_line": 225,
"start_col": 0,
"start_line": 211
} | module Selectors.LList2
open Steel.FractionalPermission
module Mem = Steel.Memory
#push-options "--__no_positivity"
noeq
type cell (a: Type0) = {
tail_fuel: Ghost.erased nat;
next: ref (cell a);
data: a;
}
#pop-options
let next #a (c:cell a) : t a = c.next
let data #a (c:cell a) : a = c.data
let mk_cell #a (n: t a) (d:a) = {
tail_fuel = Ghost.hide 0;
next = n;
data = d
}
let null_llist #a = null
let is_null #a ptr = is_null ptr
let v_null_rewrite
(a: Type0)
(_: t_of emp)
: GTot (list a)
= []
let v_c
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: GTot prop
= (Ghost.reveal c.tail_fuel < Ghost.reveal n) == true // to ensure vprop termination
let v_c_dep
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(c: normal (t_of (vrefine (vptr r) (v_c n r))))
: Tot vprop
= nllist c.tail_fuel c.next
let v_c_l_rewrite
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(res: normal (t_of ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r nllist)))
: Tot (list a)
= let (| c, l |) = res in
c.data :: l
let rec nllist
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
(decreases (Ghost.reveal n))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
let nllist_eq_not_null
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Lemma
(requires (is_null r == false))
(ensures (
nllist a n r == ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
))
= assert_norm (nllist a n r ==
begin if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
end
)
let llist_vdep
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: Tot vprop
= nllist a c.tail_fuel c.next
let llist_vrewrite
(#a: Type0)
(r: t a)
(cl: normal (t_of (vptr r `vdep` llist_vdep r)))
: GTot (list a)
= (dfst cl).data :: dsnd cl
let llist0
(#a: Type0)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else (vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r
let nllist_of_llist0
(#opened: _)
(#a: Type0)
(r: t a)
: SteelGhost (Ghost.erased nat) opened
(llist0 r)
(fun res -> nllist a res r)
(fun _ -> True)
(fun h0 res h1 ->
h0 (llist0 r) == h1 (nllist a res r)
)
=
if is_null r
then begin
let res = Ghost.hide 0 in
change_equal_slprop
(llist0 r)
(nllist a res r);
res
end else begin
change_equal_slprop
(llist0 r)
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r);
elim_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
let gk : normal (Ghost.erased (t_of (vptr r))) = elim_vdep (vptr r) (llist_vdep r) in
let res = Ghost.hide (Ghost.reveal (Ghost.reveal gk).tail_fuel + 1) in
intro_vrefine (vptr r) (v_c res r);
intro_vdep
(vptr r `vrefine` v_c res r)
(llist_vdep r (Ghost.reveal gk))
(v_c_dep res r (nllist a));
intro_vrewrite ((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) (v_c_l_rewrite res r (nllist a));
nllist_eq_not_null a res r;
change_equal_slprop
(((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) `vrewrite` v_c_l_rewrite res r (nllist a))
(nllist a res r);
res
end
let llist0_of_nllist
(#opened: _)
(#a: Type0)
(n: Ghost.erased nat)
(r: t a)
: SteelGhost unit opened
(nllist a n r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 res h1 ->
h1 (llist0 r) == h0 (nllist a n r)
)
=
if is_null r
then begin
change_equal_slprop
(nllist a n r)
(llist0 r);
()
end else begin
nllist_eq_not_null a n r;
change_equal_slprop
(nllist a n r)
(((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a));
elim_vrewrite ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) (v_c_l_rewrite n r (nllist a));
let gk = elim_vdep (vptr r `vrefine` v_c n r) (v_c_dep n r (nllist a)) in
elim_vrefine (vptr r) (v_c n r);
intro_vdep
(vptr r)
(v_c_dep n r (nllist a) (Ghost.reveal gk))
(llist_vdep r);
intro_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
change_equal_slprop
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r)
(llist0 r)
end
let llist_sl
#a r
= hp_of (llist0 r)
let llist_sel
#a r
= fun m -> sel_of (llist0 r) m // eta necessary because sel_of is GTot
let llist_of_llist0
(#opened: _)
(#a: Type)
(r: t a)
: SteelGhost unit opened
(llist0 r)
(fun _ -> llist r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist r) == h0 (llist0 r))
=
change_slprop_rel
(llist0 r)
(llist r)
(fun x y -> x == y)
(fun _ -> ()) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Selectors.LList2.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"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": "Selectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Selectors",
"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 | r: Selectors.LList2.t a -> Steel.Effect.Atomic.SteelGhost Prims.unit | Steel.Effect.Atomic.SteelGhost | [] | [] | [
"Steel.Memory.inames",
"Selectors.LList2.t",
"Steel.Effect.Atomic.change_slprop_rel",
"Selectors.LList2.llist",
"Selectors.LList2.llist0",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Prims.eq2",
"Prims.prop",
"Steel.Memory.mem",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_True"
] | [] | false | true | false | false | false | let llist0_of_llist (#opened: _) (#a: Type) (r: t a)
: SteelGhost unit
opened
(llist r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist0 r) == h0 (llist r)) =
| change_slprop_rel (llist r) (llist0 r) (fun x y -> x == y) (fun _ -> ()) | false |
LowParseWriters.fst | LowParseWriters.repr_impl | val repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 | val repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 | let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
)) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 217,
"start_col": 0,
"start_line": 195
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
r_in: LowParseWriters.LowParse.parser ->
r_out: LowParseWriters.LowParse.parser ->
pre: LowParseWriters.pre_t r_in ->
post: LowParseWriters.post_t a r_in r_out pre ->
post_err: LowParseWriters.post_err_t r_in pre ->
l: LowParseWriters.memory_invariant ->
spec: LowParseWriters.repr_spec a r_in r_out pre post post_err
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.memory_invariant",
"LowParseWriters.repr_spec",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.iresult",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"Prims.b2t",
"FStar.Monotonic.HyperHeap.includes",
"FStar.Monotonic.HyperStack.get_tip",
"LowParseWriters.LowParse.valid_pos",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.LowParse.contents",
"LowParseWriters.repr_impl_post"
] | [] | false | false | false | false | true | let repr_impl
(a: Type u#x)
(r_in r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
|
b: B.buffer u8 {l.lwrite `B.loc_includes` (B.loc_buffer b)} ->
len: U32.t{len == B.len b} ->
pos1: buffer_offset b
-> HST.Stack (iresult a)
(requires
(fun h ->
B.modifies l.lwrite l.h0 h /\ (HS.get_tip l.h0) `HS.includes` (HS.get_tip h) /\
valid_pos r_in h b 0ul pos1 /\ pre (contents r_in h b 0ul pos1)))
(ensures
(fun h res h' -> repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h')) | false |
LowParseWriters.fst | LowParseWriters.lift_pure_read_impl | val lift_pure_read_impl
(a:Type) (wp:pure_wp a)
(f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (read_repr_impl a _ _ _ l (lift_pure_read_spec a wp f_pure_spec_for_impl)) | val lift_pure_read_impl
(a:Type) (wp:pure_wp a)
(f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (read_repr_impl a _ _ _ l (lift_pure_read_spec a wp f_pure_spec_for_impl)) | let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ()) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 73,
"start_col": 0,
"start_line": 70
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
wp: Prims.pure_wp a ->
f_pure_spec_for_impl: (_: Prims.unit -> Prims.PURE a) ->
l: LowParseWriters.memory_invariant
-> LowParseWriters.read_repr_impl a
(wp (fun _ -> Prims.l_True))
(fun x -> ~(wp (fun x' -> ~(x == x'))))
(fun _ -> Prims.l_False)
l
(LowParseWriters.lift_pure_read_spec a wp f_pure_spec_for_impl) | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_wp",
"Prims.unit",
"LowParseWriters.memory_invariant",
"LowParseWriters.Correct",
"LowParseWriters.result",
"FStar.Monotonic.Pure.elim_pure_wp_monotonicity",
"LowParseWriters.read_repr_impl",
"Prims.l_True",
"Prims.l_not",
"Prims.eq2",
"Prims.l_False",
"LowParseWriters.lift_pure_read_spec"
] | [] | false | false | false | false | false | let lift_pure_read_impl a wp f_pure_spec_for_impl l =
| FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ()) | false |
LowParseWriters.fst | LowParseWriters.deref_impl | val deref_impl
(#p: parser)
(#inv: memory_invariant)
(r: leaf_reader p)
(x: ptr p inv)
: Tot (read_repr_impl (Parser?.t p) True (fun res -> res == deref_spec x) (fun _ -> False) inv (fun _ -> Correct (deref_spec x))) | val deref_impl
(#p: parser)
(#inv: memory_invariant)
(r: leaf_reader p)
(x: ptr p inv)
: Tot (read_repr_impl (Parser?.t p) True (fun res -> res == deref_spec x) (fun _ -> False) inv (fun _ -> Correct (deref_spec x))) | let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 127,
"start_col": 0,
"start_line": 122
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | r: LowParseWriters.LowParse.leaf_reader p -> x: LowParseWriters.ptr p inv
-> LowParseWriters.read_repr_impl (Parser?.t p)
Prims.l_True
(fun res -> res == LowParseWriters.deref_spec x)
(fun _ -> Prims.l_False)
inv
(fun _ -> LowParseWriters.Correct (LowParseWriters.deref_spec x)) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.leaf_reader",
"LowParseWriters.ptr",
"Prims.unit",
"LowParseWriters.Correct",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.result",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"LowParseWriters.__proj__Mkrptr__item__rptr_len",
"LowParseWriters.LowParse.valid_frame",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.len",
"FStar.UInt8.t",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"FStar.HyperStack.ST.get"
] | [] | false | false | false | false | false | let deref_impl #p #inv r x _ =
| let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len) | false |
LowParseWriters.fst | LowParseWriters.buffer_index_impl | val buffer_index_impl
(#t: Type)
(inv: memory_invariant)
(b: B.buffer t)
(i: U32.t)
: Tot (read_repr_impl _ _ _ _ inv (buffer_index_spec inv b i)) | val buffer_index_impl
(#t: Type)
(inv: memory_invariant)
(b: B.buffer t)
(i: U32.t)
: Tot (read_repr_impl _ _ _ _ inv (buffer_index_spec inv b i)) | let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 82,
"start_col": 0,
"start_line": 79
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | inv: LowParseWriters.memory_invariant -> b: LowStar.Buffer.buffer t -> i: FStar.UInt32.t
-> LowParseWriters.read_repr_impl t
(LowStar.Monotonic.Buffer.live (FStar.Ghost.reveal (Mkmemory_invariant?.h0 inv)) b /\
LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_buffer b)
(FStar.Ghost.reveal (Mkmemory_invariant?.lwrite inv)) /\
FStar.UInt32.v i < LowStar.Monotonic.Buffer.length b)
(fun res ->
FStar.UInt32.v i < LowStar.Monotonic.Buffer.length b /\
res ==
FStar.Seq.Base.index (LowStar.Monotonic.Buffer.as_seq (FStar.Ghost.reveal (Mkmemory_invariant?.h0
inv))
b)
(FStar.UInt32.v i))
(fun _ -> Prims.l_False)
inv
(LowParseWriters.buffer_index_spec inv b i) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"FStar.UInt32.t",
"Prims.unit",
"LowParseWriters.Correct",
"LowParseWriters.result",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder"
] | [] | false | false | false | false | false | let buffer_index_impl #t inv b i =
| fun _ -> Correct (B.index b i) | false |
OWGCounter.fst | OWGCounter.incr_ctr | val incr_ctr (#v: G.erased int) (r: ref int)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm (v + 1)) | val incr_ctr (#v: G.erased int) (r: ref int)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm (v + 1)) | let incr_ctr (#v:G.erased int) (r:ref int)
: SteelT unit
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm (v+1))
= let n = R.read_pt r in
R.write_pt r (n+1);
rewrite_slprop (pts_to r full_perm (n + 1))
(pts_to r full_perm (v+1))
(fun _ -> ()) | {
"file_name": "share/steel/examples/steel/OWGCounter.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 31,
"end_line": 185,
"start_col": 0,
"start_line": 177
} | (*
Copyright 2019 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.
*)
(*
* An implementation of the parallel counter presented by Owicki and Gries
* "Verifying properties of parallel programs: An axiomatic approach.", CACM'76
*
* In this example, the main thread forks two worker thread that both
* increment a shared counter. The goal of the example is to show that
* after both the worker threads are done, the value of the counter is
* its original value + 2.
*
* See http://pm.inf.ethz.ch/publications/getpdf.php for an implementation
* of the OWG counters in the Chalice framework.
*)
module OWGCounter
module G = FStar.Ghost
open Steel.Memory
open Steel.FractionalPermission
open Steel.Reference
open Steel.SpinLock
open Steel.Effect.Atomic
open Steel.Effect
module R = Steel.Reference
module P = Steel.FractionalPermission
module A = Steel.Effect.Atomic
#set-options "--ide_id_info_off --using_facts_from '* -FStar.Tactics -FStar.Reflection' --fuel 0 --ifuel 0"
let half_perm = half_perm full_perm
(* Some basic wrappers to avoid issues with normalization.
TODO: The frame inference tactic should not normalize fst and snd*)
noextract
let fst = fst
noextract
let snd = snd
/// The core invariant of the Owicki-Gries counter, shared by the two parties.
/// The concrete counter [r] is shared, and the full permission is stored in the invariant.
/// Each party also has half permission to their own ghost counter [r1] or [r2], ensuring that
/// only them can modify it by retrieving the other half of the permission when accessing the invariant.
/// The `__reduce__` attribute indicates the frame inference tactic to unfold this predicate for frame inference only
[@@ __reduce__]
let lock_inv_slprop (r:ref int) (r1 r2:ghost_ref int) (w:int & int) =
ghost_pts_to r1 half_perm (fst w) `star`
ghost_pts_to r2 half_perm (snd w) `star`
pts_to r full_perm (fst w + snd w)
[@@ __reduce__]
let lock_inv_pred (r:ref int) (r1 r2:ghost_ref int) =
fun (x:int & int) -> lock_inv_slprop r r1 r2 x
/// The actual invariant, existentially quantifying over the values currently stored in the two ghost references
[@@ __reduce__]
let lock_inv (r:ref int) (r1 r2:ghost_ref int) : vprop =
h_exists (lock_inv_pred r r1 r2)
#push-options "--warn_error -271 --fuel 1 --ifuel 1"
/// A helper lemma to reason about the lock invariant
let lock_inv_equiv_lemma (r:ref int) (r1 r2:ghost_ref int)
: Lemma (lock_inv r r1 r2 `equiv` lock_inv r r2 r1)
=
let aux (r:ref int) (r1 r2:ghost_ref int) (m:mem)
: Lemma
(requires interp (hp_of (lock_inv r r1 r2)) m)
(ensures interp (hp_of (lock_inv r r2 r1)) m)
[SMTPat ()]
= assert (
Steel.Memory.h_exists #(int & int) (fun x -> hp_of (lock_inv_pred r r1 r2 x)) ==
h_exists_sl #(int & int) (lock_inv_pred r r1 r2))
by (FStar.Tactics.norm [delta_only [`%h_exists_sl]]);
let w : G.erased (int & int) = id_elim_exists (fun x -> hp_of (lock_inv_pred r r1 r2 x)) m in
assert ((ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star`
ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star`
pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w))) `equiv`
(ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star`
ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star`
pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w)))) by (FStar.Tactics.norm [delta_attr [`%__steel_reduce__]]; canon' false (`true_p) (`true_p));
reveal_equiv
(ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star`
ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star`
pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w)))
(ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star`
ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star`
pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w)));
assert (interp (hp_of (lock_inv_pred r r2 r1 (snd w, fst w))) m);
intro_h_exists (snd w, fst w) (fun x -> hp_of (lock_inv_pred r r2 r1 x)) m;
assert (interp (Steel.Memory.h_exists (fun x -> hp_of (lock_inv_pred r r2 r1 x))) m);
assert (
Steel.Memory.h_exists #(int & int) (fun x -> hp_of (lock_inv_pred r r2 r1 x)) ==
h_exists_sl #(int & int) (lock_inv_pred r r2 r1))
by (FStar.Tactics.norm [delta_only [`%h_exists_sl]])
in
reveal_equiv (lock_inv r r1 r2) (lock_inv r r2 r1)
#pop-options
/// Acquiring the shared lock invariant
inline_for_extraction noextract
let og_acquire (r:ref int) (r_mine r_other:ghost_ref int) (b:G.erased bool)
(l:lock (lock_inv r (if b then r_mine else r_other)
(if b then r_other else r_mine)))
: SteelT unit
emp
(fun _ -> lock_inv r r_mine r_other)
= acquire l;
if b then begin
rewrite_slprop (lock_inv r (if b then r_mine else r_other)
(if b then r_other else r_mine))
(lock_inv r r_mine r_other)
(fun _ -> ());
()
end
else begin
rewrite_slprop (lock_inv r (if b then r_mine else r_other)
(if b then r_other else r_mine))
(lock_inv r r_other r_mine)
(fun _ -> ());
lock_inv_equiv_lemma r r_other r_mine;
rewrite_slprop (lock_inv r r_other r_mine) (lock_inv r r_mine r_other) (fun _ -> reveal_equiv (lock_inv r r_other r_mine) (lock_inv r r_mine r_other))
end
/// Releasing the shared lock invariant
inline_for_extraction noextract
let og_release (r:ref int) (r_mine r_other:ghost_ref int) (b:G.erased bool)
(l:lock (lock_inv r (if b then r_mine else r_other)
(if b then r_other else r_mine)))
: SteelT unit
(lock_inv r r_mine r_other)
(fun _ -> emp)
= if b then begin
rewrite_slprop (lock_inv r r_mine r_other)
(lock_inv r (if b then r_mine else r_other)
(if b then r_other else r_mine))
(fun _ -> ());
()
end
else begin
lock_inv_equiv_lemma r r_mine r_other;
rewrite_slprop (lock_inv r r_mine r_other) (lock_inv r r_other r_mine) (fun _ -> reveal_equiv (lock_inv r r_mine r_other) (lock_inv r r_other r_mine));
rewrite_slprop (lock_inv r r_other r_mine)
(lock_inv r (if b then r_mine else r_other)
(if b then r_other else r_mine))
(fun _ -> ())
end;
release l | {
"checked_file": "/",
"dependencies": [
"Steel.SpinLock.fsti.checked",
"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.Tactics.Effect.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OWGCounter.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.Effect.Atomic",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Steel.Reference",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.SpinLock",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"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": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Steel.Reference.ref Prims.int -> Steel.Effect.SteelT Prims.unit | Steel.Effect.SteelT | [] | [] | [
"FStar.Ghost.erased",
"Prims.int",
"Steel.Reference.ref",
"Steel.Effect.Atomic.rewrite_slprop",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.Reference.pts_to",
"Steel.FractionalPermission.full_perm",
"Prims.op_Addition",
"FStar.Ghost.reveal",
"Steel.Memory.mem",
"Prims.unit",
"Steel.Reference.write_pt",
"Steel.Reference.read_pt",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let incr_ctr (#v: G.erased int) (r: ref int)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm (v + 1)) =
| let n = R.read_pt r in
R.write_pt r (n + 1);
rewrite_slprop (pts_to r full_perm (n + 1)) (pts_to r full_perm (v + 1)) (fun _ -> ()) | false |
LowParseWriters.fst | LowParseWriters.return_impl | val return_impl
(a:Type) (x:a) (r: parser)
(l: memory_invariant)
: Tot (repr_impl a (r) r _ _ _ l (return_spec a x r)) | val return_impl
(a:Type) (x:a) (r: parser)
(l: memory_invariant)
: Tot (repr_impl a (r) r _ _ _ l (return_spec a x r)) | let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1 | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 232,
"start_col": 0,
"start_line": 230
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | a: Type -> x: a -> r: LowParseWriters.LowParse.parser -> l: LowParseWriters.memory_invariant
-> LowParseWriters.repr_impl a
r
r
(fun _ -> Prims.l_True)
(fun v_in x' v_out -> x' == x /\ v_out == v_in)
(fun _ -> Prims.l_False)
l
(LowParseWriters.return_spec a x r) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.ICorrect",
"LowParseWriters.iresult"
] | [] | false | false | false | false | false | let return_impl a x r l =
| fun b len pos1 -> ICorrect x pos1 | false |
LowParseWriters.fst | LowParseWriters.access_spec | val access_spec
(#p1 #p2: parser)
(#lens: clens (Parser?.t p1) (Parser?.t p2))
(#inv: memory_invariant)
(g: gaccessor p1 p2 lens)
(x: ptr p1 inv)
: Ghost (ptr p2 inv)
(requires (lens.clens_cond (deref_spec x)))
(ensures (fun res -> deref_spec res == lens.clens_get (deref_spec x))) | val access_spec
(#p1 #p2: parser)
(#lens: clens (Parser?.t p1) (Parser?.t p2))
(#inv: memory_invariant)
(g: gaccessor p1 p2 lens)
(x: ptr p1 inv)
: Ghost (ptr p2 inv)
(requires (lens.clens_cond (deref_spec x)))
(ensures (fun res -> deref_spec res == lens.clens_get (deref_spec x))) | let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' } | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 41,
"end_line": 133,
"start_col": 0,
"start_line": 129
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | g: LowParseWriters.LowParse.gaccessor p1 p2 lens -> x: LowParseWriters.ptr p1 inv
-> Prims.Ghost (LowParseWriters.ptr p2 inv) | Prims.Ghost | [] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.LowParse.clens",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.gaccessor",
"LowParseWriters.ptr",
"LowParseWriters.Mkrptr",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.LowParse.u8",
"LowStar.Buffer.trivial_preorder",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.gaccess",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowParseWriters.__proj__Mkrptr__item__rptr_base"
] | [] | false | false | false | false | false | let access_spec #p1 #p2 #lens #inv g x =
| let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' } | false |
LowParseWriters.fst | LowParseWriters.buffer_of_ptr | val buffer_of_ptr
(#p: parser)
(#inv: memory_invariant)
(x: ptr p inv)
: Tot (bl: (B.buffer u8 & U32.t) {
let (b, len) = bl in
B.len b == len /\
valid_buffer p inv.h0 b /\
inv.lwrite `B.loc_disjoint` B.loc_buffer b /\
deref_spec x == buffer_contents p inv.h0 b
}) | val buffer_of_ptr
(#p: parser)
(#inv: memory_invariant)
(x: ptr p inv)
: Tot (bl: (B.buffer u8 & U32.t) {
let (b, len) = bl in
B.len b == len /\
valid_buffer p inv.h0 b /\
inv.lwrite `B.loc_disjoint` B.loc_buffer b /\
deref_spec x == buffer_contents p inv.h0 b
}) | let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 116,
"start_col": 0,
"start_line": 113
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.ptr p inv
-> bl:
(LowStar.Buffer.buffer LowParseWriters.LowParse.u8 * FStar.UInt32.t)
{ let _ = bl in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ b len = _ in
LowStar.Monotonic.Buffer.len b == len /\
LowParseWriters.LowParse.valid_buffer p
(FStar.Ghost.reveal (Mkmemory_invariant?.h0 inv))
b /\
LowStar.Monotonic.Buffer.loc_disjoint (FStar.Ghost.reveal (Mkmemory_invariant?.lwrite inv)
)
(LowStar.Monotonic.Buffer.loc_buffer b) /\
LowParseWriters.deref_spec x ==
LowParseWriters.LowParse.buffer_contents p
(FStar.Ghost.reveal (Mkmemory_invariant?.h0 inv))
b)
<:
Type0 } | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowParseWriters.ptr",
"FStar.Pervasives.Native.Mktuple2",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"FStar.UInt32.t",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"LowParseWriters.__proj__Mkrptr__item__rptr_len",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"LowParseWriters.LowParse.valid_buffer",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.deref_spec",
"LowParseWriters.LowParse.buffer_contents"
] | [] | false | false | false | false | false | let buffer_of_ptr #p #inv x =
| (x.rptr_base, x.rptr_len) | false |
LowParseWriters.fst | LowParseWriters.valid_rptr_frame | val valid_rptr_frame
(#p: parser) (#inv: memory_invariant) (x: ptr p inv) (inv' : memory_invariant)
: Lemma
(requires (
inv `memory_invariant_includes` inv'
))
(ensures (
valid_rptr p inv' x /\
deref_spec #p #inv' x == deref_spec #p #inv x
))
[SMTPatOr [
[SMTPat (inv `memory_invariant_includes` inv'); SMTPat (valid_rptr p inv x)];
[SMTPat (inv `memory_invariant_includes` inv'); SMTPat (valid_rptr p inv' x)];
]] | val valid_rptr_frame
(#p: parser) (#inv: memory_invariant) (x: ptr p inv) (inv' : memory_invariant)
: Lemma
(requires (
inv `memory_invariant_includes` inv'
))
(ensures (
valid_rptr p inv' x /\
deref_spec #p #inv' x == deref_spec #p #inv x
))
[SMTPatOr [
[SMTPat (inv `memory_invariant_includes` inv'); SMTPat (valid_rptr p inv x)];
[SMTPat (inv `memory_invariant_includes` inv'); SMTPat (valid_rptr p inv' x)];
]] | let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0 | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 77,
"end_line": 120,
"start_col": 0,
"start_line": 118
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.ptr p inv -> inv': LowParseWriters.memory_invariant
-> FStar.Pervasives.Lemma (requires LowParseWriters.memory_invariant_includes inv inv')
(ensures
LowParseWriters.valid_rptr p inv' x /\
LowParseWriters.deref_spec x == LowParseWriters.deref_spec x)
[
SMTPatOr [
[
SMTPat (LowParseWriters.memory_invariant_includes inv inv');
SMTPat (LowParseWriters.valid_rptr p inv x)
];
[
SMTPat (LowParseWriters.memory_invariant_includes inv inv');
SMTPat (LowParseWriters.valid_rptr p inv' x)
]
]
] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.memory_invariant",
"LowParseWriters.ptr",
"LowParseWriters.LowParse.valid_frame",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.len",
"FStar.UInt8.t",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"Prims.unit"
] | [] | true | false | true | false | false | let valid_rptr_frame #p #inv x inv' =
| valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0 | false |
LowParseWriters.fst | LowParseWriters.valid_frame' | val valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h': HS.mem)
(pos': U32.t)
: Lemma
((B.live h b /\ (valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\ B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')) ==>
(valid_pos p h b pos pos' /\ valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos')) | val valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h': HS.mem)
(pos': U32.t)
: Lemma
((B.live h b /\ (valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\ B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')) ==>
(valid_pos p h b pos pos' /\ valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos')) | let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h' | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 59,
"end_line": 176,
"start_col": 0,
"start_line": 157
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.LowParse.parser ->
h: FStar.Monotonic.HyperStack.mem ->
b: LowStar.Buffer.buffer FStar.UInt8.t ->
pos: FStar.UInt32.t ->
l: LowStar.Monotonic.Buffer.loc ->
h': FStar.Monotonic.HyperStack.mem ->
pos': FStar.UInt32.t
-> FStar.Pervasives.Lemma
(ensures
LowStar.Monotonic.Buffer.live h b /\
(LowParseWriters.LowParse.valid_pos p h b pos pos' \/
LowParseWriters.LowParse.valid_pos p h' b pos pos') /\
LowStar.Monotonic.Buffer.modifies l h h' /\
LowStar.Monotonic.Buffer.loc_disjoint l
(LowStar.Monotonic.Buffer.loc_buffer_from_to b pos pos') ==>
LowParseWriters.LowParse.valid_pos p h b pos pos' /\
LowParseWriters.LowParse.valid_pos p h' b pos pos' /\
LowParseWriters.LowParse.contents p h' b pos pos' ==
LowParseWriters.LowParse.contents p h b pos pos') | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParseWriters.LowParse.parser",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Buffer.buffer",
"FStar.UInt8.t",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.loc",
"FStar.Classical.move_requires",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Buffer.trivial_preorder",
"Prims.l_or",
"LowParseWriters.LowParse.valid_pos",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer_from_to",
"Prims.eq2",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.LowParse.contents",
"LowParseWriters.LowParse.valid_frame",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_imp",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h': HS.mem)
(pos': U32.t)
: Lemma
((B.live h b /\ (valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\ B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')) ==>
(valid_pos p h b pos pos' /\ valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos')) =
| Classical.move_requires (valid_frame p h b pos pos' l) h' | false |
LowParseWriters.fst | LowParseWriters.mk_repr_impl | val mk_repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
(impl: (
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
))
: Tot (repr_impl a r_in r_out pre post post_err l spec) | val mk_repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
(impl: (
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
))
: Tot (repr_impl a r_in r_out pre post post_err l spec) | let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 6,
"end_line": 222,
"start_col": 0,
"start_line": 219
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
r_in: LowParseWriters.LowParse.parser ->
r_out: LowParseWriters.LowParse.parser ->
pre: LowParseWriters.pre_t r_in ->
post: LowParseWriters.post_t a r_in r_out pre ->
post_err: LowParseWriters.post_err_t r_in pre ->
l: LowParseWriters.memory_invariant ->
spec: LowParseWriters.repr_spec a r_in r_out pre post post_err ->
impl:
(
b:
LowStar.Buffer.buffer LowParseWriters.LowParse.u8
{ LowStar.Monotonic.Buffer.loc_includes (FStar.Ghost.reveal (Mkmemory_invariant?.lwrite
l))
(LowStar.Monotonic.Buffer.loc_buffer b) } ->
len: FStar.UInt32.t{len == LowStar.Monotonic.Buffer.len b} ->
pos1: LowParseWriters.buffer_offset b
-> FStar.HyperStack.ST.Stack (LowParseWriters.iresult a))
-> LowParseWriters.repr_impl a r_in r_out pre post post_err l spec | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.memory_invariant",
"LowParseWriters.repr_spec",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.iresult",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"Prims.b2t",
"FStar.Monotonic.HyperHeap.includes",
"FStar.Monotonic.HyperStack.get_tip",
"LowParseWriters.LowParse.valid_pos",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.LowParse.contents",
"LowParseWriters.repr_impl_post",
"LowParseWriters.repr_impl"
] | [] | false | false | false | false | false | let mk_repr_impl a r_in r_out pre post post_err l spec impl =
| impl | false |
LowParseWriters.fst | LowParseWriters.access_impl | val access_impl
(#p1 #p2: parser)
(#lens: clens (Parser?.t p1) (Parser?.t p2))
(#inv: memory_invariant)
(#g: gaccessor p1 p2 lens)
(a: accessor g)
(x: ptr p1 inv)
: Tot (read_repr_impl (ptr p2 inv) (lens.clens_cond (deref_spec x)) (fun res -> lens.clens_cond (deref_spec x) /\ deref_spec res == lens.clens_get (deref_spec x)) (fun _ -> False) inv (fun _ -> Correct (access_spec g x))) | val access_impl
(#p1 #p2: parser)
(#lens: clens (Parser?.t p1) (Parser?.t p2))
(#inv: memory_invariant)
(#g: gaccessor p1 p2 lens)
(a: accessor g)
(x: ptr p1 inv)
: Tot (read_repr_impl (ptr p2 inv) (lens.clens_cond (deref_spec x)) (fun res -> lens.clens_cond (deref_spec x) /\ deref_spec res == lens.clens_get (deref_spec x)) (fun _ -> False) inv (fun _ -> Correct (access_spec g x))) | let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' }) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 145,
"start_col": 0,
"start_line": 135
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | a: LowParseWriters.LowParse.accessor g -> x: LowParseWriters.ptr p1 inv
-> LowParseWriters.read_repr_impl (LowParseWriters.ptr p2 inv)
(Mkclens?.clens_cond lens (LowParseWriters.deref_spec x))
(fun res ->
Mkclens?.clens_cond lens (LowParseWriters.deref_spec x) /\
LowParseWriters.deref_spec res == Mkclens?.clens_get lens (LowParseWriters.deref_spec x))
(fun _ -> Prims.l_False)
inv
(fun _ -> LowParseWriters.Correct (LowParseWriters.access_spec g x)) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.LowParse.clens",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.gaccessor",
"LowParseWriters.LowParse.accessor",
"LowParseWriters.ptr",
"Prims.unit",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"FStar.UInt32.t",
"LowParseWriters.Correct",
"LowParseWriters.Mkrptr",
"LowParseWriters.LowParse.gaccessor_frame",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowParseWriters.result",
"FStar.HyperStack.ST.get",
"FStar.Pervasives.Native.tuple2",
"LowParseWriters.LowParse.baccess",
"LowParseWriters.__proj__Mkrptr__item__rptr_len",
"LowParseWriters.LowParse.valid_frame",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.len",
"FStar.UInt8.t",
"LowStar.Buffer.trivial_preorder"
] | [] | false | false | false | false | false | let access_impl #p1 #p2 #lens #inv #g a x =
| fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let base', len' = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' }) | false |
Steel.ST.CancellableSpinLock.fst | Steel.ST.CancellableSpinLock.acquire | val acquire (#v:vprop) (c:cancellable_lock v)
: STT bool emp (fun b -> maybe_acquired b c) | val acquire (#v:vprop) (c:cancellable_lock v)
: STT bool emp (fun b -> maybe_acquired b c) | let acquire #v c =
acquire c.llock;
let b_erased = elim_exists () in
let b = read c.lref in
if b
then begin
rewrite (if b_erased then v else emp) v;
rewrite (v `star` can_release c)
(maybe_acquired b c)
end
else begin
intro_exists (G.reveal b_erased) (lock_inv_pred c.lref v);
release c.llock;
rewrite emp (maybe_acquired b c)
end;
return b | {
"file_name": "lib/steel/Steel.ST.CancellableSpinLock.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 10,
"end_line": 66,
"start_col": 0,
"start_line": 51
} | (*
Copyright 2021 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.
Author: Aseem Rastogi
*)
module Steel.ST.CancellableSpinLock
open Steel.ST.Effect
open Steel.ST.Util
open Steel.FractionalPermission
open Steel.ST.Reference
open Steel.ST.SpinLock
module G = FStar.Ghost
[@@__reduce__]
let lock_inv_pred (r:ref bool) (v:vprop) : bool -> vprop =
fun b -> pts_to r full_perm b `star` (if b then v else emp)
[@@__reduce__]
let lock_inv (r:ref bool) (v:vprop) : vprop = exists_ (lock_inv_pred r v)
noeq
type cancellable_lock (v:vprop) = {
lref : ref bool;
llock : lock (lock_inv lref v)
}
let new_cancellable_lock v =
let r = alloc true in
intro_exists true (lock_inv_pred r v);
let l = new_lock (lock_inv r v) in
return ({lref = r; llock = l})
[@__reduce__]
let can_release #v c = pts_to c.lref full_perm true | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.SpinLock.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.CancellableSpinLock.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Steel.ST.SpinLock",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"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 | c: Steel.ST.CancellableSpinLock.cancellable_lock v -> Steel.ST.Effect.STT Prims.bool | Steel.ST.Effect.STT | [] | [] | [
"Steel.Effect.Common.vprop",
"Steel.ST.CancellableSpinLock.cancellable_lock",
"Steel.ST.Util.return",
"Prims.bool",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.ST.CancellableSpinLock.maybe_acquired",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.star",
"Steel.ST.CancellableSpinLock.can_release",
"FStar.Ghost.reveal",
"Steel.Effect.Common.emp",
"Steel.ST.SpinLock.release",
"Steel.ST.CancellableSpinLock.lock_inv",
"Steel.ST.CancellableSpinLock.__proj__Mkcancellable_lock__item__lref",
"Steel.ST.CancellableSpinLock.__proj__Mkcancellable_lock__item__llock",
"Steel.ST.Util.intro_exists",
"Steel.ST.CancellableSpinLock.lock_inv_pred",
"Steel.ST.Reference.read",
"Steel.FractionalPermission.full_perm",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.Effect.Common.VStar",
"Steel.ST.Reference.pts_to",
"Steel.ST.SpinLock.acquire"
] | [] | false | true | false | false | false | let acquire #v c =
| acquire c.llock;
let b_erased = elim_exists () in
let b = read c.lref in
if b
then
(rewrite (if b_erased then v else emp) v;
rewrite (v `star` (can_release c)) (maybe_acquired b c))
else
(intro_exists (G.reveal b_erased) (lock_inv_pred c.lref v);
release c.llock;
rewrite emp (maybe_acquired b c));
return b | false |
LowParseWriters.fst | LowParseWriters.buffer_sub_impl | val buffer_sub_impl
(#t: Type)
(inv: memory_invariant)
(b: B.buffer t)
(i: U32.t)
(len: Ghost.erased U32.t)
: Tot (read_repr_impl _ _ _ _ inv (buffer_sub_spec inv b i len)) | val buffer_sub_impl
(#t: Type)
(inv: memory_invariant)
(b: B.buffer t)
(i: U32.t)
(len: Ghost.erased U32.t)
: Tot (read_repr_impl _ _ _ _ inv (buffer_sub_spec inv b i len)) | let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 87,
"start_col": 0,
"start_line": 84
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
inv: LowParseWriters.memory_invariant ->
b: LowStar.Buffer.buffer t ->
i: FStar.UInt32.t ->
len: FStar.Ghost.erased FStar.UInt32.t
-> LowParseWriters.read_repr_impl (LowStar.Buffer.buffer t)
(LowStar.Monotonic.Buffer.live (FStar.Ghost.reveal (Mkmemory_invariant?.h0 inv)) b /\
LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_buffer b)
(FStar.Ghost.reveal (Mkmemory_invariant?.lwrite inv)) /\
FStar.UInt32.v i + FStar.UInt32.v (FStar.Ghost.reveal len) <=
LowStar.Monotonic.Buffer.length b)
(fun res ->
FStar.UInt32.v i + FStar.UInt32.v (FStar.Ghost.reveal len) <=
LowStar.Monotonic.Buffer.length b /\
res == LowStar.Buffer.gsub b i (FStar.Ghost.reveal len) /\
LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_buffer res)
(FStar.Ghost.reveal (Mkmemory_invariant?.lwrite inv)))
(fun _ -> Prims.l_False)
inv
(LowParseWriters.buffer_sub_spec inv b i len) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"FStar.UInt32.t",
"FStar.Ghost.erased",
"Prims.unit",
"LowParseWriters.Correct",
"LowParseWriters.result",
"LowStar.Buffer.sub",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder"
] | [] | false | false | false | false | false | let buffer_sub_impl #t inv b i len =
| fun _ -> Correct (B.sub b i len) | false |
Selectors.LList2.fst | Selectors.LList2.llist_of_llist0 | val llist_of_llist0 (#opened: _) (#a: Type) (r: t a)
: SteelGhost unit
opened
(llist0 r)
(fun _ -> llist r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist r) == h0 (llist0 r)) | val llist_of_llist0 (#opened: _) (#a: Type) (r: t a)
: SteelGhost unit
opened
(llist0 r)
(fun _ -> llist r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist r) == h0 (llist0 r)) | let llist_of_llist0
(#opened: _)
(#a: Type)
(r: t a)
: SteelGhost unit opened
(llist0 r)
(fun _ -> llist r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist r) == h0 (llist0 r))
=
change_slprop_rel
(llist0 r)
(llist r)
(fun x y -> x == y)
(fun _ -> ()) | {
"file_name": "share/steel/examples/steel/Selectors.LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 17,
"end_line": 209,
"start_col": 0,
"start_line": 195
} | module Selectors.LList2
open Steel.FractionalPermission
module Mem = Steel.Memory
#push-options "--__no_positivity"
noeq
type cell (a: Type0) = {
tail_fuel: Ghost.erased nat;
next: ref (cell a);
data: a;
}
#pop-options
let next #a (c:cell a) : t a = c.next
let data #a (c:cell a) : a = c.data
let mk_cell #a (n: t a) (d:a) = {
tail_fuel = Ghost.hide 0;
next = n;
data = d
}
let null_llist #a = null
let is_null #a ptr = is_null ptr
let v_null_rewrite
(a: Type0)
(_: t_of emp)
: GTot (list a)
= []
let v_c
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: GTot prop
= (Ghost.reveal c.tail_fuel < Ghost.reveal n) == true // to ensure vprop termination
let v_c_dep
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(c: normal (t_of (vrefine (vptr r) (v_c n r))))
: Tot vprop
= nllist c.tail_fuel c.next
let v_c_l_rewrite
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(res: normal (t_of ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r nllist)))
: Tot (list a)
= let (| c, l |) = res in
c.data :: l
let rec nllist
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
(decreases (Ghost.reveal n))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
let nllist_eq_not_null
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Lemma
(requires (is_null r == false))
(ensures (
nllist a n r == ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
))
= assert_norm (nllist a n r ==
begin if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
end
)
let llist_vdep
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: Tot vprop
= nllist a c.tail_fuel c.next
let llist_vrewrite
(#a: Type0)
(r: t a)
(cl: normal (t_of (vptr r `vdep` llist_vdep r)))
: GTot (list a)
= (dfst cl).data :: dsnd cl
let llist0
(#a: Type0)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else (vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r
let nllist_of_llist0
(#opened: _)
(#a: Type0)
(r: t a)
: SteelGhost (Ghost.erased nat) opened
(llist0 r)
(fun res -> nllist a res r)
(fun _ -> True)
(fun h0 res h1 ->
h0 (llist0 r) == h1 (nllist a res r)
)
=
if is_null r
then begin
let res = Ghost.hide 0 in
change_equal_slprop
(llist0 r)
(nllist a res r);
res
end else begin
change_equal_slprop
(llist0 r)
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r);
elim_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
let gk : normal (Ghost.erased (t_of (vptr r))) = elim_vdep (vptr r) (llist_vdep r) in
let res = Ghost.hide (Ghost.reveal (Ghost.reveal gk).tail_fuel + 1) in
intro_vrefine (vptr r) (v_c res r);
intro_vdep
(vptr r `vrefine` v_c res r)
(llist_vdep r (Ghost.reveal gk))
(v_c_dep res r (nllist a));
intro_vrewrite ((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) (v_c_l_rewrite res r (nllist a));
nllist_eq_not_null a res r;
change_equal_slprop
(((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) `vrewrite` v_c_l_rewrite res r (nllist a))
(nllist a res r);
res
end
let llist0_of_nllist
(#opened: _)
(#a: Type0)
(n: Ghost.erased nat)
(r: t a)
: SteelGhost unit opened
(nllist a n r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 res h1 ->
h1 (llist0 r) == h0 (nllist a n r)
)
=
if is_null r
then begin
change_equal_slprop
(nllist a n r)
(llist0 r);
()
end else begin
nllist_eq_not_null a n r;
change_equal_slprop
(nllist a n r)
(((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a));
elim_vrewrite ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) (v_c_l_rewrite n r (nllist a));
let gk = elim_vdep (vptr r `vrefine` v_c n r) (v_c_dep n r (nllist a)) in
elim_vrefine (vptr r) (v_c n r);
intro_vdep
(vptr r)
(v_c_dep n r (nllist a) (Ghost.reveal gk))
(llist_vdep r);
intro_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
change_equal_slprop
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r)
(llist0 r)
end
let llist_sl
#a r
= hp_of (llist0 r)
let llist_sel
#a r
= fun m -> sel_of (llist0 r) m // eta necessary because sel_of is GTot | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Selectors.LList2.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"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": "Selectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Selectors",
"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 | r: Selectors.LList2.t a -> Steel.Effect.Atomic.SteelGhost Prims.unit | Steel.Effect.Atomic.SteelGhost | [] | [] | [
"Steel.Memory.inames",
"Selectors.LList2.t",
"Steel.Effect.Atomic.change_slprop_rel",
"Selectors.LList2.llist0",
"Selectors.LList2.llist",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Prims.eq2",
"Prims.prop",
"Steel.Memory.mem",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_True"
] | [] | false | true | false | false | false | let llist_of_llist0 (#opened: _) (#a: Type) (r: t a)
: SteelGhost unit
opened
(llist0 r)
(fun _ -> llist r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist r) == h0 (llist0 r)) =
| change_slprop_rel (llist0 r) (llist r) (fun x y -> x == y) (fun _ -> ()) | false |
LowParseWriters.fst | LowParseWriters.extract_repr_impl | val extract_repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
(impl: repr_impl a r_in r_out pre post post_err l spec)
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b })
(len: U32.t { len == B.len b })
(pos1: buffer_offset b)
: HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
)) | val extract_repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
(impl: repr_impl a r_in r_out pre post post_err l spec)
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b })
(len: U32.t { len == B.len b })
(pos1: buffer_offset b)
: HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
)) | let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 6,
"end_line": 227,
"start_col": 0,
"start_line": 224
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
r_in: LowParseWriters.LowParse.parser ->
r_out: LowParseWriters.LowParse.parser ->
pre: LowParseWriters.pre_t r_in ->
post: LowParseWriters.post_t a r_in r_out pre ->
post_err: LowParseWriters.post_err_t r_in pre ->
l: LowParseWriters.memory_invariant ->
spec: LowParseWriters.repr_spec a r_in r_out pre post post_err ->
impl: LowParseWriters.repr_impl a r_in r_out pre post post_err l spec ->
b:
LowStar.Buffer.buffer LowParseWriters.LowParse.u8
{ LowStar.Monotonic.Buffer.loc_includes (FStar.Ghost.reveal (Mkmemory_invariant?.lwrite l))
(LowStar.Monotonic.Buffer.loc_buffer b) } ->
len: FStar.UInt32.t{len == LowStar.Monotonic.Buffer.len b} ->
pos1: LowParseWriters.buffer_offset b
-> FStar.HyperStack.ST.Stack (LowParseWriters.iresult a) | FStar.HyperStack.ST.Stack | [] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.memory_invariant",
"LowParseWriters.repr_spec",
"LowParseWriters.repr_impl",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.iresult",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"Prims.b2t",
"FStar.Monotonic.HyperHeap.includes",
"FStar.Monotonic.HyperStack.get_tip",
"LowParseWriters.LowParse.valid_pos",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.LowParse.contents",
"LowParseWriters.repr_impl_post"
] | [] | false | true | false | false | false | let extract_repr_impl a r_in r_out pre post post_err l spec impl =
| impl | false |
LowParseWriters.fst | LowParseWriters.validate_impl | val validate_impl
(#p: parser)
(v: validator p)
(inv: memory_invariant)
(b: B.buffer U8.t)
(len: U32.t { B.len b == len })
: Tot (read_repr_impl _ _ _ _ inv (validate_spec p inv b)) | val validate_impl
(#p: parser)
(v: validator p)
(inv: memory_invariant)
(b: B.buffer U8.t)
(len: U32.t { B.len b == len })
: Tot (read_repr_impl _ _ _ _ inv (validate_spec p inv b)) | let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 193,
"start_col": 0,
"start_line": 178
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
v: LowParseWriters.LowParse.validator p ->
inv: LowParseWriters.memory_invariant ->
b: LowStar.Buffer.buffer FStar.UInt8.t ->
len: FStar.UInt32.t{LowStar.Monotonic.Buffer.len b == len}
-> LowParseWriters.read_repr_impl (LowParseWriters.ptr p inv * FStar.UInt32.t)
(LowParseWriters.validate_pre inv b)
(LowParseWriters.validate_post p inv b)
(LowParseWriters.validate_post_err p inv b)
inv
(LowParseWriters.validate_spec p inv b) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.LowParse.validator",
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"FStar.UInt8.t",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"Prims.unit",
"LowParseWriters.Error",
"FStar.Pervasives.Native.tuple2",
"LowParseWriters.ptr",
"LowParseWriters.result",
"LowParseWriters.Correct",
"FStar.Pervasives.Native.Mktuple2",
"LowParseWriters.rptr",
"LowParseWriters.Mkrptr",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.sub",
"FStar.UInt32.__uint_to_t",
"FStar.Ghost.hide",
"LowParseWriters.LowParse.gvalidate_frame",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.l_or",
"LowParseWriters.LowParse.valid_pos",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer_from_to",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.LowParse.contents",
"LowParseWriters.valid_frame'",
"FStar.HyperStack.ST.get",
"FStar.Pervasives.Native.option",
"LowParseWriters.LowParse.bvalidate"
] | [] | false | false | false | false | false | let validate_impl #p v inv b len =
| fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b'; rptr_len = pos } in
Correct (x, pos) | false |
Metaprogramming.fst | Metaprogramming.my_int | val my_int:int | val my_int:int | let my_int : int = _ by (exact (quote 42)) | {
"file_name": "examples/tactics/eci19/Metaprogramming.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 13,
"start_col": 0,
"start_line": 13
} | module Metaprogramming
open FStar.Tactics.V2
(*
Now, we shall turn to the automated generation of programs. Meta-F*
enables this in much the same way that it allows handling proofs: it
provides the user with a proofstate, a set of hypotheses and goals, and
one uses primitives to solve them. The way to call Meta-F* for metaprogramming
is the `_ by tau` syntax, as in the following:
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Metaprogramming.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"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 | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let my_int:int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ -> (exact (quote 42))) | false |
Metaprogramming.fst | Metaprogramming.fancy_id | val fancy_id (x: int) : int | val fancy_id (x: int) : int | let fancy_id : x:int -> int = _ by (let x = intro () in
exact (binding_to_term x)) | {
"file_name": "examples/tactics/eci19/Metaprogramming.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 70,
"start_col": 0,
"start_line": 69
} | module Metaprogramming
open FStar.Tactics.V2
(*
Now, we shall turn to the automated generation of programs. Meta-F*
enables this in much the same way that it allows handling proofs: it
provides the user with a proofstate, a set of hypotheses and goals, and
one uses primitives to solve them. The way to call Meta-F* for metaprogramming
is the `_ by tau` syntax, as in the following:
*)
let my_int : int = _ by (exact (quote 42))
(*
In the fragment above, F* infers that the `_` must have type `int` (from
the annotation of `my_int`), and generates a proof state with a single
`int` goal. If you dump the initial proof state, you'll see something
like this:
Goal 1/1
--------------------------------------------------------------------------------
int
(*?u35*) _
Then, we solve this goal with the `exact` primitive
val exact : term -> Tac unit
`exact` takes a term and attempts to solve the current goal with it. In
this case, it succeeds and the original `_` is solved to `42`. If you
print the definition of `my_int` there will be no mention of the tactic,
it will have been run already.
Exercise: try to solve the goal with a type-incorrect solution, for
example `true`.
Here there is a key difference the kind of goals that appeared before.
For proving, we start with an *irrelevant* (i.e. squashed) goal, where a
proof term is not strictly needed. Indeed, we can simply send irrelevant
goals to the SMT solver. On the other hand, in metaprogramming, the goal
is usually relevant and a fully-defined term, in this case an integer,
is needed.
Exercise: instead of using `exact`, try sending this goal to the SMT
solver, or not solving it somehow (it should fail!).
*)
(*
Instead of solving a goal outright with a solution, other primitives
allow to build terms incrementally. For instance, `apply f` solves the
goal to an application of `f` to some arguments (as many as needed), and
presents new goals for each argument. *)
let metasum : int = _ by (apply (quote (+));
// dump ""; // You should see two new goals here!
exact (`13);
exact (`29))
(* Exercise: print the definition of metasum *)
(* We can also construct functions via the `intro` primitive. Calling
`intro` when the current goal is of type `a -> b` will solve it with
`fun x -> ?`, while presenting a new goal for the `?`, of at type `b`.
A `binder` for `x` is returned by intro, so it can be used to construct
the new solution. *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Metaprogramming.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"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: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int"
] | [] | false | false | false | true | false | let fancy_id: x: int -> int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ ->
(let x = intro () in
exact (binding_to_term x))) | false |
Metaprogramming.fst | Metaprogramming.metasum | val metasum:int | val metasum:int | let metasum : int = _ by (apply (quote (+));
// dump ""; // You should see two new goals here!
exact (`13);
exact (`29)) | {
"file_name": "examples/tactics/eci19/Metaprogramming.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 59,
"start_col": 0,
"start_line": 56
} | module Metaprogramming
open FStar.Tactics.V2
(*
Now, we shall turn to the automated generation of programs. Meta-F*
enables this in much the same way that it allows handling proofs: it
provides the user with a proofstate, a set of hypotheses and goals, and
one uses primitives to solve them. The way to call Meta-F* for metaprogramming
is the `_ by tau` syntax, as in the following:
*)
let my_int : int = _ by (exact (quote 42))
(*
In the fragment above, F* infers that the `_` must have type `int` (from
the annotation of `my_int`), and generates a proof state with a single
`int` goal. If you dump the initial proof state, you'll see something
like this:
Goal 1/1
--------------------------------------------------------------------------------
int
(*?u35*) _
Then, we solve this goal with the `exact` primitive
val exact : term -> Tac unit
`exact` takes a term and attempts to solve the current goal with it. In
this case, it succeeds and the original `_` is solved to `42`. If you
print the definition of `my_int` there will be no mention of the tactic,
it will have been run already.
Exercise: try to solve the goal with a type-incorrect solution, for
example `true`.
Here there is a key difference the kind of goals that appeared before.
For proving, we start with an *irrelevant* (i.e. squashed) goal, where a
proof term is not strictly needed. Indeed, we can simply send irrelevant
goals to the SMT solver. On the other hand, in metaprogramming, the goal
is usually relevant and a fully-defined term, in this case an integer,
is needed.
Exercise: instead of using `exact`, try sending this goal to the SMT
solver, or not solving it somehow (it should fail!).
*)
(*
Instead of solving a goal outright with a solution, other primitives
allow to build terms incrementally. For instance, `apply f` solves the
goal to an application of `f` to some arguments (as many as needed), and
presents new goals for each argument. *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Metaprogramming.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"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 | Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.op_Addition"
] | [] | false | false | false | true | false | let metasum:int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ ->
(apply (quote ( + ));
exact (`13);
exact (`29))) | false |
Metaprogramming.fst | Metaprogramming.matchenum | val matchenum: enum -> int | val matchenum: enum -> int | let matchenum : enum -> int =
_ by (let x = intro () in
destruct (binding_to_term x);
ignore (intro ()); exact (`1);
ignore (intro ()); exact (`2);
ignore (intro ()); exact (`3)) | {
"file_name": "examples/tactics/eci19/Metaprogramming.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 104,
"start_col": 0,
"start_line": 99
} | module Metaprogramming
open FStar.Tactics.V2
(*
Now, we shall turn to the automated generation of programs. Meta-F*
enables this in much the same way that it allows handling proofs: it
provides the user with a proofstate, a set of hypotheses and goals, and
one uses primitives to solve them. The way to call Meta-F* for metaprogramming
is the `_ by tau` syntax, as in the following:
*)
let my_int : int = _ by (exact (quote 42))
(*
In the fragment above, F* infers that the `_` must have type `int` (from
the annotation of `my_int`), and generates a proof state with a single
`int` goal. If you dump the initial proof state, you'll see something
like this:
Goal 1/1
--------------------------------------------------------------------------------
int
(*?u35*) _
Then, we solve this goal with the `exact` primitive
val exact : term -> Tac unit
`exact` takes a term and attempts to solve the current goal with it. In
this case, it succeeds and the original `_` is solved to `42`. If you
print the definition of `my_int` there will be no mention of the tactic,
it will have been run already.
Exercise: try to solve the goal with a type-incorrect solution, for
example `true`.
Here there is a key difference the kind of goals that appeared before.
For proving, we start with an *irrelevant* (i.e. squashed) goal, where a
proof term is not strictly needed. Indeed, we can simply send irrelevant
goals to the SMT solver. On the other hand, in metaprogramming, the goal
is usually relevant and a fully-defined term, in this case an integer,
is needed.
Exercise: instead of using `exact`, try sending this goal to the SMT
solver, or not solving it somehow (it should fail!).
*)
(*
Instead of solving a goal outright with a solution, other primitives
allow to build terms incrementally. For instance, `apply f` solves the
goal to an application of `f` to some arguments (as many as needed), and
presents new goals for each argument. *)
let metasum : int = _ by (apply (quote (+));
// dump ""; // You should see two new goals here!
exact (`13);
exact (`29))
(* Exercise: print the definition of metasum *)
(* We can also construct functions via the `intro` primitive. Calling
`intro` when the current goal is of type `a -> b` will solve it with
`fun x -> ?`, while presenting a new goal for the `?`, of at type `b`.
A `binder` for `x` is returned by intro, so it can be used to construct
the new solution. *)
let fancy_id : x:int -> int = _ by (let x = intro () in
exact (binding_to_term x))
(* Exercise: look at the proof states and final solution of `fancy_id` *)
(* Exercise: write a `zero` tactic that solves any goal of type `a -> b
-> ... -> z -> int` with the constant zero function. It should pass the
following tests. *)
//let const () : Tac unit = ???
//
//let f1 : int = _ by (const ())
//let f2 : nat -> int = _ by (const ())
//let f3 : bool -> list int -> unit -> int = _ by (const ())
//let f4 : int -> int -> int -> int -> int = _ by (const ())
//
//let _ = assert (f1 == 0)
//let _ = assert (forall x. f2 x == 0)
//let _ = assert (forall x y z. f3 x y z == 0)
//let _ = assert (forall x y z w . f4 x y z w == 0)
(* We can also perform case analysis on inductive types by the `destruct` primitive`.
Essentially, the `destruct` tactic takes a term `t` that has some inductive type
and performs a `match` on it. Then, it returns goals for each of the possible
cases. In each case, we also get an hypothesis for the fact that
the term we destructed is equal to the given branch. We ignore those
hypotheses here by just `intro`ducing them. *)
type enum = | A | B | C | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Metaprogramming.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"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 | _: Metaprogramming.enum -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Metaprogramming.enum",
"Prims.int"
] | [] | false | false | false | true | false | let matchenum: enum -> int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ ->
(let x = intro () in
destruct (binding_to_term x);
ignore (intro ());
exact (`1);
ignore (intro ());
exact (`2);
ignore (intro ());
exact (`3))) | false |
Metaprogramming.fst | Metaprogramming.matcheither | val matcheither: either int int -> int | val matcheither: either int int -> int | let matcheither : either int int -> int =
_ by (let x = intro () in
destruct (binding_to_term x);
let x = intro() in ignore (intro ()); exact (binding_to_term x);
let y = intro() in ignore (intro ()); exact (binding_to_term y)) | {
"file_name": "examples/tactics/eci19/Metaprogramming.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 72,
"end_line": 115,
"start_col": 0,
"start_line": 111
} | module Metaprogramming
open FStar.Tactics.V2
(*
Now, we shall turn to the automated generation of programs. Meta-F*
enables this in much the same way that it allows handling proofs: it
provides the user with a proofstate, a set of hypotheses and goals, and
one uses primitives to solve them. The way to call Meta-F* for metaprogramming
is the `_ by tau` syntax, as in the following:
*)
let my_int : int = _ by (exact (quote 42))
(*
In the fragment above, F* infers that the `_` must have type `int` (from
the annotation of `my_int`), and generates a proof state with a single
`int` goal. If you dump the initial proof state, you'll see something
like this:
Goal 1/1
--------------------------------------------------------------------------------
int
(*?u35*) _
Then, we solve this goal with the `exact` primitive
val exact : term -> Tac unit
`exact` takes a term and attempts to solve the current goal with it. In
this case, it succeeds and the original `_` is solved to `42`. If you
print the definition of `my_int` there will be no mention of the tactic,
it will have been run already.
Exercise: try to solve the goal with a type-incorrect solution, for
example `true`.
Here there is a key difference the kind of goals that appeared before.
For proving, we start with an *irrelevant* (i.e. squashed) goal, where a
proof term is not strictly needed. Indeed, we can simply send irrelevant
goals to the SMT solver. On the other hand, in metaprogramming, the goal
is usually relevant and a fully-defined term, in this case an integer,
is needed.
Exercise: instead of using `exact`, try sending this goal to the SMT
solver, or not solving it somehow (it should fail!).
*)
(*
Instead of solving a goal outright with a solution, other primitives
allow to build terms incrementally. For instance, `apply f` solves the
goal to an application of `f` to some arguments (as many as needed), and
presents new goals for each argument. *)
let metasum : int = _ by (apply (quote (+));
// dump ""; // You should see two new goals here!
exact (`13);
exact (`29))
(* Exercise: print the definition of metasum *)
(* We can also construct functions via the `intro` primitive. Calling
`intro` when the current goal is of type `a -> b` will solve it with
`fun x -> ?`, while presenting a new goal for the `?`, of at type `b`.
A `binder` for `x` is returned by intro, so it can be used to construct
the new solution. *)
let fancy_id : x:int -> int = _ by (let x = intro () in
exact (binding_to_term x))
(* Exercise: look at the proof states and final solution of `fancy_id` *)
(* Exercise: write a `zero` tactic that solves any goal of type `a -> b
-> ... -> z -> int` with the constant zero function. It should pass the
following tests. *)
//let const () : Tac unit = ???
//
//let f1 : int = _ by (const ())
//let f2 : nat -> int = _ by (const ())
//let f3 : bool -> list int -> unit -> int = _ by (const ())
//let f4 : int -> int -> int -> int -> int = _ by (const ())
//
//let _ = assert (f1 == 0)
//let _ = assert (forall x. f2 x == 0)
//let _ = assert (forall x y z. f3 x y z == 0)
//let _ = assert (forall x y z w . f4 x y z w == 0)
(* We can also perform case analysis on inductive types by the `destruct` primitive`.
Essentially, the `destruct` tactic takes a term `t` that has some inductive type
and performs a `match` on it. Then, it returns goals for each of the possible
cases. In each case, we also get an hypothesis for the fact that
the term we destructed is equal to the given branch. We ignore those
hypotheses here by just `intro`ducing them. *)
type enum = | A | B | C
let matchenum : enum -> int =
_ by (let x = intro () in
destruct (binding_to_term x);
ignore (intro ()); exact (`1);
ignore (intro ()); exact (`2);
ignore (intro ()); exact (`3))
(* Exercise: look at the proof states and final solution for matchenum *)
(* Calling `destruct` also allows to get the arguments of each constructor. *)
type either (a b : Type) = | Left of a | Right of b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Metaprogramming.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"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 | _: Metaprogramming.either Prims.int Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Metaprogramming.either",
"Prims.int"
] | [] | false | false | false | true | false | let matcheither: either int int -> int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ ->
(let x = intro () in
destruct (binding_to_term x);
let x = intro () in
ignore (intro ());
exact (binding_to_term x);
let y = intro () in
ignore (intro ());
exact (binding_to_term y))) | false |
LowParseWriters.fst | LowParseWriters.bind_impl | val bind_impl
(a:Type) (b:Type)
(r_in_f:parser) (r_out_f: parser)
(pre_f: pre_t r_in_f) (post_f: post_t a r_in_f r_out_f pre_f)
(post_err_f: post_err_t r_in_f pre_f)
(r_out_g: parser)
(pre_g: (x:a) -> pre_t (r_out_f)) (post_g: (x:a) -> post_t b (r_out_f) r_out_g (pre_g x))
(post_err_g: (x:a) -> post_err_t (r_out_f) (pre_g x))
(f_bind_impl:repr_spec a r_in_f r_out_f pre_f post_f post_err_f)
(g:(x:a -> repr_spec b (r_out_f) r_out_g (pre_g x) (post_g x) (post_err_g x)))
(l: memory_invariant)
(f' : repr_impl a r_in_f r_out_f pre_f post_f post_err_f l f_bind_impl)
(g' : (x: a -> repr_impl b (r_out_f) r_out_g (pre_g x) (post_g x) (post_err_g x) l (g x)))
: Tot (repr_impl b r_in_f r_out_g _ _ _ l (bind_spec a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g)) | val bind_impl
(a:Type) (b:Type)
(r_in_f:parser) (r_out_f: parser)
(pre_f: pre_t r_in_f) (post_f: post_t a r_in_f r_out_f pre_f)
(post_err_f: post_err_t r_in_f pre_f)
(r_out_g: parser)
(pre_g: (x:a) -> pre_t (r_out_f)) (post_g: (x:a) -> post_t b (r_out_f) r_out_g (pre_g x))
(post_err_g: (x:a) -> post_err_t (r_out_f) (pre_g x))
(f_bind_impl:repr_spec a r_in_f r_out_f pre_f post_f post_err_f)
(g:(x:a -> repr_spec b (r_out_f) r_out_g (pre_g x) (post_g x) (post_err_g x)))
(l: memory_invariant)
(f' : repr_impl a r_in_f r_out_f pre_f post_f post_err_f l f_bind_impl)
(g' : (x: a -> repr_impl b (r_out_f) r_out_g (pre_g x) (post_g x) (post_err_g x) l (g x)))
: Tot (repr_impl b r_in_f r_out_g _ _ _ l (bind_spec a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g)) | let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 241,
"start_col": 0,
"start_line": 235
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
b: Type ->
r_in_f: LowParseWriters.LowParse.parser ->
r_out_f: LowParseWriters.LowParse.parser ->
pre_f: LowParseWriters.pre_t r_in_f ->
post_f: LowParseWriters.post_t a r_in_f r_out_f pre_f ->
post_err_f: LowParseWriters.post_err_t r_in_f pre_f ->
r_out_g: LowParseWriters.LowParse.parser ->
pre_g: (x: a -> LowParseWriters.pre_t r_out_f) ->
post_g: (x: a -> LowParseWriters.post_t b r_out_f r_out_g (pre_g x)) ->
post_err_g: (x: a -> LowParseWriters.post_err_t r_out_f (pre_g x)) ->
f_bind_impl: LowParseWriters.repr_spec a r_in_f r_out_f pre_f post_f post_err_f ->
g: (x: a -> LowParseWriters.repr_spec b r_out_f r_out_g (pre_g x) (post_g x) (post_err_g x)) ->
l: LowParseWriters.memory_invariant ->
f': LowParseWriters.repr_impl a r_in_f r_out_f pre_f post_f post_err_f l f_bind_impl ->
g':
(x: a
-> LowParseWriters.repr_impl b r_out_f r_out_g (pre_g x) (post_g x) (post_err_g x) l (g x)
)
-> LowParseWriters.repr_impl b
r_in_f
r_out_g
(fun v_in ->
pre_f v_in /\
(forall (x: a) (v_out: Parser?.t r_out_f). post_f v_in x v_out ==> pre_g x v_out))
(fun v_in y v_out ->
exists (x: a) (v_out_f: Parser?.t r_out_f).
pre_f v_in /\ post_f v_in x v_out_f /\ post_g x v_out_f y v_out)
(fun v_in ->
pre_f v_in /\
(post_err_f v_in \/
(exists (x: a) (v_out_f: Parser?.t r_out_f).
post_f v_in x v_out_f /\ post_err_g x v_out_f)))
l
(LowParseWriters.bind_spec a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g
post_err_g f_bind_impl g) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.repr_spec",
"LowParseWriters.memory_invariant",
"LowParseWriters.repr_impl",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"Prims.string",
"LowParseWriters.IError",
"LowParseWriters.iresult",
"LowParseWriters.IOverflow"
] | [] | false | false | false | false | false | let bind_impl
a
b
r_in_f
r_out_f
pre_f
post_f
post_err_f
r_out_g
pre_g
post_g
post_err_g
f_bind_impl
g
l
f'
g'
=
| fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf | false |
LowParseWriters.fst | LowParseWriters.check_precond_repr | val check_precond_repr
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot (repr unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)) inv) | val check_precond_repr
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot (repr unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)) inv) | let check_precond_repr
p1 precond c inv
= Repr _ (check_precond_impl p1 precond c inv) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 46,
"end_line": 405,
"start_col": 0,
"start_line": 403
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen)
inline_for_extraction
let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos
#restart-solver
#push-options "--ifuel 8"
inline_for_extraction
let frame2_impl
a frame ppre pre p post post_err l inner
= fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2) (pos `U32.sub` pos2) with
| IOverflow ->
IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos' ;
ICorrect x pos'
#pop-options
#pop-options
let valid_rewrite_impl
p1 p2 precond f v inv
=
fun buf len pos ->
let h = HST.get () in
v.valid_rewrite_valid h buf 0ul pos;
ICorrect () pos
let cast
p1 p2 precond f v inv x1
=
v.valid_rewrite_valid inv.h0 x1.rptr_base 0ul x1.rptr_len;
x1
let check_precond_spec
(p1: parser)
(precond: pre_t p1)
: Tot (repr_spec unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)))
= fun vin ->
if FStar.StrongExcludedMiddle.strong_excluded_middle (precond vin)
then Correct ((), vin)
else Error "check_precond failed"
inline_for_extraction
let check_precond_impl
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot (repr_impl unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)) inv (check_precond_spec p1 precond))
= fun b len pos ->
let h = HST.get () in
if c b len 0ul pos
then
let h' = HST.get () in
let _ = valid_frame p1 h b 0ul pos B.loc_none h' in
ICorrect () pos
else IError "check_precond failed" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
p1: LowParseWriters.LowParse.parser ->
precond: LowParseWriters.pre_t p1 ->
c: LowParseWriters.check_precond_t p1 precond ->
inv: LowParseWriters.memory_invariant
-> LowParseWriters.repr Prims.unit
p1
p1
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))
inv | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.check_precond_t",
"LowParseWriters.memory_invariant",
"LowParseWriters.Repr",
"Prims.unit",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"Prims.l_and",
"Prims.eq2",
"Prims.l_not",
"LowParseWriters.check_precond_spec",
"LowParseWriters.check_precond_impl",
"LowParseWriters.repr"
] | [] | false | false | false | false | false | let check_precond_repr p1 precond c inv =
| Repr _ (check_precond_impl p1 precond c inv) | false |
LowParseWriters.fst | LowParseWriters.lift_read_impl | val lift_read_impl
(a: Type)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(inv: memory_invariant)
(r: parser)
(f_read_spec: read_repr a pre post post_err inv)
: Tot (repr_impl a r (r) _ _ _ inv (lift_read_spec a pre post post_err inv r f_read_spec)) | val lift_read_impl
(a: Type)
(pre: pure_pre)
(post: pure_post' a pre)
(post_err: pure_post_err pre)
(inv: memory_invariant)
(r: parser)
(f_read_spec: read_repr a pre post post_err inv)
: Tot (repr_impl a r (r) _ _ _ inv (lift_read_spec a pre post post_err inv r f_read_spec)) | let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 269,
"start_col": 0,
"start_line": 258
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
pre: Prims.pure_pre ->
post: LowParseWriters.pure_post' a pre ->
post_err: LowParseWriters.pure_post_err pre ->
inv: LowParseWriters.memory_invariant ->
r: LowParseWriters.LowParse.parser ->
f_read_spec: LowParseWriters.read_repr a pre post post_err inv
-> LowParseWriters.repr_impl a
r
r
(fun _ -> pre)
(fun st x st' -> st == st' /\ post x)
(fun _ -> post_err ())
inv
(LowParseWriters.lift_read_spec a pre post post_err inv r f_read_spec) | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_pre",
"LowParseWriters.pure_post'",
"LowParseWriters.pure_post_err",
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.parser",
"LowParseWriters.read_repr",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.ICorrect",
"Prims.unit",
"LowParseWriters.LowParse.valid_frame",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.loc_none",
"LowParseWriters.iresult",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.string",
"LowParseWriters.IError",
"LowParseWriters.result",
"LowParseWriters.__proj__ReadRepr__item__impl"
] | [] | false | false | false | false | false | let lift_read_impl a pre post post_err inv r f_read_spec =
| fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e -> IError e | false |
LowParseWriters.fst | LowParseWriters.wfailwith_impl | val wfailwith_impl
(a: Type)
(inv: memory_invariant)
(rin rout: parser)
(s: string)
: Tot (repr_impl a rin rout (fun _ -> True) (fun _ _ _ -> False) (fun _ -> True) inv (wfailwith_spec a rin rout s)) | val wfailwith_impl
(a: Type)
(inv: memory_invariant)
(rin rout: parser)
(s: string)
: Tot (repr_impl a rin rout (fun _ -> True) (fun _ _ _ -> False) (fun _ -> True) inv (wfailwith_spec a rin rout s)) | let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 10,
"end_line": 275,
"start_col": 0,
"start_line": 271
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
inv: LowParseWriters.memory_invariant ->
rin: LowParseWriters.LowParse.parser ->
rout: LowParseWriters.LowParse.parser ->
s: Prims.string
-> LowParseWriters.repr_impl a
rin
rout
(fun _ -> Prims.l_True)
(fun _ _ _ -> Prims.l_False)
(fun _ -> Prims.l_True)
inv
(LowParseWriters.wfailwith_spec a rin rout s) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.parser",
"Prims.string",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.IError",
"LowParseWriters.iresult"
] | [] | false | false | false | false | false | let wfailwith_impl a inv rin rout s =
| fun b len pos -> IError s | false |
LowParseWriters.fst | LowParseWriters.subcomp_impl | val subcomp_impl (a:Type)
(r_in:parser) (r_out: parser)
(pre: pre_t r_in) (post: post_t a r_in r_out pre) (post_err: post_err_t r_in pre)
(l:memory_invariant)
(r_in':parser) (r_out': parser)
(pre': pre_t r_in) (post': post_t a r_in r_out pre') (post_err': post_err_t r_in pre')
(l' : memory_invariant)
(f_subcomp_spec:repr_spec a r_in r_out pre post post_err)
(f_subcomp:repr_impl a r_in r_out pre post post_err l f_subcomp_spec)
(sq: squash (subcomp_cond a r_in r_out pre post post_err pre' post' post_err' l l'))
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec)) | val subcomp_impl (a:Type)
(r_in:parser) (r_out: parser)
(pre: pre_t r_in) (post: post_t a r_in r_out pre) (post_err: post_err_t r_in pre)
(l:memory_invariant)
(r_in':parser) (r_out': parser)
(pre': pre_t r_in) (post': post_t a r_in r_out pre') (post_err': post_err_t r_in pre')
(l' : memory_invariant)
(f_subcomp_spec:repr_spec a r_in r_out pre post post_err)
(f_subcomp:repr_impl a r_in r_out pre post post_err l f_subcomp_spec)
(sq: squash (subcomp_cond a r_in r_out pre post post_err pre' post' post_err' l l'))
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec)) | let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 247,
"start_col": 0,
"start_line": 244
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
r_in: LowParseWriters.LowParse.parser ->
r_out: LowParseWriters.LowParse.parser ->
pre: LowParseWriters.pre_t r_in ->
post: LowParseWriters.post_t a r_in r_out pre ->
post_err: LowParseWriters.post_err_t r_in pre ->
l: LowParseWriters.memory_invariant ->
r_in': LowParseWriters.LowParse.parser ->
r_out': LowParseWriters.LowParse.parser ->
pre': LowParseWriters.pre_t r_in ->
post': LowParseWriters.post_t a r_in r_out pre' ->
post_err': LowParseWriters.post_err_t r_in pre' ->
l': LowParseWriters.memory_invariant ->
f_subcomp_spec: LowParseWriters.repr_spec a r_in r_out pre post post_err ->
f_subcomp: LowParseWriters.repr_impl a r_in r_out pre post post_err l f_subcomp_spec ->
sq:
Prims.squash (LowParseWriters.subcomp_cond a r_in r_out pre post post_err pre' post' post_err'
l l')
-> LowParseWriters.repr_impl a
r_in
r_out
pre'
post'
post_err'
l'
(LowParseWriters.subcomp_spec a r_in r_out pre post post_err pre' post' post_err'
f_subcomp_spec) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.memory_invariant",
"LowParseWriters.repr_spec",
"LowParseWriters.repr_impl",
"Prims.squash",
"LowParseWriters.subcomp_cond",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.iresult",
"LowParseWriters.subcomp_spec"
] | [] | false | false | false | false | false | let subcomp_impl
a
r_in
r_out
pre
post
post_err
l
r_in'
r_out'
pre'
post'
post_err'
l'
f_subcomp_spec
f_subcomp
sq
: Tot
(repr_impl a
r_in
r_out
pre'
post'
post_err'
l'
(subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec)) =
| (fun b len pos -> f_subcomp b len pos) | false |
LowParseWriters.fst | LowParseWriters.get_state_impl | val get_state_impl
(inv: memory_invariant)
(p: parser)
: Tot (repr_impl _ _ _ _ _ _ inv (get_state_spec p)) | val get_state_impl
(inv: memory_invariant)
(p: parser)
: Tot (repr_impl _ _ _ _ _ _ inv (get_state_spec p)) | let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 282,
"start_col": 0,
"start_line": 277
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | inv: LowParseWriters.memory_invariant -> p: LowParseWriters.LowParse.parser
-> LowParseWriters.repr_impl (FStar.Ghost.erased (Parser?.t p))
p
p
(fun _ -> Prims.l_True)
(fun x y z -> x == FStar.Ghost.reveal y /\ x == z)
(fun _ -> Prims.l_False)
inv
(LowParseWriters.get_state_spec p) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.parser",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.ICorrect",
"FStar.Ghost.erased",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"FStar.Ghost.hide",
"LowParseWriters.LowParse.contents",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.iresult",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | false | false | false | false | let get_state_impl inv p =
| fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos | false |
LowParseWriters.fst | LowParseWriters.valid_rewrite_impl | val valid_rewrite_impl
(p1: parser)
(p2: parser)
(precond: pre_t p1)
(f: (x: Parser?.t p1 { precond x }) -> GTot (Parser?.t p2))
(v: valid_rewrite_t p1 p2 precond f)
(inv: memory_invariant)
: Tot (repr_impl unit p1 (p2) precond (fun vin _ vout -> precond vin /\ f vin == vout) (fun _ -> False) inv (valid_rewrite_spec p1 p2 precond f v)) | val valid_rewrite_impl
(p1: parser)
(p2: parser)
(precond: pre_t p1)
(f: (x: Parser?.t p1 { precond x }) -> GTot (Parser?.t p2))
(v: valid_rewrite_t p1 p2 precond f)
(inv: memory_invariant)
: Tot (repr_impl unit p1 (p2) precond (fun vin _ vout -> precond vin /\ f vin == vout) (fun _ -> False) inv (valid_rewrite_spec p1 p2 precond f v)) | let valid_rewrite_impl
p1 p2 precond f v inv
=
fun buf len pos ->
let h = HST.get () in
v.valid_rewrite_valid h buf 0ul pos;
ICorrect () pos | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 19,
"end_line": 370,
"start_col": 0,
"start_line": 364
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen)
inline_for_extraction
let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos
#restart-solver
#push-options "--ifuel 8"
inline_for_extraction
let frame2_impl
a frame ppre pre p post post_err l inner
= fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2) (pos `U32.sub` pos2) with
| IOverflow ->
IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos' ;
ICorrect x pos'
#pop-options
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
p1: LowParseWriters.LowParse.parser ->
p2: LowParseWriters.LowParse.parser ->
precond: LowParseWriters.pre_t p1 ->
f: (x: Parser?.t p1 {precond x} -> Prims.GTot (Parser?.t p2)) ->
v: LowParseWriters.valid_rewrite_t p1 p2 precond f ->
inv: LowParseWriters.memory_invariant
-> LowParseWriters.repr_impl Prims.unit
p1
p2
precond
(fun vin _ vout -> precond vin /\ f vin == vout)
(fun _ -> Prims.l_False)
inv
(LowParseWriters.valid_rewrite_spec p1 p2 precond f v) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.valid_rewrite_t",
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.ICorrect",
"Prims.unit",
"LowParseWriters.__proj__Mkvalid_rewrite_t__item__valid_rewrite_valid",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.iresult",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | false | false | false | false | let valid_rewrite_impl p1 p2 precond f v inv =
| fun buf len pos ->
let h = HST.get () in
v.valid_rewrite_valid h buf 0ul pos;
ICorrect () pos | false |
LowParseWriters.fst | LowParseWriters.check_precond_spec | val check_precond_spec (p1: parser) (precond: pre_t p1)
: Tot
(repr_spec unit
p1
(p1)
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))) | val check_precond_spec (p1: parser) (precond: pre_t p1)
: Tot
(repr_spec unit
p1
(p1)
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))) | let check_precond_spec
(p1: parser)
(precond: pre_t p1)
: Tot (repr_spec unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)))
= fun vin ->
if FStar.StrongExcludedMiddle.strong_excluded_middle (precond vin)
then Correct ((), vin)
else Error "check_precond failed" | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 385,
"start_col": 0,
"start_line": 378
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen)
inline_for_extraction
let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos
#restart-solver
#push-options "--ifuel 8"
inline_for_extraction
let frame2_impl
a frame ppre pre p post post_err l inner
= fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2) (pos `U32.sub` pos2) with
| IOverflow ->
IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos' ;
ICorrect x pos'
#pop-options
#pop-options
let valid_rewrite_impl
p1 p2 precond f v inv
=
fun buf len pos ->
let h = HST.get () in
v.valid_rewrite_valid h buf 0ul pos;
ICorrect () pos
let cast
p1 p2 precond f v inv x1
=
v.valid_rewrite_valid inv.h0 x1.rptr_base 0ul x1.rptr_len;
x1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 | p1: LowParseWriters.LowParse.parser -> precond: LowParseWriters.pre_t p1
-> LowParseWriters.repr_spec Prims.unit
p1
p1
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin)) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"FStar.StrongExcludedMiddle.strong_excluded_middle",
"LowParseWriters.Correct",
"FStar.Pervasives.Native.tuple2",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"LowParseWriters.Error",
"LowParseWriters.result",
"LowParseWriters.repr_spec",
"Prims.l_and",
"Prims.eq2",
"Prims.l_not"
] | [] | false | false | false | false | false | let check_precond_spec (p1: parser) (precond: pre_t p1)
: Tot
(repr_spec unit
p1
(p1)
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))) =
| fun vin ->
if FStar.StrongExcludedMiddle.strong_excluded_middle (precond vin)
then Correct ((), vin)
else Error "check_precond failed" | false |
LowParseWriters.fst | LowParseWriters.cast | val cast
(p1: parser)
(p2: parser)
(precond: pre_t p1)
(f: (x: Parser?.t p1 { precond x }) -> GTot (Parser?.t p2))
(v: valid_rewrite_t p1 p2 precond f)
(inv: memory_invariant)
(x1: ptr p1 inv { precond (deref_spec x1) })
: Tot (x2: ptr p2 inv {
deref_spec x2 == f (deref_spec x1)
}) | val cast
(p1: parser)
(p2: parser)
(precond: pre_t p1)
(f: (x: Parser?.t p1 { precond x }) -> GTot (Parser?.t p2))
(v: valid_rewrite_t p1 p2 precond f)
(inv: memory_invariant)
(x1: ptr p1 inv { precond (deref_spec x1) })
: Tot (x2: ptr p2 inv {
deref_spec x2 == f (deref_spec x1)
}) | let cast
p1 p2 precond f v inv x1
=
v.valid_rewrite_valid inv.h0 x1.rptr_base 0ul x1.rptr_len;
x1 | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 376,
"start_col": 0,
"start_line": 372
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen)
inline_for_extraction
let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos
#restart-solver
#push-options "--ifuel 8"
inline_for_extraction
let frame2_impl
a frame ppre pre p post post_err l inner
= fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2) (pos `U32.sub` pos2) with
| IOverflow ->
IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos' ;
ICorrect x pos'
#pop-options
#pop-options
let valid_rewrite_impl
p1 p2 precond f v inv
=
fun buf len pos ->
let h = HST.get () in
v.valid_rewrite_valid h buf 0ul pos;
ICorrect () pos | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
p1: LowParseWriters.LowParse.parser ->
p2: LowParseWriters.LowParse.parser ->
precond: LowParseWriters.pre_t p1 ->
f: (x: Parser?.t p1 {precond x} -> Prims.GTot (Parser?.t p2)) ->
v: LowParseWriters.valid_rewrite_t p1 p2 precond f ->
inv: LowParseWriters.memory_invariant ->
x1: LowParseWriters.ptr p1 inv {precond (LowParseWriters.deref_spec x1)}
-> x2:
LowParseWriters.ptr p2 inv {LowParseWriters.deref_spec x2 == f (LowParseWriters.deref_spec x1)} | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowParseWriters.valid_rewrite_t",
"LowParseWriters.memory_invariant",
"LowParseWriters.ptr",
"LowParseWriters.deref_spec",
"Prims.unit",
"LowParseWriters.__proj__Mkvalid_rewrite_t__item__valid_rewrite_valid",
"FStar.Ghost.reveal",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.__proj__Mkrptr__item__rptr_len",
"Prims.eq2"
] | [] | false | false | false | false | false | let cast p1 p2 precond f v inv x1 =
| v.valid_rewrite_valid inv.h0 x1.rptr_base 0ul x1.rptr_len;
x1 | false |
LowParseWriters.fst | LowParseWriters.elem_writer_impl | val elem_writer_impl
(#p: parser)
(w: leaf_writer p)
(l: memory_invariant)
(x: Parser?.t p)
: Tot (repr_impl unit parse_empty (p) (fun _ -> True) (fun _ _ y -> y == x) (fun _ -> False) l (elem_writer_spec p x)) | val elem_writer_impl
(#p: parser)
(w: leaf_writer p)
(l: memory_invariant)
(x: Parser?.t p)
: Tot (repr_impl unit parse_empty (p) (fun _ -> True) (fun _ _ y -> y == x) (fun _ -> False) l (elem_writer_spec p x)) | let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen) | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 318,
"start_col": 0,
"start_line": 311
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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": 128,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | w: LowParseWriters.LowParse.leaf_writer p -> l: LowParseWriters.memory_invariant -> x: Parser?.t p
-> LowParseWriters.repr_impl Prims.unit
LowParseWriters.LowParse.parse_empty
p
(fun _ -> Prims.l_True)
(fun _ _ y -> y == x)
(fun _ -> Prims.l_False)
l
(LowParseWriters.elem_writer_spec p x) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.LowParse.leaf_writer",
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.IOverflow",
"Prims.unit",
"LowParseWriters.ICorrect",
"FStar.UInt32.add",
"LowParseWriters.iresult",
"FStar.Pervasives.Native.option",
"FStar.UInt32.sub",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.offset"
] | [] | false | false | false | false | false | let elem_writer_impl #p w l x =
| fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen) | false |
LowParseWriters.fst | LowParseWriters.check_precond_impl | val check_precond_impl
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot
(repr_impl unit
p1
(p1)
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))
inv
(check_precond_spec p1 precond)) | val check_precond_impl
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot
(repr_impl unit
p1
(p1)
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))
inv
(check_precond_spec p1 precond)) | let check_precond_impl
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot (repr_impl unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)) inv (check_precond_spec p1 precond))
= fun b len pos ->
let h = HST.get () in
if c b len 0ul pos
then
let h' = HST.get () in
let _ = valid_frame p1 h b 0ul pos B.loc_none h' in
ICorrect () pos
else IError "check_precond failed" | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 401,
"start_col": 0,
"start_line": 388
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen)
inline_for_extraction
let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos
#restart-solver
#push-options "--ifuel 8"
inline_for_extraction
let frame2_impl
a frame ppre pre p post post_err l inner
= fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2) (pos `U32.sub` pos2) with
| IOverflow ->
IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos' ;
ICorrect x pos'
#pop-options
#pop-options
let valid_rewrite_impl
p1 p2 precond f v inv
=
fun buf len pos ->
let h = HST.get () in
v.valid_rewrite_valid h buf 0ul pos;
ICorrect () pos
let cast
p1 p2 precond f v inv x1
=
v.valid_rewrite_valid inv.h0 x1.rptr_base 0ul x1.rptr_len;
x1
let check_precond_spec
(p1: parser)
(precond: pre_t p1)
: Tot (repr_spec unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)))
= fun vin ->
if FStar.StrongExcludedMiddle.strong_excluded_middle (precond vin)
then Correct ((), vin)
else Error "check_precond failed" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
p1: LowParseWriters.LowParse.parser ->
precond: LowParseWriters.pre_t p1 ->
c: LowParseWriters.check_precond_t p1 precond ->
inv: LowParseWriters.memory_invariant
-> LowParseWriters.repr_impl Prims.unit
p1
p1
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))
inv
(LowParseWriters.check_precond_spec p1 precond) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.check_precond_t",
"LowParseWriters.memory_invariant",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.ICorrect",
"Prims.unit",
"LowParseWriters.LowParse.valid_frame",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.loc_none",
"LowParseWriters.iresult",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.bool",
"LowParseWriters.IError",
"LowParseWriters.repr_impl",
"LowParseWriters.LowParse.__proj__Parser__item__t",
"Prims.l_and",
"Prims.l_not",
"LowParseWriters.check_precond_spec"
] | [] | false | false | false | false | false | let check_precond_impl
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot
(repr_impl unit
p1
(p1)
precond
(fun vin _ vout -> vin == vout /\ precond vin)
(fun vin -> ~(precond vin))
inv
(check_precond_spec p1 precond)) =
| fun b len pos ->
let h = HST.get () in
if c b len 0ul pos
then
let h' = HST.get () in
let _ = valid_frame p1 h b 0ul pos B.loc_none h' in
ICorrect () pos
else IError "check_precond failed" | false |
LowParseWriters.fst | LowParseWriters.cat_impl | val cat_impl
(#inv: memory_invariant)
(#p: parser)
(x: ptr p inv)
: Tot (repr_impl _ _ _ _ _ _ inv (cat_spec x)) | val cat_impl
(#inv: memory_invariant)
(#p: parser)
(x: ptr p inv)
: Tot (repr_impl _ _ _ _ _ _ inv (cat_spec x)) | let cat_impl
#inv #p x
=
fun b len _ ->
if len `U32.lt` x.rptr_len
then
IOverflow
else begin
B.blit x.rptr_base 0ul b 0ul x.rptr_len;
let h' = HST.get () in
valid_ext p inv.h0 x.rptr_base 0ul x.rptr_len h' b 0ul x.rptr_len;
ICorrect () x.rptr_len
end | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 419,
"start_col": 0,
"start_line": 407
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen)
inline_for_extraction
let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos
#restart-solver
#push-options "--ifuel 8"
inline_for_extraction
let frame2_impl
a frame ppre pre p post post_err l inner
= fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2) (pos `U32.sub` pos2) with
| IOverflow ->
IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos' ;
ICorrect x pos'
#pop-options
#pop-options
let valid_rewrite_impl
p1 p2 precond f v inv
=
fun buf len pos ->
let h = HST.get () in
v.valid_rewrite_valid h buf 0ul pos;
ICorrect () pos
let cast
p1 p2 precond f v inv x1
=
v.valid_rewrite_valid inv.h0 x1.rptr_base 0ul x1.rptr_len;
x1
let check_precond_spec
(p1: parser)
(precond: pre_t p1)
: Tot (repr_spec unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)))
= fun vin ->
if FStar.StrongExcludedMiddle.strong_excluded_middle (precond vin)
then Correct ((), vin)
else Error "check_precond failed"
inline_for_extraction
let check_precond_impl
(p1: parser)
(precond: pre_t p1)
(c: check_precond_t p1 precond)
(inv: memory_invariant)
: Tot (repr_impl unit p1 (p1) precond (fun vin _ vout -> vin == vout /\ precond vin) (fun vin -> ~ (precond vin)) inv (check_precond_spec p1 precond))
= fun b len pos ->
let h = HST.get () in
if c b len 0ul pos
then
let h' = HST.get () in
let _ = valid_frame p1 h b 0ul pos B.loc_none h' in
ICorrect () pos
else IError "check_precond failed"
let check_precond_repr
p1 precond c inv
= Repr _ (check_precond_impl p1 precond c inv) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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: LowParseWriters.ptr p inv
-> LowParseWriters.repr_impl Prims.unit
LowParseWriters.LowParse.parse_empty
p
(fun _ -> Prims.l_True)
(fun _ _ vout -> vout == LowParseWriters.deref_spec x)
(fun _ -> Prims.l_False)
inv
(LowParseWriters.cat_spec x) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.memory_invariant",
"LowParseWriters.LowParse.parser",
"LowParseWriters.ptr",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"FStar.UInt32.lt",
"LowParseWriters.__proj__Mkrptr__item__rptr_len",
"LowParseWriters.IOverflow",
"Prims.unit",
"LowParseWriters.iresult",
"Prims.bool",
"LowParseWriters.ICorrect",
"LowParseWriters.LowParse.valid_ext",
"FStar.Monotonic.HyperStack.mem",
"LowParseWriters.__proj__Mkmemory_invariant__item__h0",
"LowParseWriters.__proj__Mkrptr__item__rptr_base",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.blit",
"FStar.UInt8.t"
] | [] | false | false | false | false | false | let cat_impl #inv #p x =
| fun b len _ ->
if len `U32.lt` x.rptr_len
then IOverflow
else
(B.blit x.rptr_base 0ul b 0ul x.rptr_len;
let h' = HST.get () in
valid_ext p inv.h0 x.rptr_base 0ul x.rptr_len h' b 0ul x.rptr_len;
ICorrect () x.rptr_len) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_flbytes' | val serialize_flbytes' (sz: nat{sz < 4294967296}) : Tot (bare_serializer (B32.lbytes sz)) | val serialize_flbytes' (sz: nat{sz < 4294967296}) : Tot (bare_serializer (B32.lbytes sz)) | let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
) | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 36,
"start_col": 0,
"start_line": 30
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | sz: Prims.nat{sz < 4294967296} -> LowParse.Spec.Base.bare_serializer (FStar.Bytes.lbytes sz) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Bytes.lbytes",
"FStar.Bytes.reveal",
"Prims.unit",
"LowParse.Spec.Bytes.lt_pow2_32",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.bare_serializer"
] | [] | false | false | false | false | false | let serialize_flbytes' (sz: nat{sz < 4294967296}) : Tot (bare_serializer (B32.lbytes sz)) =
| fun (x: B32.lbytes sz) ->
(lt_pow2_32 sz;
B32.reveal x) | false |
LowParseWriters.fst | LowParseWriters.recast_writer_impl | val recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f)) | val recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f)) | let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 79,
"end_line": 331,
"start_col": 0,
"start_line": 321
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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": 128,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Type ->
r_in: LowParseWriters.LowParse.parser ->
r_out: LowParseWriters.LowParse.parser ->
pre: LowParseWriters.pre_t r_in ->
post: LowParseWriters.post_t a r_in r_out pre ->
post_err: LowParseWriters.post_err_t r_in pre ->
l: LowParseWriters.memory_invariant ->
f: (_: Prims.unit -> LowParseWriters.EWrite a)
-> LowParseWriters.repr_impl a
r_in
r_out
pre
(LowParseWriters.recast_writer_post a r_in r_out pre post post_err l f)
(LowParseWriters.recast_writer_post_err a r_in r_out pre post post_err l f)
l
(LowParseWriters.recast_writer_spec a r_in r_out pre post post_err l f) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.memory_invariant",
"Prims.unit",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.destr_repr_impl",
"LowParseWriters.iresult",
"LowParseWriters.repr_impl",
"LowParseWriters.recast_writer_post",
"LowParseWriters.recast_writer_post_err",
"LowParseWriters.recast_writer_spec"
] | [] | false | false | false | false | false | let recast_writer_impl
(a: Type u#x)
(r_in r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: (unit -> EWrite a r_in r_out pre post post_err l))
: Tot
(repr_impl a
r_in
r_out
pre
(recast_writer_post a r_in r_out pre post post_err l f)
(recast_writer_post_err a r_in r_out pre post post_err l f)
l
(recast_writer_spec a r_in r_out pre post post_err l f)) =
| fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos | false |
LowParseWriters.fst | LowParseWriters.frame2_impl | val frame2_impl
(a: Type)
(frame: parser)
(ppre: parser)
(pre: pre_t ppre)
(p: parser)
(post: post_t a ppre p pre)
(post_err: post_err_t ppre pre)
(l: memory_invariant)
(inner: unit -> EWrite a ppre p pre post post_err l)
: Tot (repr_impl a (frame `parse_pair` ppre) (frame_out a frame p) (frame2_pre frame ppre pre) (frame2_post a frame ppre pre p post) (frame2_post_err frame ppre pre post_err) l (frame2_spec a frame ppre pre p post post_err l inner)) | val frame2_impl
(a: Type)
(frame: parser)
(ppre: parser)
(pre: pre_t ppre)
(p: parser)
(post: post_t a ppre p pre)
(post_err: post_err_t ppre pre)
(l: memory_invariant)
(inner: unit -> EWrite a ppre p pre post post_err l)
: Tot (repr_impl a (frame `parse_pair` ppre) (frame_out a frame p) (frame2_pre frame ppre pre) (frame2_post a frame ppre pre p post) (frame2_post_err frame ppre pre post_err) l (frame2_spec a frame ppre pre p post post_err l inner)) | let frame2_impl
a frame ppre pre p post post_err l inner
= fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2) (pos `U32.sub` pos2) with
| IOverflow ->
IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos' ;
ICorrect x pos' | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 19,
"end_line": 358,
"start_col": 0,
"start_line": 338
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos
inline_for_extraction
let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos'
#push-options "--z3rlimit 128"
let elem_writer_impl
#p w l x
=
fun b len pos ->
let b' = B.offset b pos in
match w b' (len `U32.sub` pos) x with
| None -> IOverflow
| Some xlen -> ICorrect () (pos `U32.add` xlen)
inline_for_extraction
let recast_writer_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(f: unit -> EWrite a r_in r_out pre post post_err l)
: Tot (repr_impl a r_in r_out pre (recast_writer_post a r_in r_out pre post post_err l f) (recast_writer_post_err a r_in r_out pre post post_err l f) l (recast_writer_spec a r_in r_out pre post post_err l f))
= fun b len pos -> destr_repr_impl a r_in r_out pre post post_err l f b len pos
#restart-solver
#push-options "--ifuel 8" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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": 8,
"max_fuel": 8,
"max_ifuel": 8,
"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": 128,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Type ->
frame: LowParseWriters.LowParse.parser ->
ppre: LowParseWriters.LowParse.parser ->
pre: LowParseWriters.pre_t ppre ->
p: LowParseWriters.LowParse.parser ->
post: LowParseWriters.post_t a ppre p pre ->
post_err: LowParseWriters.post_err_t ppre pre ->
l: LowParseWriters.memory_invariant ->
inner: (_: Prims.unit -> LowParseWriters.EWrite a)
-> LowParseWriters.repr_impl a
(LowParseWriters.LowParse.parse_pair frame ppre)
(LowParseWriters.frame_out a frame p)
(LowParseWriters.frame2_pre frame ppre pre)
(LowParseWriters.frame2_post a frame ppre pre p post)
(LowParseWriters.frame2_post_err frame ppre pre post_err)
l
(LowParseWriters.frame2_spec a frame ppre pre p post post_err l inner) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.memory_invariant",
"Prims.unit",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"LowParseWriters.IOverflow",
"LowParseWriters.iresult",
"Prims.string",
"LowParseWriters.IError",
"LowParseWriters.ICorrect",
"LowParseWriters.LowParse.valid_parse_pair",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.LowParse.valid_frame",
"LowStar.Monotonic.Buffer.loc_disjoint_loc_buffer_from_to",
"FStar.UInt32.add",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowParseWriters.destr_repr_impl",
"FStar.UInt32.sub",
"LowStar.Monotonic.Buffer.loc_none",
"Prims._assert",
"LowParseWriters.LowParse.valid_pos",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.offset",
"LowParseWriters.LowParse.valid_parse_pair_inv"
] | [] | false | false | false | false | false | let frame2_impl a frame ppre pre p post post_err l inner =
| fun buf len pos ->
let h = HST.get () in
let pos2 = valid_parse_pair_inv frame ppre buf len 0ul pos in
let buf' = B.offset buf pos2 in
assert (valid_pos ppre h buf pos2 pos);
assert (valid_pos ppre h buf' 0ul (pos `U32.sub` pos2));
let h1 = HST.get () in
valid_frame ppre h buf' 0ul (pos `U32.sub` pos2) B.loc_none h1;
match
destr_repr_impl a ppre p pre post post_err l inner buf' (len `U32.sub` pos2)
(pos `U32.sub` pos2)
with
| IOverflow -> IOverflow
| IError e -> IError e
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos2 `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos2 pos2 (B.len buf');
valid_frame frame h buf 0ul pos2 (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos2 pos';
ICorrect x pos' | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake0 | val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res)) | val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res)) | let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 41,
"start_col": 0,
"start_line": 39
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res)) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"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 |
n:
Lib.IntTypes.size_t
{ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
2 * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t } ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n} ->
r: Hacl.Impl.Matrix.lbytes (Lib.IntTypes.size 2 *! n) ->
j: Lib.IntTypes.size_t{Lib.IntTypes.v j < Lib.IntTypes.v n} ->
res: Hacl.Impl.Matrix.matrix_t n n
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Hacl.Impl.Matrix.lbytes",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Matrix.mset",
"Prims.unit",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.ByteBuffer.uint_from_bytes_le",
"Lib.IntTypes.uint_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub",
"Lib.IntTypes.uint8"
] | [] | false | true | false | false | false | let frodo_gen_matrix_shake0 n i r j res =
| let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij) | false |
LowParseWriters.fst | LowParseWriters.frame_impl | val frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner)) | val frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner)) | let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: unit -> EWrite a parse_empty p pre post post_err l)
: Tot (repr_impl a frame (frame_out a frame p) (frame_pre frame pre) (frame_post a frame pre p post) (frame_post_err frame pre post_err) l (frame_spec a frame pre p post post_err l inner))
= fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos' ;
ICorrect x pos' | {
"file_name": "examples/layeredeffects/LowParseWriters.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 19,
"end_line": 307,
"start_col": 0,
"start_line": 285
} | (*
Copyright 2019 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 LowParseWriters
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
let read_repr_impl
a pre post post_err l spec
=
unit ->
HST.Stack (result a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
pre
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res == spec ()
))
let mk_read_repr_impl
a pre post post_err l spec impl
=
impl
let extract_read_repr_impl
a pre post post_err l spec impl
=
impl ()
let read_return_impl
a x inv
= fun _ -> Correct x
let read_bind_impl
a b pre_f post_f post_err_f pre_g post_g post_err_g f_bind_impl g l f' g'
=
fun _ ->
match f' () with
| Correct x -> g' x ()
| Error e -> Error e
let read_subcomp_impl
a pre post post_err pre' post' post_err' l l' f_subcomp_spec f_subcomp sq
=
fun _ -> f_subcomp ()
let lift_pure_read_impl
a wp f_pure_spec_for_impl l
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ -> Correct (f_pure_spec_for_impl ())
let failwith_impl
a inv s
= fun _ -> Error s
let buffer_index_impl
#t inv b i
=
fun _ -> Correct (B.index b i)
let buffer_sub_impl
#t inv b i len
=
fun _ -> Correct (B.sub b i len)
noeq
type rptr = {
rptr_base: B.buffer U8.t;
rptr_len: (rptr_len: U32.t { rptr_len == B.len rptr_base });
}
let valid_rptr
p inv x
=
inv.lwrite `B.loc_disjoint` B.loc_buffer x.rptr_base /\
valid_buffer p inv.h0 x.rptr_base
let deref_spec
#p #inv x
=
buffer_contents p inv.h0 x.rptr_base
let mk_ptr
p inv b len
= {
rptr_base = b;
rptr_len = len;
}
let buffer_of_ptr
#p #inv x
=
(x.rptr_base, x.rptr_len)
let valid_rptr_frame
#p #inv x inv'
= valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite inv'.h0
let deref_impl
#p #inv r x _
=
let h = HST.get () in
valid_frame p inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
Correct (r x.rptr_base x.rptr_len)
let access_spec
#p1 #p2 #lens #inv g x
=
let y' = gaccess g inv.h0 x.rptr_base in
{ rptr_base = y'; rptr_len = B.len y' }
let access_impl
#p1 #p2 #lens #inv #g a x
=
fun _ ->
let h = HST.get () in
valid_frame p1 inv.h0 x.rptr_base 0ul (B.len x.rptr_base) inv.lwrite h;
let (base', len') = baccess a x.rptr_base x.rptr_len in
let h' = HST.get () in
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h;
gaccessor_frame g inv.h0 x.rptr_base inv.lwrite h';
Correct ({ rptr_base = base'; rptr_len = len' })
let validate_spec
p inv b
= fun _ ->
match gvalidate p inv.h0 b with
| None -> Error "validation failed"
| Some pos ->
let b' = B.gsub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let valid_frame'
(p: parser)
(h: HS.mem)
(b: B.buffer U8.t)
(pos: U32.t)
(l: B.loc)
(h' : HS.mem)
(pos' : U32.t)
: Lemma
((
B.live h b /\
(valid_pos p h b pos pos' \/ valid_pos p h' b pos pos') /\
B.modifies l h h' /\
B.loc_disjoint l (B.loc_buffer_from_to b pos pos')
) ==> (
valid_pos p h b pos pos' /\
valid_pos p h' b pos pos' /\
contents p h' b pos pos' == contents p h b pos pos'
))
= Classical.move_requires (valid_frame p h b pos pos' l) h'
let validate_impl
#p v inv b len
= fun _ ->
let h1 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h1);
gvalidate_frame p inv.h0 b inv.lwrite h1;
let res = bvalidate v b len in
let h2 = HST.get () in
Classical.forall_intro (valid_frame' p inv.h0 b 0ul inv.lwrite h2);
gvalidate_frame p inv.h0 b inv.lwrite h2;
match res with
| None -> Error "validation failed"
| Some pos ->
let b' = B.sub b 0ul pos in
let x = { rptr_base = b' ; rptr_len = pos } in
Correct (x, pos)
let repr_impl
(a:Type u#x)
(r_in: parser)
(r_out: parser)
(pre: pre_t r_in)
(post: post_t a r_in r_out pre)
(post_err: post_err_t r_in pre)
(l: memory_invariant)
(spec: repr_spec a r_in r_out pre post post_err)
: Tot Type0 =
(b: B.buffer u8 { l.lwrite `B.loc_includes` B.loc_buffer b }) ->
(len: U32.t { len == B.len b }) ->
(pos1: buffer_offset b) ->
HST.Stack (iresult a)
(requires (fun h ->
B.modifies l.lwrite l.h0 h /\
HS.get_tip l.h0 `HS.includes` HS.get_tip h /\
valid_pos r_in h b 0ul pos1 /\
pre (contents r_in h b 0ul pos1)
))
(ensures (fun h res h' ->
repr_impl_post a r_in r_out pre post post_err l spec b pos1 h res h'
))
let mk_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
let extract_repr_impl
a r_in r_out pre post post_err l spec impl
=
impl
inline_for_extraction
let return_impl
a x r l
= fun b len pos1 -> ICorrect x pos1
inline_for_extraction
let bind_impl
a b r_in_f r_out_f pre_f post_f post_err_f r_out_g pre_g post_g post_err_g f_bind_impl g l f' g'
= fun buf len pos ->
match f' buf len pos with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x posf -> g' x buf len posf
inline_for_extraction
let subcomp_impl
a r_in r_out pre post post_err l r_in' r_out' pre' post' post_err' l' f_subcomp_spec f_subcomp sq
: Tot (repr_impl a r_in r_out pre' post' post_err' l' (subcomp_spec a r_in r_out pre post post_err pre' post' post_err' f_subcomp_spec))
= (fun b len pos -> f_subcomp b len pos)
(*
inline_for_extraction
let lift_pure_impl
(a:Type) (wp:pure_wp a { pure_wp_mono a wp }) (r:parser) (f_pure_spec_for_impl:unit -> PURE a wp)
(l: memory_invariant)
: Tot (repr_impl a r (fun _ -> r) (lift_pure_pre a wp r) (lift_pure_post a wp r) l (lift_pure_spec a wp r f_pure_spec_for_impl))
= fun buf len pos -> Some (f_pure_spec_for_impl (), pos)
*)
let lift_read_impl
a pre post post_err inv r f_read_spec
=
fun b len pos ->
let h = HST.get () in
match ReadRepr?.impl f_read_spec () with
| Correct res ->
let h' = HST.get () in
valid_frame r h b 0ul pos B.loc_none h';
ICorrect res pos
| Error e ->
IError e
let wfailwith_impl
a inv rin rout s
=
fun b len pos ->
IError s
let get_state_impl
inv p
=
fun b len pos ->
let h = HST.get () in
ICorrect (Ghost.hide (contents p h b 0ul pos)) pos | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.StrongExcludedMiddle.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParseWriters.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParseWriters.LowParse",
"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 |
a: Type ->
frame: LowParseWriters.LowParse.parser ->
pre: LowParseWriters.pre_t LowParseWriters.LowParse.parse_empty ->
p: LowParseWriters.LowParse.parser ->
post: LowParseWriters.post_t a LowParseWriters.LowParse.parse_empty p pre ->
post_err: LowParseWriters.post_err_t LowParseWriters.LowParse.parse_empty pre ->
l: LowParseWriters.memory_invariant ->
inner: (_: Prims.unit -> LowParseWriters.EWrite a)
-> LowParseWriters.repr_impl a
frame
(LowParseWriters.frame_out a frame p)
(LowParseWriters.frame_pre frame pre)
(LowParseWriters.frame_post a frame pre p post)
(LowParseWriters.frame_post_err frame pre post_err)
l
(LowParseWriters.frame_spec a frame pre p post post_err l inner) | Prims.Tot | [
"total"
] | [] | [
"LowParseWriters.LowParse.parser",
"LowParseWriters.pre_t",
"LowParseWriters.LowParse.parse_empty",
"LowParseWriters.post_t",
"LowParseWriters.post_err_t",
"LowParseWriters.memory_invariant",
"Prims.unit",
"LowStar.Buffer.buffer",
"LowParseWriters.LowParse.u8",
"LowStar.Monotonic.Buffer.loc_includes",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.loc",
"LowParseWriters.__proj__Mkmemory_invariant__item__lwrite",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"Prims.eq2",
"LowStar.Monotonic.Buffer.len",
"LowParseWriters.buffer_offset",
"Prims.string",
"LowParseWriters.IError",
"LowParseWriters.iresult",
"LowParseWriters.IOverflow",
"LowParseWriters.ICorrect",
"LowParseWriters.LowParse.valid_parse_pair",
"FStar.UInt32.__uint_to_t",
"LowParseWriters.LowParse.valid_frame",
"LowStar.Monotonic.Buffer.loc_disjoint_loc_buffer_from_to",
"FStar.UInt32.add",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowParseWriters.destr_repr_impl",
"FStar.UInt32.sub",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.offset",
"LowParseWriters.repr_impl",
"LowParseWriters.frame_out",
"LowParseWriters.frame_pre",
"LowParseWriters.frame_post",
"LowParseWriters.frame_post_err",
"LowParseWriters.frame_spec"
] | [] | false | false | false | false | false | let frame_impl
(a: Type)
(frame: parser)
(pre: pre_t parse_empty)
(p: parser)
(post: post_t a parse_empty p pre)
(post_err: post_err_t parse_empty pre)
(l: memory_invariant)
(inner: (unit -> EWrite a parse_empty p pre post post_err l))
: Tot
(repr_impl a
frame
(frame_out a frame p)
(frame_pre frame pre)
(frame_post a frame pre p post)
(frame_post_err frame pre post_err)
l
(frame_spec a frame pre p post post_err l inner)) =
| fun buf len pos ->
let h = HST.get () in
let buf' = B.offset buf pos in
match destr_repr_impl a parse_empty p pre post post_err l inner buf' (len `U32.sub` pos) 0ul with
| IError e -> IError e
| IOverflow -> IOverflow
| ICorrect x wlen ->
let h' = HST.get () in
let pos' = pos `U32.add` wlen in
B.loc_disjoint_loc_buffer_from_to buf 0ul pos pos (B.len buf');
valid_frame frame h buf 0ul pos (B.loc_buffer buf') h';
valid_parse_pair frame (p) h' buf 0ul pos pos';
ICorrect x pos' | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_all_bytes_kind | val parse_all_bytes_kind : LowParse.Spec.Base.parser_kind' | let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
} | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 74,
"start_col": 0,
"start_line": 68
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | LowParse.Spec.Base.parser_kind' | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.Mkparser_kind'",
"FStar.Pervasives.Native.None",
"Prims.nat",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.ParserConsumesAll",
"LowParse.Spec.Base.parser_kind_metadata_some"
] | [] | false | false | false | true | false | let parse_all_bytes_kind =
| {
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll
} | false |
|
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.concat_ind_seed | val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16) | val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16) | let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 89,
"end_line": 63,
"start_col": 0,
"start_line": 54
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"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 |
tmp_seed: Hacl.Impl.Matrix.lbytes 18ul ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.maxint Lib.IntTypes.U16}
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Matrix.lbytes",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.uint8",
"Lib.Sequence.sub",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Sequence.concat",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.numbytes",
"Lib.ByteSequence.uint_to_bytes_le",
"Lib.IntTypes.to_u16",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub_f",
"Lib.Sequence.lseq",
"Lib.ByteBuffer.uint_to_bytes_le",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub"
] | [] | false | true | false | false | false | let concat_ind_seed tmp_seed i =
| let h0 = ST.get () in
update_sub_f h0
tmp_seed
0ul
2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_all_bytes' | val serialize_all_bytes' (input: B32.bytes) : GTot bytes | val serialize_all_bytes' (input: B32.bytes) : GTot bytes | let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 18,
"end_line": 122,
"start_col": 0,
"start_line": 119
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | input: FStar.Bytes.bytes -> Prims.GTot LowParse.Bytes.bytes | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Bytes.bytes",
"FStar.Bytes.reveal",
"LowParse.Bytes.bytes"
] | [] | false | false | false | false | false | let serialize_all_bytes' (input: B32.bytes) : GTot bytes =
| B32.reveal input | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake1 | val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16) | val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16) | let frodo_gen_matrix_shake1 n tmp_seed r i res =
concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res
) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 92,
"start_col": 0,
"start_line": 81
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16)
inline_for_extraction noextract private
val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"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 |
n:
Lib.IntTypes.size_t
{ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 } ->
tmp_seed: Hacl.Impl.Matrix.lbytes 18ul ->
r: Hacl.Impl.Matrix.lbytes (Lib.IntTypes.size 2 *! n) ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n} ->
res: Hacl.Impl.Matrix.matrix_t n n
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Hacl.Impl.Matrix.lbytes",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Prims.op_LessThan",
"Hacl.Impl.Matrix.matrix_t",
"Lib.Buffer.loop1",
"Hacl.Impl.Matrix.elem",
"Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake0",
"Prims.unit",
"Lib.LoopCombinators.unfold_repeati",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Hacl.Impl.Matrix.as_matrix",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.Frodo.Gen.frodo_gen_matrix_shake0",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Hacl.SHA3.shake128_hacl",
"Hacl.Impl.Frodo.Gen.concat_ind_seed"
] | [] | false | true | false | false | false | let frodo_gen_matrix_shake1 n tmp_seed r i res =
| concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@@ inline_let ]let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0
n
res
spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_bounded_vlbytes_pred | val parse_bounded_vlbytes_pred
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: B32.bytes)
: GTot Type0 | val parse_bounded_vlbytes_pred
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: B32.bytes)
: GTot Type0 | let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 32,
"end_line": 160,
"start_col": 0,
"start_line": 154
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} -> x: FStar.Bytes.bytes
-> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"FStar.Bytes.bytes",
"FStar.UInt.uint_t",
"FStar.Bytes.length"
] | [] | false | false | false | false | true | let parse_bounded_vlbytes_pred
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: B32.bytes)
: GTot Type0 =
| let reslen = B32.length x in
min <= reslen /\ reslen <= max | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_flbytes | val serialize_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer (parse_flbytes sz)) | val serialize_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer (parse_flbytes sz)) | let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 23,
"end_line": 58,
"start_col": 0,
"start_line": 54
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | sz: Prims.nat{sz < 4294967296}
-> LowParse.Spec.Base.serializer (LowParse.Spec.Bytes.parse_flbytes sz) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Spec.Bytes.serialize_flbytes'",
"Prims.unit",
"LowParse.Spec.Bytes.serialize_flbytes_correct",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Base.total_constant_size_parser_kind",
"FStar.Bytes.lbytes",
"LowParse.Spec.Bytes.parse_flbytes"
] | [] | false | false | false | false | false | let serialize_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer (parse_flbytes sz)) =
| serialize_flbytes_correct sz;
serialize_flbytes' sz | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_flbytes_gen | val parse_flbytes_gen (sz: nat{sz < 4294967296}) (s: bytes{Seq.length s == sz})
: GTot (B32.lbytes sz) | val parse_flbytes_gen (sz: nat{sz < 4294967296}) (s: bytes{Seq.length s == sz})
: GTot (B32.lbytes sz) | let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 12,
"end_line": 23,
"start_col": 0,
"start_line": 18
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | sz: Prims.nat{sz < 4294967296} -> s: LowParse.Bytes.bytes{FStar.Seq.Base.length s == sz}
-> Prims.GTot (FStar.Bytes.lbytes sz) | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Bytes.bytes",
"Prims.eq2",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.Bytes.hide",
"Prims.unit",
"LowParse.Spec.Bytes.lt_pow2_32",
"FStar.Bytes.lbytes"
] | [] | false | false | false | false | false | let parse_flbytes_gen (sz: nat{sz < 4294967296}) (s: bytes{Seq.length s == sz})
: GTot (B32.lbytes sz) =
| lt_pow2_32 sz;
B32.hide s | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_flbytes | val parse_flbytes (sz: nat{sz < 4294967296})
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz)) | val parse_flbytes (sz: nat{sz < 4294967296})
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz)) | let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz) | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 75,
"end_line": 28,
"start_col": 0,
"start_line": 25
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | sz: Prims.nat{sz < 4294967296}
-> LowParse.Spec.Base.parser (LowParse.Spec.Base.total_constant_size_parser_kind sz)
(FStar.Bytes.lbytes sz) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Spec.Combinators.make_total_constant_size_parser",
"FStar.Bytes.lbytes",
"LowParse.Spec.Bytes.parse_flbytes_gen",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.total_constant_size_parser_kind"
] | [] | false | false | false | false | false | let parse_flbytes (sz: nat{sz < 4294967296})
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz)) =
| make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_flbytes_correct | val serialize_flbytes_correct (sz: nat{sz < 4294967296})
: Lemma (serializer_correct (parse_flbytes sz) (serialize_flbytes' sz)) | val serialize_flbytes_correct (sz: nat{sz < 4294967296})
: Lemma (serializer_correct (parse_flbytes sz) (serialize_flbytes' sz)) | let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 52,
"start_col": 0,
"start_line": 38
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | sz: Prims.nat{sz < 4294967296}
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.serializer_correct (LowParse.Spec.Bytes.parse_flbytes sz)
(LowParse.Spec.Bytes.serialize_flbytes' sz)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Classical.forall_intro",
"FStar.Bytes.lbytes",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Bytes.serialize_flbytes'",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Bytes.parse_flbytes",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.serializer_correct",
"LowParse.Spec.Base.total_constant_size_parser_kind"
] | [] | false | false | true | false | false | let serialize_flbytes_correct (sz: nat{sz < 4294967296})
: Lemma (serializer_correct (parse_flbytes sz) (serialize_flbytes' sz)) =
| let prf (input: B32.lbytes sz)
: Lemma
(let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\ parse (parse_flbytes sz) ser == Some (input, sz)) =
()
in
Classical.forall_intro prf | false |
Bug.SpinLock.fst | Bug.SpinLock.test_fstar | val test_fstar : r: Pulse.Lib.Reference.ref Prims.int -> Prims.unit | let test_fstar (r:R.ref int) =
let my_lock = new_lock (exists* v. R.pts_to r v) in
() | {
"file_name": "share/steel/examples/pulse/bug-reports/Bug.SpinLock.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 4,
"end_line": 24,
"start_col": 0,
"start_line": 22
} | (*
Copyright 2023 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 Bug.SpinLock
open Pulse.Lib.Pervasives
module R = Pulse.Lib.Reference
open Pulse.Lib.SpinLock | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.SpinLock.fsti.checked",
"Pulse.Lib.Reference.fsti.checked",
"Pulse.Lib.Pervasives.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Bug.SpinLock.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Lib.SpinLock",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Lib.Reference",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Bug",
"short_module": null
},
{
"abbrev": false,
"full_module": "Bug",
"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 | r: Pulse.Lib.Reference.ref Prims.int -> Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Reference.ref",
"Prims.int",
"Pulse.Lib.Core.stt",
"Pulse.Lib.SpinLock.lock",
"Pulse.Lib.Core.op_exists_Star",
"Pulse.Lib.Reference.pts_to",
"PulseCore.FractionalPermission.full_perm",
"Pulse.Lib.Core.vprop",
"Pulse.Lib.Core.emp",
"Pulse.Lib.SpinLock.new_lock",
"Prims.unit"
] | [] | false | false | false | true | false | let test_fstar (r: R.ref int) =
| let my_lock = new_lock (exists* v. R.pts_to r v) in
() | false |
|
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_all_bytes_injective | val parse_all_bytes_injective: Prims.unit -> Lemma (injective parse_all_bytes') | val parse_all_bytes_injective: Prims.unit -> Lemma (injective parse_all_bytes') | let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x)) | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 69,
"end_line": 103,
"start_col": 0,
"start_line": 89
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures LowParse.Spec.Base.injective LowParse.Spec.Bytes.parse_all_bytes') | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"FStar.Classical.forall_intro_2",
"LowParse.Bytes.bytes",
"Prims.l_imp",
"LowParse.Spec.Base.injective_precond",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes'",
"LowParse.Spec.Base.injective_postcond",
"FStar.Classical.move_requires",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Bytes.reveal_hide",
"LowParse.Spec.Bytes.lt_pow2_32",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Spec.Base.injective"
] | [] | false | false | true | false | false | let parse_all_bytes_injective () : Lemma (injective parse_all_bytes') =
| let prf (b1 b2: bytes)
: Lemma (requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2)) =
assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x)) | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x0 | val frodo_gen_matrix_shake_4x0:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> i:size_t{v i < v n / 4}
-> r0:lbytes (size 2 *! n)
-> r1:lbytes (size 2 *! n)
-> r2:lbytes (size 2 *! n)
-> r3:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h r0 /\ live h r1 /\ live h r2 /\
live h r3 /\ live h res /\
B.loc_pairwise_disjoint [loc res; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x0 (v n) (v i) (as_seq h0 r0) (as_seq h0 r1)
(as_seq h0 r2) (as_seq h0 r3) (v j) (as_matrix h0 res)) | val frodo_gen_matrix_shake_4x0:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> i:size_t{v i < v n / 4}
-> r0:lbytes (size 2 *! n)
-> r1:lbytes (size 2 *! n)
-> r2:lbytes (size 2 *! n)
-> r3:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h r0 /\ live h r1 /\ live h r2 /\
live h r3 /\ live h res /\
B.loc_pairwise_disjoint [loc res; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x0 (v n) (v i) (as_seq h0 r0) (as_seq h0 r1)
(as_seq h0 r2) (as_seq h0 r3) (v j) (as_matrix h0 res)) | let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res =
let resij0 = sub r0 (j *! size 2) (size 2) in
let resij1 = sub r1 (j *! size 2) (size 2) in
let resij2 = sub r2 (j *! size 2) (size 2) in
let resij3 = sub r3 (j *! size 2) (size 2) in
mset res (size 4 *! i +! size 0) j (uint_from_bytes_le resij0);
mset res (size 4 *! i +! size 1) j (uint_from_bytes_le resij1);
mset res (size 4 *! i +! size 2) j (uint_from_bytes_le resij2);
mset res (size 4 *! i +! size 3) j (uint_from_bytes_le resij3) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 64,
"end_line": 161,
"start_col": 0,
"start_line": 153
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16)
inline_for_extraction noextract private
val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let frodo_gen_matrix_shake1 n tmp_seed r i res =
concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res
)
val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed))
[@"c_inline"]
let frodo_gen_matrix_shake n seed res =
push_frame ();
let r = create (size 2 *! n) (u8 0) in
let tmp_seed = create 18ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake1 (v n) (as_seq h0 seed) in
[@ inline_let]
let inv h (i:nat{i <= v n}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res) in
Loops.eq_repeati0 (v n) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul n inv
(fun i ->
Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake1 n tmp_seed r i res);
pop_frame ()
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x0:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> i:size_t{v i < v n / 4}
-> r0:lbytes (size 2 *! n)
-> r1:lbytes (size 2 *! n)
-> r2:lbytes (size 2 *! n)
-> r3:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h r0 /\ live h r1 /\ live h r2 /\
live h r3 /\ live h res /\
B.loc_pairwise_disjoint [loc res; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x0 (v n) (v i) (as_seq h0 r0) (as_seq h0 r1)
(as_seq h0 r2) (as_seq h0 r3) (v j) (as_matrix h0 res)) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"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 |
n:
Lib.IntTypes.size_t
{ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 } ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n / 4} ->
r0: Hacl.Impl.Matrix.lbytes (Lib.IntTypes.size 2 *! n) ->
r1: Hacl.Impl.Matrix.lbytes (Lib.IntTypes.size 2 *! n) ->
r2: Hacl.Impl.Matrix.lbytes (Lib.IntTypes.size 2 *! n) ->
r3: Hacl.Impl.Matrix.lbytes (Lib.IntTypes.size 2 *! n) ->
j: Lib.IntTypes.size_t{Lib.IntTypes.v j < Lib.IntTypes.v n} ->
res: Hacl.Impl.Matrix.matrix_t n n
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Prims.op_LessThan",
"Prims.op_Division",
"Hacl.Impl.Matrix.lbytes",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Matrix.mset",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.ByteBuffer.uint_from_bytes_le",
"Lib.IntTypes.uint_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub",
"Lib.IntTypes.uint8"
] | [] | false | true | false | false | false | let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res =
| let resij0 = sub r0 (j *! size 2) (size 2) in
let resij1 = sub r1 (j *! size 2) (size 2) in
let resij2 = sub r2 (j *! size 2) (size 2) in
let resij3 = sub r3 (j *! size 2) (size 2) in
mset res (size 4 *! i +! size 0) j (uint_from_bytes_le resij0);
mset res (size 4 *! i +! size 1) j (uint_from_bytes_le resij1);
mset res (size 4 *! i +! size 2) j (uint_from_bytes_le resij2);
mset res (size 4 *! i +! size 3) j (uint_from_bytes_le resij3) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_all_bytes' | val parse_all_bytes' (input: bytes) : Tot (option (B32.bytes * consumed_length input)) | val parse_all_bytes' (input: bytes) : Tot (option (B32.bytes * consumed_length input)) | let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 85,
"start_col": 0,
"start_line": 76
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | input: LowParse.Bytes.bytes
-> FStar.Pervasives.Native.option (FStar.Bytes.bytes * LowParse.Spec.Base.consumed_length input) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Bytes.bytes",
"Prims.op_GreaterThanOrEqual",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"FStar.Bytes.bytes",
"LowParse.Spec.Base.consumed_length",
"Prims.bool",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"LowParse.Bytes32.b32_hide",
"Prims.unit",
"LowParse.Spec.Bytes.lt_pow2_32",
"FStar.Pervasives.Native.option",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte"
] | [] | false | false | false | false | false | let parse_all_bytes' (input: bytes) : Tot (option (B32.bytes * consumed_length input)) =
| let len = Seq.length input in
if len >= 4294967296
then None
else
(lt_pow2_32 len;
Some (B32.b32_hide input, len)) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_all_bytes | val parse_all_bytes:parser parse_all_bytes_kind B32.bytes | val parse_all_bytes:parser parse_all_bytes_kind B32.bytes | let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 21,
"end_line": 117,
"start_col": 0,
"start_line": 116
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | LowParse.Spec.Base.parser LowParse.Spec.Bytes.parse_all_bytes_kind FStar.Bytes.bytes | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Bytes.tot_parse_all_bytes"
] | [] | false | false | false | true | false | let parse_all_bytes:parser parse_all_bytes_kind B32.bytes =
| tot_parse_all_bytes | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.tot_parse_all_bytes | val tot_parse_all_bytes:tot_parser parse_all_bytes_kind B32.bytes | val tot_parse_all_bytes:tot_parser parse_all_bytes_kind B32.bytes | let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes' | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 18,
"end_line": 114,
"start_col": 0,
"start_line": 112
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | LowParse.Spec.Base.tot_parser LowParse.Spec.Bytes.parse_all_bytes_kind FStar.Bytes.bytes | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Bytes.parse_all_bytes'",
"Prims.unit",
"LowParse.Spec.Bytes.parse_all_bytes_correct"
] | [] | false | false | false | true | false | let tot_parse_all_bytes:tot_parser parse_all_bytes_kind B32.bytes =
| parse_all_bytes_correct ();
parse_all_bytes' | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_all_bytes_correct | val parse_all_bytes_correct: Prims.unit
-> Lemma (parser_kind_prop parse_all_bytes_kind parse_all_bytes') | val parse_all_bytes_correct: Prims.unit
-> Lemma (parser_kind_prop parse_all_bytes_kind parse_all_bytes') | let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective () | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 30,
"end_line": 110,
"start_col": 0,
"start_line": 107
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.parser_kind_prop LowParse.Spec.Bytes.parse_all_bytes_kind
LowParse.Spec.Bytes.parse_all_bytes') | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"LowParse.Spec.Bytes.parse_all_bytes_injective",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.Bytes.parse_all_bytes'",
"Prims.l_True",
"Prims.squash",
"LowParse.Spec.Base.parser_kind_prop",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let parse_all_bytes_correct () : Lemma (parser_kind_prop parse_all_bytes_kind parse_all_bytes') =
| parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective () | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_all_bytes_correct | val serialize_all_bytes_correct: Prims.unit
-> Lemma (serializer_correct parse_all_bytes serialize_all_bytes') | val serialize_all_bytes_correct: Prims.unit
-> Lemma (serializer_correct parse_all_bytes serialize_all_bytes') | let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 139,
"start_col": 0,
"start_line": 126
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.serializer_correct LowParse.Spec.Bytes.parse_all_bytes
LowParse.Spec.Bytes.serialize_all_bytes') | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"FStar.Classical.forall_intro",
"FStar.Bytes.bytes",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Bytes.serialize_all_bytes'",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Bytes.parse_all_bytes",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Bytes.hide_reveal",
"LowParse.Spec.Bytes.lt_pow2_32",
"FStar.Bytes.length",
"Prims._assert",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.serializer_correct",
"LowParse.Spec.Bytes.parse_all_bytes_kind"
] | [] | false | false | true | false | false | let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
| let prf (input: B32.bytes)
: Lemma
(let ser = serialize_all_bytes' input in
let len:consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)) =
assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_all_bytes | val serialize_all_bytes:serializer parse_all_bytes | val serialize_all_bytes:serializer parse_all_bytes | let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes' | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 22,
"end_line": 145,
"start_col": 0,
"start_line": 143
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 | LowParse.Spec.Base.serializer LowParse.Spec.Bytes.parse_all_bytes | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Bytes.serialize_all_bytes'",
"Prims.unit",
"LowParse.Spec.Bytes.serialize_all_bytes_correct"
] | [] | false | false | false | true | false | let serialize_all_bytes:serializer parse_all_bytes =
| serialize_all_bytes_correct ();
serialize_all_bytes' | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_bounded_vlbytes_kind | val parse_bounded_vlbytes_kind (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot parser_kind | val parse_bounded_vlbytes_kind (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot parser_kind | let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 77,
"end_line": 172,
"start_col": 0,
"start_line": 168
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } ) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296}
-> LowParse.Spec.Base.parser_kind | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.Base.parser_kind"
] | [] | false | false | false | false | false | let parse_bounded_vlbytes_kind (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot parser_kind =
| parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_bounded_vlbytes_aux | val parse_bounded_vlbytes_aux
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot
(parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind)
(parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)) | val parse_bounded_vlbytes_aux
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot
(parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind)
(parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)) | let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 60,
"end_line": 152,
"start_col": 0,
"start_line": 147
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4}
-> LowParse.Spec.Base.parser (LowParse.Spec.VLData.parse_bounded_vldata_strong_kind min
max
l
LowParse.Spec.Bytes.parse_all_bytes_kind)
(LowParse.Spec.VLData.parse_bounded_vldata_strong_t min
max
LowParse.Spec.Bytes.serialize_all_bytes) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.VLData.parse_bounded_vldata_strong'",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Base.parser",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t"
] | [] | false | false | false | false | false | let parse_bounded_vlbytes_aux
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot
(parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind)
(parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)) =
| parse_bounded_vldata_strong' min max l serialize_all_bytes | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_bounded_vlbytes | val parse_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot
(parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) | val parse_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot
(parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) | let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max) | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 46,
"end_line": 193,
"start_col": 0,
"start_line": 189
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296}
-> LowParse.Spec.Base.parser (LowParse.Spec.VLData.parse_bounded_vldata_strong_kind min
max
(LowParse.Spec.BoundedInt.log256' max)
LowParse.Spec.Bytes.parse_all_bytes_kind)
(LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.Bytes.parse_bounded_vlbytes'",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Base.parser",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t"
] | [] | false | false | false | false | false | let parse_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot
(parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) =
| parse_bounded_vlbytes' min max (log256' max) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.synth_bounded_vlbytes | val synth_bounded_vlbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max) | val synth_bounded_vlbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max) | let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 180,
"start_col": 0,
"start_line": 175
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
x:
LowParse.Spec.VLData.parse_bounded_vldata_strong_t min
max
LowParse.Spec.Bytes.serialize_all_bytes
-> LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t"
] | [] | false | false | false | false | false | let synth_bounded_vlbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max) =
| x | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.tmp_seed4_pre | val tmp_seed4_pre: h:mem -> tmp_seed:lbytes (18ul *! 4ul) -> Type0 | val tmp_seed4_pre: h:mem -> tmp_seed:lbytes (18ul *! 4ul) -> Type0 | let tmp_seed4_pre h tmp_seed =
let seed0 = LSeq.sub (as_seq h tmp_seed) 2 16 in
let seed1 = LSeq.sub (as_seq h tmp_seed) 20 16 in
let seed2 = LSeq.sub (as_seq h tmp_seed) 38 16 in
let seed3 = LSeq.sub (as_seq h tmp_seed) 56 16 in
seed0 == seed1 /\ seed0 == seed2 /\ seed0 == seed3 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 170,
"start_col": 0,
"start_line": 165
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16)
inline_for_extraction noextract private
val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let frodo_gen_matrix_shake1 n tmp_seed r i res =
concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res
)
val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed))
[@"c_inline"]
let frodo_gen_matrix_shake n seed res =
push_frame ();
let r = create (size 2 *! n) (u8 0) in
let tmp_seed = create 18ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake1 (v n) (as_seq h0 seed) in
[@ inline_let]
let inv h (i:nat{i <= v n}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res) in
Loops.eq_repeati0 (v n) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul n inv
(fun i ->
Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake1 n tmp_seed r i res);
pop_frame ()
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x0:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> i:size_t{v i < v n / 4}
-> r0:lbytes (size 2 *! n)
-> r1:lbytes (size 2 *! n)
-> r2:lbytes (size 2 *! n)
-> r3:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h r0 /\ live h r1 /\ live h r2 /\
live h r3 /\ live h res /\
B.loc_pairwise_disjoint [loc res; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x0 (v n) (v i) (as_seq h0 r0) (as_seq h0 r1)
(as_seq h0 r2) (as_seq h0 r3) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res =
let resij0 = sub r0 (j *! size 2) (size 2) in
let resij1 = sub r1 (j *! size 2) (size 2) in
let resij2 = sub r2 (j *! size 2) (size 2) in
let resij3 = sub r3 (j *! size 2) (size 2) in
mset res (size 4 *! i +! size 0) j (uint_from_bytes_le resij0);
mset res (size 4 *! i +! size 1) j (uint_from_bytes_le resij1);
mset res (size 4 *! i +! size 2) j (uint_from_bytes_le resij2);
mset res (size 4 *! i +! size 3) j (uint_from_bytes_le resij3) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"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 | h: FStar.Monotonic.HyperStack.mem -> tmp_seed: Hacl.Impl.Matrix.lbytes (18ul *! 4ul) -> Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Matrix.lbytes",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Prims.l_or",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Lib.IntTypes.v",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Sequence.sub"
] | [] | false | false | false | false | true | let tmp_seed4_pre h tmp_seed =
| let seed0 = LSeq.sub (as_seq h tmp_seed) 2 16 in
let seed1 = LSeq.sub (as_seq h tmp_seed) 20 16 in
let seed2 = LSeq.sub (as_seq h tmp_seed) 38 16 in
let seed3 = LSeq.sub (as_seq h tmp_seed) 56 16 in
seed0 == seed1 /\ seed0 == seed2 /\ seed0 == seed3 | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_bounded_vlbytes' | val parse_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot
(parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) | val parse_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot
(parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) | let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 83,
"end_line": 187,
"start_col": 0,
"start_line": 182
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4}
-> LowParse.Spec.Base.parser (LowParse.Spec.VLData.parse_bounded_vldata_strong_kind min
max
l
LowParse.Spec.Bytes.parse_all_bytes_kind)
(LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_aux",
"LowParse.Spec.Bytes.synth_bounded_vlbytes",
"LowParse.Spec.Base.parser"
] | [] | false | false | false | false | false | let parse_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot
(parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) =
| parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.synth_bounded_vlbytes_recip | val synth_bounded_vlbytes_recip
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) | val synth_bounded_vlbytes_recip
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) | let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 234,
"start_col": 0,
"start_line": 229
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
x: LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max
-> LowParse.Spec.VLData.parse_bounded_vldata_strong_t min
max
LowParse.Spec.Bytes.serialize_all_bytes | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes"
] | [] | false | false | false | false | false | let synth_bounded_vlbytes_recip
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) =
| x | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_bounded_vlbytes' | val serialize_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot (serializer (parse_bounded_vlbytes' min max l)) | val serialize_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot (serializer (parse_bounded_vlbytes' min max l)) | let serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes' min max l))
= serialize_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
() | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 246,
"start_col": 0,
"start_line": 236
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes
inline_for_extraction
let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4}
-> LowParse.Spec.Base.serializer (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_aux",
"LowParse.Spec.Bytes.synth_bounded_vlbytes",
"LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux",
"LowParse.Spec.Bytes.synth_bounded_vlbytes_recip",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Bytes.parse_bounded_vlbytes'"
] | [] | false | false | false | false | false | let serialize_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot (serializer (parse_bounded_vlbytes' min max l)) =
| serialize_synth (parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
() | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux | val serialize_bounded_vlbytes_aux
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot (serializer (parse_bounded_vlbytes_aux min max l)) | val serialize_bounded_vlbytes_aux
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot (serializer (parse_bounded_vlbytes_aux min max l)) | let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 226,
"start_col": 0,
"start_line": 221
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4}
-> LowParse.Spec.Base.serializer (LowParse.Spec.Bytes.parse_bounded_vlbytes_aux min max l) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.VLData.serialize_bounded_vldata_strong'",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_aux"
] | [] | false | false | false | false | false | let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
: Tot (serializer (parse_bounded_vlbytes_aux min max l)) =
| serialize_bounded_vldata_strong' min max l serialize_all_bytes | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.length_serialize_bounded_vlbytes | val length_serialize_bounded_vlbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes min max) x) == log256' max + B32.length x) | val length_serialize_bounded_vlbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes min max) x) == log256' max + B32.length x) | let length_serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes min max) x) == log256' max + B32.length x)
= length_serialize_bounded_vlbytes' min max (log256' max) x | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 59,
"end_line": 275,
"start_col": 0,
"start_line": 269
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes
inline_for_extraction
let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x
let serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes' min max l))
= serialize_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
let serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (serializer (parse_bounded_vlbytes min max))
= serialize_bounded_vlbytes' min max (log256' max)
let length_serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x)
= serialize_synth_eq
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
x: LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.length (LowParse.Spec.Base.serialize (LowParse.Spec.Bytes.serialize_bounded_vlbytes
min
max)
x) ==
LowParse.Spec.BoundedInt.log256' max + FStar.Bytes.length x) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.Bytes.length_serialize_bounded_vlbytes'",
"LowParse.Spec.BoundedInt.log256'",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.Bytes.parse_bounded_vlbytes",
"LowParse.Spec.Bytes.serialize_bounded_vlbytes",
"Prims.op_Addition",
"FStar.Bytes.length",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let length_serialize_bounded_vlbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes min max) x) == log256' max + B32.length x) =
| length_serialize_bounded_vlbytes' min max (log256' max) x | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.uint64 | val uint64 : Prims.eqtype | let uint64 = UInt64.t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 29,
"start_col": 0,
"start_line": 29
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt64.t"
] | [] | false | false | false | true | false | let uint64 =
| UInt64.t | false |
|
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_bounded_vlbytes | val serialize_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot (serializer (parse_bounded_vlbytes min max)) | val serialize_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot (serializer (parse_bounded_vlbytes min max)) | let serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (serializer (parse_bounded_vlbytes min max))
= serialize_bounded_vlbytes' min max (log256' max) | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 50,
"end_line": 252,
"start_col": 0,
"start_line": 248
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes
inline_for_extraction
let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x
let serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes' min max l))
= serialize_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296}
-> LowParse.Spec.Base.serializer (LowParse.Spec.Bytes.parse_bounded_vlbytes min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.Bytes.serialize_bounded_vlbytes'",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.Bytes.parse_bounded_vlbytes"
] | [] | false | false | false | false | false | let serialize_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296})
: Tot (serializer (parse_bounded_vlbytes min max)) =
| serialize_bounded_vlbytes' min max (log256' max) | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_bounded_vlgenbytes | val parse_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#sk: parser_kind)
(pk: parser sk (bounded_int32 min max))
: Tot
(parser (parse_bounded_vlgen_kind sk min max parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) | val parse_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#sk: parser_kind)
(pk: parser sk (bounded_int32 min max))
: Tot
(parser (parse_bounded_vlgen_kind sk min max parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) | let parse_bounded_vlgenbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(#sk: parser_kind)
(pk: parser sk (bounded_int32 min max))
: Tot (parser (parse_bounded_vlgen_kind sk min max parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlgen min max pk serialize_all_bytes `parse_synth` synth_bounded_vlbytes min max | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 96,
"end_line": 283,
"start_col": 0,
"start_line": 277
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes
inline_for_extraction
let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x
let serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes' min max l))
= serialize_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
let serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (serializer (parse_bounded_vlbytes min max))
= serialize_bounded_vlbytes' min max (log256' max)
let length_serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x)
= serialize_synth_eq
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
x
let length_serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes min max) x) == log256' max + B32.length x)
= length_serialize_bounded_vlbytes' min max (log256' max) x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
pk: LowParse.Spec.Base.parser sk (LowParse.Spec.BoundedInt.bounded_int32 min max)
-> LowParse.Spec.Base.parser (LowParse.Spec.VLGen.parse_bounded_vlgen_kind sk
min
max
LowParse.Spec.Bytes.parse_all_bytes_kind)
(LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.Bytes.synth_bounded_vlbytes"
] | [] | false | false | false | false | false | let parse_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#sk: parser_kind)
(pk: parser sk (bounded_int32 min max))
: Tot
(parser (parse_bounded_vlgen_kind sk min max parse_all_bytes_kind)
(parse_bounded_vlbytes_t min max)) =
| (parse_bounded_vlgen min max pk serialize_all_bytes) `parse_synth` (synth_bounded_vlbytes min max) | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake | val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed)) | val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed)) | let frodo_gen_matrix_shake n seed res =
push_frame ();
let r = create (size 2 *! n) (u8 0) in
let tmp_seed = create 18ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake1 (v n) (as_seq h0 seed) in
[@ inline_let]
let inv h (i:nat{i <= v n}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res) in
Loops.eq_repeati0 (v n) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul n inv
(fun i ->
Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake1 n tmp_seed r i res);
pop_frame () | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 130,
"start_col": 0,
"start_line": 106
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16)
inline_for_extraction noextract private
val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let frodo_gen_matrix_shake1 n tmp_seed r i res =
concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res
)
val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed)) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"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 |
n:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v n /\ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 } ->
seed: Hacl.Impl.Matrix.lbytes 16ul ->
res: Hacl.Impl.Matrix.matrix_t n n
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Hacl.Impl.Matrix.lbytes",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Matrix.matrix_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.Loops.for",
"Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake1",
"Lib.LoopCombinators.unfold_repeati",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Matrix.elem",
"Lib.IntTypes.op_Star_Bang",
"Lib.LoopCombinators.eq_repeati0",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.logical",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Lib.IntTypes.uint8",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"Prims.l_Forall",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"Lib.Sequence.seq",
"FStar.Seq.Base.length",
"Lib.LoopCombinators.repeati",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.Frodo.Gen.frodo_gen_matrix_shake1",
"Lib.Sequence.eq_intro",
"FStar.HyperStack.ST.get",
"Lib.Buffer.memset",
"Lib.IntTypes.u16",
"Lib.Buffer.copy",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.U8",
"FStar.UInt32.uint_to_t",
"Lib.Buffer.sub",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.mul",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.size",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let frodo_gen_matrix_shake n seed res =
| push_frame ();
let r = create (size 2 *! n) (u8 0) in
let tmp_seed = create 18ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@@ inline_let ]let spec h0 = S.frodo_gen_matrix_shake1 (v n) (as_seq h0 seed) in
[@@ inline_let ]let inv h (i: nat{i <= v n}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res)
in
Loops.eq_repeati0 (v n) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul
n
inv
(fun i ->
Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake1 n tmp_seed r i res);
pop_frame () | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.b64 | val b64 : Type0 | let b64 = buf_t TUInt8 TUInt64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 38,
"start_col": 0,
"start_line": 38
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.buf_t",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt64"
] | [] | false | false | false | true | true | let b64 =
| buf_t TUInt8 TUInt64 | false |
|
ElGamal.fst | ElGamal.elgamal | val elgamal (m: group) : Rand group | val elgamal (m: group) : Rand group | let elgamal (m:group)
: Rand group
= let z = sample () in
g^z | {
"file_name": "examples/rel/ElGamal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 32,
"start_col": 0,
"start_line": 29
} | (*
Copyright 2008-2018 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 ElGamal
open FStar.DM4F.Heap.Random
open FStar.DM4F.Random
open ElGamal.Group
let bij' (m:group) =
let f = fun h -> upd h (to_id 0) ((sel h (to_id 0) - log m) % q) in
let finv = fun h -> upd h (to_id 0) ((sel h (to_id 0) + log m) % q) in
Bijection f finv | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Random.fst.checked",
"FStar.DM4F.Heap.Random.fsti.checked",
"ElGamal.Group.fst.checked"
],
"interface_file": false,
"source_file": "ElGamal.fst"
} | [
{
"abbrev": false,
"full_module": "ElGamal.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.Random",
"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 | m: ElGamal.Group.group -> FStar.DM4F.Random.Rand ElGamal.Group.group | FStar.DM4F.Random.Rand | [] | [] | [
"ElGamal.Group.group",
"ElGamal.Group.op_Hat",
"ElGamal.Group.g",
"FStar.DM4F.Heap.Random.elem",
"FStar.DM4F.Random.sample"
] | [] | false | true | false | false | false | let elgamal (m: group) : Rand group =
| let z = sample () in
g ^ z | false |
Selectors.LList2.fst | Selectors.LList2.intro_llist_nil | val intro_llist_nil (#opened: _) (a:Type0)
: SteelGhost unit opened emp (fun _ -> llist (null_llist #a))
(requires fun _ -> True)
(ensures fun _ _ h1 -> v_llist #a null_llist h1 == []) | val intro_llist_nil (#opened: _) (a:Type0)
: SteelGhost unit opened emp (fun _ -> llist (null_llist #a))
(requires fun _ -> True)
(ensures fun _ _ h1 -> v_llist #a null_llist h1 == []) | let intro_llist_nil a =
intro_vrewrite emp (v_null_rewrite a);
change_equal_slprop
(emp `vrewrite` v_null_rewrite a)
(llist0 (null_llist #a));
llist_of_llist0 (null_llist #a) | {
"file_name": "share/steel/examples/steel/Selectors.LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 33,
"end_line": 232,
"start_col": 0,
"start_line": 227
} | module Selectors.LList2
open Steel.FractionalPermission
module Mem = Steel.Memory
#push-options "--__no_positivity"
noeq
type cell (a: Type0) = {
tail_fuel: Ghost.erased nat;
next: ref (cell a);
data: a;
}
#pop-options
let next #a (c:cell a) : t a = c.next
let data #a (c:cell a) : a = c.data
let mk_cell #a (n: t a) (d:a) = {
tail_fuel = Ghost.hide 0;
next = n;
data = d
}
let null_llist #a = null
let is_null #a ptr = is_null ptr
let v_null_rewrite
(a: Type0)
(_: t_of emp)
: GTot (list a)
= []
let v_c
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: GTot prop
= (Ghost.reveal c.tail_fuel < Ghost.reveal n) == true // to ensure vprop termination
let v_c_dep
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(c: normal (t_of (vrefine (vptr r) (v_c n r))))
: Tot vprop
= nllist c.tail_fuel c.next
let v_c_l_rewrite
(n: Ghost.erased nat)
(#a: Type0)
(r: t a)
(nllist: (n': Ghost.erased nat) -> (r: t a { Ghost.reveal n' < Ghost.reveal n }) -> Pure vprop (requires True) (ensures (fun y -> t_of y == list a)))
(res: normal (t_of ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r nllist)))
: Tot (list a)
= let (| c, l |) = res in
c.data :: l
let rec nllist
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
(decreases (Ghost.reveal n))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
let nllist_eq_not_null
(a: Type0)
(n: Ghost.erased nat)
(r: t a)
: Lemma
(requires (is_null r == false))
(ensures (
nllist a n r == ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
))
= assert_norm (nllist a n r ==
begin if is_null r
then emp `vrewrite` v_null_rewrite a
else ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a)
end
)
let llist_vdep
(#a: Type0)
(r: t a)
(c: normal (t_of (vptr r)))
: Tot vprop
= nllist a c.tail_fuel c.next
let llist_vrewrite
(#a: Type0)
(r: t a)
(cl: normal (t_of (vptr r `vdep` llist_vdep r)))
: GTot (list a)
= (dfst cl).data :: dsnd cl
let llist0
(#a: Type0)
(r: t a)
: Pure vprop
(requires True)
(ensures (fun y -> t_of y == list a))
= if is_null r
then emp `vrewrite` v_null_rewrite a
else (vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r
let nllist_of_llist0
(#opened: _)
(#a: Type0)
(r: t a)
: SteelGhost (Ghost.erased nat) opened
(llist0 r)
(fun res -> nllist a res r)
(fun _ -> True)
(fun h0 res h1 ->
h0 (llist0 r) == h1 (nllist a res r)
)
=
if is_null r
then begin
let res = Ghost.hide 0 in
change_equal_slprop
(llist0 r)
(nllist a res r);
res
end else begin
change_equal_slprop
(llist0 r)
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r);
elim_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
let gk : normal (Ghost.erased (t_of (vptr r))) = elim_vdep (vptr r) (llist_vdep r) in
let res = Ghost.hide (Ghost.reveal (Ghost.reveal gk).tail_fuel + 1) in
intro_vrefine (vptr r) (v_c res r);
intro_vdep
(vptr r `vrefine` v_c res r)
(llist_vdep r (Ghost.reveal gk))
(v_c_dep res r (nllist a));
intro_vrewrite ((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) (v_c_l_rewrite res r (nllist a));
nllist_eq_not_null a res r;
change_equal_slprop
(((vptr r `vrefine` v_c res r) `vdep` v_c_dep res r (nllist a)) `vrewrite` v_c_l_rewrite res r (nllist a))
(nllist a res r);
res
end
let llist0_of_nllist
(#opened: _)
(#a: Type0)
(n: Ghost.erased nat)
(r: t a)
: SteelGhost unit opened
(nllist a n r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 res h1 ->
h1 (llist0 r) == h0 (nllist a n r)
)
=
if is_null r
then begin
change_equal_slprop
(nllist a n r)
(llist0 r);
()
end else begin
nllist_eq_not_null a n r;
change_equal_slprop
(nllist a n r)
(((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) `vrewrite` v_c_l_rewrite n r (nllist a));
elim_vrewrite ((vptr r `vrefine` v_c n r) `vdep` v_c_dep n r (nllist a)) (v_c_l_rewrite n r (nllist a));
let gk = elim_vdep (vptr r `vrefine` v_c n r) (v_c_dep n r (nllist a)) in
elim_vrefine (vptr r) (v_c n r);
intro_vdep
(vptr r)
(v_c_dep n r (nllist a) (Ghost.reveal gk))
(llist_vdep r);
intro_vrewrite (vptr r `vdep` llist_vdep r) (llist_vrewrite r);
change_equal_slprop
((vptr r `vdep` llist_vdep r) `vrewrite` llist_vrewrite r)
(llist0 r)
end
let llist_sl
#a r
= hp_of (llist0 r)
let llist_sel
#a r
= fun m -> sel_of (llist0 r) m // eta necessary because sel_of is GTot
let llist_of_llist0
(#opened: _)
(#a: Type)
(r: t a)
: SteelGhost unit opened
(llist0 r)
(fun _ -> llist r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist r) == h0 (llist0 r))
=
change_slprop_rel
(llist0 r)
(llist r)
(fun x y -> x == y)
(fun _ -> ())
let llist0_of_llist
(#opened: _)
(#a: Type)
(r: t a)
: SteelGhost unit opened
(llist r)
(fun _ -> llist0 r)
(fun _ -> True)
(fun h0 _ h1 -> h1 (llist0 r) == h0 (llist r))
=
change_slprop_rel
(llist r)
(llist0 r)
(fun x y -> x == y)
(fun _ -> ()) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Selectors.LList2.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"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": "Selectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Selectors",
"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 | a: Type0 -> Steel.Effect.Atomic.SteelGhost Prims.unit | Steel.Effect.Atomic.SteelGhost | [] | [] | [
"Steel.Memory.inames",
"Selectors.LList2.llist_of_llist0",
"Selectors.LList2.null_llist",
"Prims.unit",
"Steel.Effect.Atomic.change_equal_slprop",
"Steel.Effect.Common.vrewrite",
"Steel.Effect.Common.emp",
"Prims.list",
"Selectors.LList2.v_null_rewrite",
"Selectors.LList2.llist0",
"Steel.Effect.Atomic.intro_vrewrite"
] | [] | false | true | false | false | false | let intro_llist_nil a =
| intro_vrewrite emp (v_null_rewrite a);
change_equal_slprop (emp `vrewrite` (v_null_rewrite a)) (llist0 (null_llist #a));
llist_of_llist0 (null_llist #a) | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.t64_mod | val t64_mod : Vale.Interop.Base.td | let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public}) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 100,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.Base.td | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.TD_Buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt64",
"Vale.Interop.Base.Mkbuffer_qualifiers",
"Vale.Arch.HeapTypes_s.Public"
] | [] | false | false | false | true | false | let t64_mod =
| TD_Buffer TUInt8 TUInt64 ({ modified = true; strict_disjointness = false; taint = MS.Public }) | false |
|
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.t64_no_mod | val t64_no_mod : Vale.Interop.Base.td | let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public}) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 104,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public}) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.Base.td | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.TD_Buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt64",
"Vale.Interop.Base.Mkbuffer_qualifiers",
"Vale.Arch.HeapTypes_s.Public"
] | [] | false | false | false | true | false | let t64_no_mod =
| TD_Buffer TUInt8 TUInt64 ({ modified = false; strict_disjointness = false; taint = MS.Public }) | false |
|
ElGamal.fst | ElGamal.elgamal' | val elgamal' (m: group) : Rand group | val elgamal' (m: group) : Rand group | let elgamal' (m:group) : Rand group =
let z = sample () in
(g^z) * m | {
"file_name": "examples/rel/ElGamal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 36,
"start_col": 0,
"start_line": 34
} | (*
Copyright 2008-2018 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 ElGamal
open FStar.DM4F.Heap.Random
open FStar.DM4F.Random
open ElGamal.Group
let bij' (m:group) =
let f = fun h -> upd h (to_id 0) ((sel h (to_id 0) - log m) % q) in
let finv = fun h -> upd h (to_id 0) ((sel h (to_id 0) + log m) % q) in
Bijection f finv
let elgamal (m:group)
: Rand group
= let z = sample () in
g^z | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Random.fst.checked",
"FStar.DM4F.Heap.Random.fsti.checked",
"ElGamal.Group.fst.checked"
],
"interface_file": false,
"source_file": "ElGamal.fst"
} | [
{
"abbrev": false,
"full_module": "ElGamal.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.Random",
"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 | m: ElGamal.Group.group -> FStar.DM4F.Random.Rand ElGamal.Group.group | FStar.DM4F.Random.Rand | [] | [] | [
"ElGamal.Group.group",
"ElGamal.Group.op_Star",
"ElGamal.Group.op_Hat",
"ElGamal.Group.g",
"FStar.DM4F.Heap.Random.elem",
"FStar.DM4F.Random.sample"
] | [] | false | true | false | false | false | let elgamal' (m: group) : Rand group =
| let z = sample () in
(g ^ z) * m | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.length_serialize_bounded_vlgenbytes | val length_serialize_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong})
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlgenbytes min max sk) x) ==
Seq.length (serialize sk (B32.len x)) + B32.length x) | val length_serialize_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong})
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlgenbytes min max sk) x) ==
Seq.length (serialize sk (B32.len x)) + B32.length x) | let length_serialize_bounded_vlgenbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong })
(x: parse_bounded_vlbytes_t min max)
: Lemma
(
Seq.length (serialize (serialize_bounded_vlgenbytes min max sk) x) ==
Seq.length (serialize sk (B32.len x)) + B32.length x
)
= serialize_synth_eq
(parse_bounded_vlgen min max pk serialize_all_bytes)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlgen min max sk serialize_all_bytes)
(synth_bounded_vlbytes_recip min max)
()
x;
serialize_bounded_vlgen_unfold
min
max
sk
serialize_all_bytes
x | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 323,
"start_col": 0,
"start_line": 299
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes
inline_for_extraction
let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x
let serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes' min max l))
= serialize_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
let serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (serializer (parse_bounded_vlbytes min max))
= serialize_bounded_vlbytes' min max (log256' max)
let length_serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x)
= serialize_synth_eq
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
x
let length_serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes min max) x) == log256' max + B32.length x)
= length_serialize_bounded_vlbytes' min max (log256' max) x
let parse_bounded_vlgenbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(#sk: parser_kind)
(pk: parser sk (bounded_int32 min max))
: Tot (parser (parse_bounded_vlgen_kind sk min max parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlgen min max pk serialize_all_bytes `parse_synth` synth_bounded_vlbytes min max
let serialize_bounded_vlgenbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong })
: Tot (serializer (parse_bounded_vlgenbytes min max pk))
= serialize_synth
(parse_bounded_vlgen min max pk serialize_all_bytes)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlgen min max sk serialize_all_bytes)
(synth_bounded_vlbytes_recip min max)
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"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 /\ max > 0 /\ max < 4294967296} ->
sk:
LowParse.Spec.Base.serializer pk
{ Mkparser_kind'?.parser_kind_subkind kk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
x: LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.length (LowParse.Spec.Base.serialize (LowParse.Spec.Bytes.serialize_bounded_vlgenbytes
min
max
sk)
x) ==
FStar.Seq.Base.length (LowParse.Spec.Base.serialize sk (FStar.Bytes.len x)) +
FStar.Bytes.length x) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"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.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.VLGen.serialize_bounded_vlgen_unfold",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"Prims.unit",
"LowParse.Spec.Combinators.serialize_synth_eq",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.Bytes.synth_bounded_vlbytes",
"LowParse.Spec.VLGen.serialize_bounded_vlgen",
"LowParse.Spec.Bytes.synth_bounded_vlbytes_recip",
"Prims.l_True",
"Prims.squash",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.Bytes.parse_bounded_vlgenbytes",
"LowParse.Spec.Bytes.serialize_bounded_vlgenbytes",
"Prims.op_Addition",
"FStar.Bytes.len",
"FStar.Bytes.length",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let length_serialize_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong})
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlgenbytes min max sk) x) ==
Seq.length (serialize sk (B32.len x)) + B32.length x) =
| serialize_synth_eq (parse_bounded_vlgen min max pk serialize_all_bytes)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlgen min max sk serialize_all_bytes)
(synth_bounded_vlbytes_recip min max)
()
x;
serialize_bounded_vlgen_unfold min max sk serialize_all_bytes x | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.decode_templong_t | val decode_templong_t : i:size_nat{i <= 8} -> Type0 | val decode_templong_t : i:size_nat{i <= 8} -> Type0 | let decode_templong_t i = uint64 | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 194,
"start_col": 0,
"start_line": 194
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64
let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8
val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n
let frodo_key_encode2 logq b n a i res =
let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res
val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n
let frodo_key_encode logq b n a =
let res = create n n in
Loops.repeati n (frodo_key_encode2 logq b n a) res
val frodo_key_decode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> templong:uint64
-> uint64
let frodo_key_decode0 logq b n a i k templong =
templong |. to_u64 (dc logq b a.(i, k)) <<. size (b * k)
val frodo_key_decode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> i:size_nat{i < n}
-> templong:uint64
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8)
let frodo_key_decode1 logq b n i templong res =
update_sub res (i * b) b (LSeq.sub (uint_to_bytes_le templong) 0 b) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"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 | i: Lib.IntTypes.size_nat{i <= 8} -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.uint64"
] | [] | false | false | false | false | true | let decode_templong_t i =
| uint64 | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.rotate_r | val rotate_r (#a: eqtype) (#b: Type) (t: tree a b) : tree a b | val rotate_r (#a: eqtype) (#b: Type) (t: tree a b) : tree a b | let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 10,
"end_line": 29,
"start_col": 0,
"start_line": 26
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> 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.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"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 | t: Vale.Lib.MapTree.tree a b -> Vale.Lib.MapTree.tree a b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.tree",
"Prims.nat",
"Vale.Lib.MapTree.mkNode"
] | [] | false | false | false | false | false | let rotate_r (#a: eqtype) (#b: Type) (t: tree a b) : tree a b =
| match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.