effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | val skip_o_rules:ref bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let skip_o_rules: ref bool = alloc false | val skip_o_rules:ref bool
let skip_o_rules:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false | false | true | Options.fst | {
"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"
} | null | val skip_o_rules:ref bool | [] | Options.skip_o_rules | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 40,
"end_line": 64,
"start_col": 29,
"start_line": 64
} |
FStar.All.ML | val compute_options (ignore: list string) : ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let compute_options = compute_options_2 | val compute_options (ignore: list string) : ML string
let compute_options = | true | null | false | compute_options_2 | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Options.compute_options_2"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2 | false | false | Options.fst | {
"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"
} | null | val compute_options (ignore: list string) : ML string | [] | Options.compute_options | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | ignore: Prims.list Prims.string -> FStar.All.ML Prims.string | {
"end_col": 39,
"end_line": 386,
"start_col": 22,
"start_line": 386
} |
Prims.Tot | val micro_step:ref (option (valid_string valid_micro_step)) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let micro_step : ref (option (valid_string valid_micro_step)) = alloc None | val micro_step:ref (option (valid_string valid_micro_step))
let micro_step:ref (option (valid_string valid_micro_step)) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_micro_step",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false | false | true | Options.fst | {
"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"
} | null | val micro_step:ref (option (valid_string valid_micro_step)) | [] | Options.micro_step | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_micro_step)) | {
"end_col": 74,
"end_line": 74,
"start_col": 64,
"start_line": 74
} |
Prims.Tot | val makefile_name:ref (option vstring) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let makefile_name : ref (option vstring) = alloc None | val makefile_name:ref (option vstring)
let makefile_name:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false | false | true | Options.fst | {
"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"
} | null | val makefile_name:ref (option vstring) | [] | Options.makefile_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 53,
"end_line": 85,
"start_col": 43,
"start_line": 85
} |
FStar.All.ML | val get_save_hashes : unit -> ML bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_save_hashes () =
!save_hashes | val get_save_hashes : unit -> ML bool
let get_save_hashes () = | true | null | false | !save_hashes | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.save_hashes"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None | false | false | Options.fst | {
"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"
} | null | val get_save_hashes : unit -> ML bool | [] | Options.get_save_hashes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 14,
"end_line": 452,
"start_col": 2,
"start_line": 452
} |
Prims.Tot | val z3_diff_test:ref (option (valid_string valid_equate_types)) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None | val z3_diff_test:ref (option (valid_string valid_equate_types))
let z3_diff_test:ref (option (valid_string valid_equate_types)) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_equate_types",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false | false | true | Options.fst | {
"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"
} | null | val z3_diff_test:ref (option (valid_string valid_equate_types)) | [] | Options.z3_diff_test | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_equate_types)) | {
"end_col": 77,
"end_line": 119,
"start_col": 67,
"start_line": 119
} |
FStar.All.ML | val get_skip_c_makefiles : unit -> ML bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_skip_c_makefiles () =
!skip_c_makefiles | val get_skip_c_makefiles : unit -> ML bool
let get_skip_c_makefiles () = | true | null | false | !skip_c_makefiles | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.skip_c_makefiles"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup | false | false | Options.fst | {
"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"
} | null | val get_skip_c_makefiles : unit -> ML bool | [] | Options.get_skip_c_makefiles | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 19,
"end_line": 438,
"start_col": 2,
"start_line": 438
} |
Prims.Tot | val strip_suffix (fn: string) (sfx: string{ends_with fn sfx}) : string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx) | val strip_suffix (fn: string) (sfx: string{ends_with fn sfx}) : string
let strip_suffix (fn: string) (sfx: string{ends_with fn sfx}) : string = | false | null | false | String.sub fn 0 (String.length fn - String.length sfx) | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Prims.string",
"Prims.b2t",
"Options.ends_with",
"FStar.String.sub",
"Prims.op_Subtraction",
"FStar.String.length"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx }) | false | false | Options.fst | {
"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"
} | null | val strip_suffix (fn: string) (sfx: string{ends_with fn sfx}) : string | [] | Options.strip_suffix | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fn: Prims.string -> sfx: Prims.string{Options.ends_with fn sfx} -> Prims.string | {
"end_col": 58,
"end_line": 40,
"start_col": 4,
"start_line": 40
} |
Prims.Tot | val cmd_option_name (a: cmd_option) : Tot string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name' | val cmd_option_name (a: cmd_option) : Tot string
let cmd_option_name (a: cmd_option) : Tot string = | false | null | false | match a with | CmdFStarOption (_, name', _, _) | CmdOption name' _ _ _ -> name' | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Options.cmd_option",
"FStar.Char.char",
"Prims.string",
"FStar.Getopt.opt_variant",
"Prims.unit",
"Options.cmd_option_kind",
"Prims.list"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt | false | true | Options.fst | {
"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"
} | null | val cmd_option_name (a: cmd_option) : Tot string | [] | Options.cmd_option_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | a: Options.cmd_option -> Prims.string | {
"end_col": 12,
"end_line": 166,
"start_col": 2,
"start_line": 163
} |
FStar.All.ML | val get_makefile_name : unit -> ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf | val get_makefile_name : unit -> ML string
let get_makefile_name _ = | true | null | false | match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"OS.concat",
"Prims.string",
"Options.get_output_dir",
"Options.vstring",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.makefile_name"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake | false | false | Options.fst | {
"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"
} | null | val get_makefile_name : unit -> ML string | [] | Options.get_makefile_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.string | {
"end_col": 17,
"end_line": 487,
"start_col": 2,
"start_line": 485
} |
Prims.Tot | val cmd_option_arg_desc (a: cmd_option) : Tot string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end | val cmd_option_arg_desc (a: cmd_option) : Tot string
let cmd_option_arg_desc (a: cmd_option) : Tot string = | false | null | false | match a with
| CmdFStarOption (_, _, arg, _) ->
(match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> "")
| CmdOption _ kind _ _ ->
match kind with
| OptStringOption argdesc _ _ | OptList argdesc _ _ -> argdesc
| _ -> "" | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Options.cmd_option",
"FStar.Char.char",
"Prims.string",
"FStar.Getopt.opt_variant",
"Prims.unit",
"Options.cmd_option_kind",
"Prims.list",
"Prims.bool",
"FStar.ST.ref",
"FStar.Pervasives.Native.option",
"Options.valid_string"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc | false | true | Options.fst | {
"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"
} | null | val cmd_option_arg_desc (a: cmd_option) : Tot string | [] | Options.cmd_option_arg_desc | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | a: Options.cmd_option -> Prims.string | {
"end_col": 7,
"end_line": 192,
"start_col": 2,
"start_line": 180
} |
FStar.All.ML | val get_output_dir : unit -> ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s | val get_output_dir : unit -> ML string
let get_output_dir () = | true | null | false | match !output_dir with
| None -> "."
| Some s -> s | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"Options.vstring",
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.output_dir"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file) | false | false | Options.fst | {
"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"
} | null | val get_output_dir : unit -> ML string | [] | Options.get_output_dir | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.string | {
"end_col": 15,
"end_line": 416,
"start_col": 2,
"start_line": 414
} |
FStar.All.ML | val get_arg0: Prims.unit -> ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v | val get_arg0: Prims.unit -> ML string
let get_arg0 () : ML string = | true | null | false | match !arg0 with
| None -> "3d"
| Some v -> v | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"Options.vstring",
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.arg0"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options | false | false | Options.fst | {
"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"
} | null | val get_arg0: Prims.unit -> ML string | [] | Options.get_arg0 | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.string | {
"end_col": 15,
"end_line": 317,
"start_col": 2,
"start_line": 315
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s | let negate_string_gen (s negation: string) = | false | null | false | if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Prims.string",
"Options.string_starts_with",
"FStar.String.sub",
"FStar.String.length",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.op_Hat"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small | false | true | Options.fst | {
"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"
} | null | val negate_string_gen : s: Prims.string -> negation: Prims.string -> Prims.string | [] | Options.negate_string_gen | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: Prims.string -> negation: Prims.string -> Prims.string | {
"end_col": 19,
"end_line": 212,
"start_col": 2,
"start_line": 210
} |
|
FStar.All.ML | val config_module_name : unit -> ML (option string) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config") | val config_module_name : unit -> ML (option string)
let config_module_name () = | true | null | false | match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config") | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.Pervasives.Native.None",
"Prims.string",
"Options.valid_string",
"Options.check_config_file_name",
"FStar.Pervasives.Native.Some",
"Options.strip_suffix",
"OS.basename",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.config_file"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs | false | false | Options.fst | {
"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"
} | null | val config_module_name : unit -> ML (option string) | [] | Options.config_module_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option Prims.string) | {
"end_col": 62,
"end_line": 534,
"start_col": 2,
"start_line": 532
} |
FStar.All.ML | val get_check_hashes : unit -> ML (option check_hashes_t) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None | val get_check_hashes : unit -> ML (option check_hashes_t)
let get_check_hashes () = | true | null | false | if !batch
then
match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.Pervasives.Native.None",
"HashingOptions.check_hashes_t",
"FStar.Pervasives.Native.Some",
"HashingOptions.WeakHashes",
"HashingOptions.StrongHashes",
"HashingOptions.InplaceHashes",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_check_hashes",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.check_hashes",
"Prims.bool",
"Options.batch"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h | false | false | Options.fst | {
"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"
} | null | val get_check_hashes : unit -> ML (option check_hashes_t) | [] | Options.get_check_hashes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option HashingOptions.check_hashes_t) | {
"end_col": 11,
"end_line": 449,
"start_col": 2,
"start_line": 444
} |
Prims.Tot | val cmd_option_description (a: cmd_option) : Tot string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc | val cmd_option_description (a: cmd_option) : Tot string
let cmd_option_description (a: cmd_option) : Tot string = | false | null | false | match a with | CmdOption _ _ desc _ | CmdFStarOption (_, _, _, desc) -> desc | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Options.cmd_option",
"Prims.string",
"Options.cmd_option_kind",
"Prims.list",
"FStar.Char.char",
"FStar.Getopt.opt_variant",
"Prims.unit"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q | false | true | Options.fst | {
"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"
} | null | val cmd_option_description (a: cmd_option) : Tot string | [] | Options.cmd_option_description | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | a: Options.cmd_option -> Prims.string | {
"end_col": 8,
"end_line": 177,
"start_col": 2,
"start_line": 174
} |
FStar.All.ML | val get_json : unit -> ML bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_json () =
!json | val get_json : unit -> ML bool
let get_json () = | true | null | false | !json | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.json"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules | false | false | Options.fst | {
"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"
} | null | val get_json : unit -> ML bool | [] | Options.get_json | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 7,
"end_line": 493,
"start_col": 2,
"start_line": 493
} |
FStar.All.ML | val get_skip_deps : unit -> ML bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_skip_deps _ =
!skip_deps | val get_skip_deps : unit -> ML bool
let get_skip_deps _ = | true | null | false | !skip_deps | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.skip_deps"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml | false | false | Options.fst | {
"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"
} | null | val get_skip_deps : unit -> ML bool | [] | Options.get_skip_deps | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 12,
"end_line": 476,
"start_col": 2,
"start_line": 476
} |
FStar.All.ML | val get_produce_c_from_existing_krml : unit -> ML bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml | val get_produce_c_from_existing_krml : unit -> ML bool
let get_produce_c_from_existing_krml _ = | true | null | false | !produce_c_from_existing_krml | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.produce_c_from_existing_krml"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig | false | false | Options.fst | {
"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"
} | null | val get_produce_c_from_existing_krml : unit -> ML bool | [] | Options.get_produce_c_from_existing_krml | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 31,
"end_line": 473,
"start_col": 2,
"start_line": 473
} |
FStar.All.ML | val compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options | val compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string = | true | null | false | let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
(match kind with
| OptBool v -> if !v then Printf.sprintf "%s --%s" msg name else msg
| OptStringOption _ _ v ->
(match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v)
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v))
| _ -> msg
in
let msg = List.fold_left print "" !options in
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"FStar.ST.ref",
"Prims.list",
"Options.cmd_option",
"Prims.string",
"FStar.List.fold_left",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Prims.bool",
"FStar.Printf.sprintf",
"Options.negate_name",
"Prims.op_Negation",
"FStar.List.Tot.Base.mem",
"Options.cmd_option_name",
"Options.cmd_option_kind",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"FStar.List.Tot.Base.fold_left",
"FStar.List.Tot.Base.rev"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end | false | false | Options.fst | {
"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"
} | null | val compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string | [] | Options.compute_current_options | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | options: FStar.ST.ref (Prims.list Options.cmd_option) -> ignore: Prims.list Prims.string
-> FStar.All.ML Prims.string | {
"end_col": 44,
"end_line": 312,
"start_col": 96,
"start_line": 275
} |
FStar.All.ML | val get_emit_output_types_defs : unit -> ML bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_emit_output_types_defs () = !emit_output_types_defs | val get_emit_output_types_defs : unit -> ML bool
let get_emit_output_types_defs () = | true | null | false | !emit_output_types_defs | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.emit_output_types_defs"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ()) | false | false | Options.fst | {
"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"
} | null | val get_emit_output_types_defs : unit -> ML bool | [] | Options.get_emit_output_types_defs | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 59,
"end_line": 509,
"start_col": 36,
"start_line": 509
} |
FStar.All.ML | val get_micro_step : unit -> ML (option micro_step_t) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig | val get_micro_step : unit -> ML (option micro_step_t)
let get_micro_step _ = | true | null | false | match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.Pervasives.Native.None",
"HashingOptions.micro_step_t",
"FStar.Pervasives.Native.Some",
"HashingOptions.MicroStepVerify",
"HashingOptions.MicroStepExtract",
"HashingOptions.MicroStepCopyClangFormat",
"HashingOptions.MicroStepEmitConfig",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_micro_step",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.micro_step"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list | false | false | Options.fst | {
"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"
} | null | val get_micro_step : unit -> ML (option micro_step_t) | [] | Options.get_micro_step | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option HashingOptions.micro_step_t) | {
"end_col": 50,
"end_line": 470,
"start_col": 2,
"start_line": 465
} |
FStar.All.ML | val get_module_name (file: string) : ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file) | val get_module_name (file: string) : ML string
let get_module_name (file: string) = | true | null | false | match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file) | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.string",
"Options.split_3d_file_name",
"Options.starts_with_capital",
"Prims.bool",
"FStar.All.failwith",
"FStar.Printf.sprintf"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d" | false | false | Options.fst | {
"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"
} | null | val get_module_name (file: string) : ML string | [] | Options.get_module_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | file: Prims.string -> FStar.All.ML Prims.string | {
"end_col": 83,
"end_line": 411,
"start_col": 4,
"start_line": 406
} |
FStar.All.ML | val get_emit_smt_encoding: unit -> ML bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_emit_smt_encoding () =
!emit_smt_encoding | val get_emit_smt_encoding: unit -> ML bool
let get_emit_smt_encoding () = | true | null | false | !emit_smt_encoding | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.emit_smt_encoding"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config") | false | false | Options.fst | {
"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"
} | null | val get_emit_smt_encoding: unit -> ML bool | [] | Options.get_emit_smt_encoding | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 20,
"end_line": 537,
"start_col": 2,
"start_line": 537
} |
FStar.All.ML | val make_includes : unit -> ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs | val make_includes : unit -> ML string
let make_includes () = | true | null | false | let incs = get_add_include () in
List.Tot.fold_left (fun accu inc -> Printf.sprintf "%s#include %s\n" accu inc) "" incs | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.List.Tot.Base.fold_left",
"Prims.string",
"FStar.Printf.sprintf",
"Prims.list",
"Options.get_add_include"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include | false | false | Options.fst | {
"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"
} | null | val make_includes : unit -> ML string | [] | Options.make_includes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.string | {
"end_col": 8,
"end_line": 529,
"start_col": 22,
"start_line": 519
} |
FStar.ST.STATE | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_z3_executable () =
match !z3_executable with
| None -> "z3"
| Some z3 -> z3 | let get_z3_executable () = | true | null | false | match !z3_executable with
| None -> "z3"
| Some z3 -> z3 | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [] | [
"Prims.unit",
"Options.vstring",
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.z3_executable"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding
let get_z3_test () = !z3_test
let get_z3_pos_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "neg" -> false
| _ -> true
let get_z3_neg_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "pos" -> false
| _ -> true
let get_z3_witnesses () =
match !z3_witnesses with
| None -> 1
| Some s ->
try
let n = OS.int_of_string s in
if n < 1 then 1 else n
with _ -> 1
let get_debug _ = !debug
let get_z3_diff_test _ =
match !z3_diff_test with
| None -> None
| Some s -> let [p1; p2] = String.split [','] s in Some (p1, p2) | false | false | Options.fst | {
"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"
} | null | val get_z3_executable : _: Prims.unit -> FStar.ST.STATE Prims.string | [] | Options.get_z3_executable | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.ST.STATE Prims.string | {
"end_col": 17,
"end_line": 574,
"start_col": 2,
"start_line": 572
} |
|
Prims.Tot | val ends_with (s suffix: string) : bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix' | val ends_with (s suffix: string) : bool
let ends_with (s suffix: string) : bool = | false | null | false | let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else
let suffix' = String.sub s (l - sl) sl in
suffix = suffix' | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Prims.string",
"Prims.op_BarBar",
"Prims.op_GreaterThan",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.b2t",
"Prims.nat",
"FStar.String.strlen",
"FStar.String.sub",
"Prims.op_Subtraction",
"FStar.String.length"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end | false | true | Options.fst | {
"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"
} | null | val ends_with (s suffix: string) : bool | [] | Options.ends_with | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: Prims.string -> suffix: Prims.string -> Prims.bool | {
"end_col": 23,
"end_line": 30,
"start_col": 49,
"start_line": 24
} |
Prims.Tot | val starts_with_capital (s: string) : Tot bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end | val starts_with_capital (s: string) : Tot bool
let starts_with_capital (s: string) : Tot bool = | false | null | false | String.length s >= 1 &&
(let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0) | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Prims.string",
"Prims.op_AmpAmp",
"Prims.op_GreaterThanOrEqual",
"FStar.String.length",
"FStar.String.compare",
"Prims.op_LessThanOrEqual",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.String.strlen",
"FStar.String.sub",
"Prims.bool"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true | false | true | Options.fst | {
"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"
} | null | val starts_with_capital (s: string) : Tot bool | [] | Options.starts_with_capital | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: Prims.string -> Prims.bool | {
"end_col": 5,
"end_line": 22,
"start_col": 2,
"start_line": 19
} |
Prims.Tot | val find_cmd_option (name: string) (l: list cmd_option) : Tot (option cmd_option) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q | val find_cmd_option (name: string) (l: list cmd_option) : Tot (option cmd_option)
let rec find_cmd_option (name: string) (l: list cmd_option) : Tot (option cmd_option) = | false | null | false | match l with
| [] -> None
| a :: q -> if name = cmd_option_name a then Some a else find_cmd_option name q | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Prims.string",
"Prims.list",
"Options.cmd_option",
"FStar.Pervasives.Native.None",
"Prims.op_Equality",
"Options.cmd_option_name",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"Options.find_cmd_option",
"FStar.Pervasives.Native.option"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name' | false | true | Options.fst | {
"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"
} | null | val find_cmd_option (name: string) (l: list cmd_option) : Tot (option cmd_option) | [
"recursion"
] | Options.find_cmd_option | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | name: Prims.string -> l: Prims.list Options.cmd_option
-> FStar.Pervasives.Native.option Options.cmd_option | {
"end_col": 71,
"end_line": 171,
"start_col": 87,
"start_line": 168
} |
FStar.All.ML | val set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies | val set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit = | true | null | false | List.iter (fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ())
implies | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"FStar.ST.ref",
"Prims.list",
"Options.cmd_option",
"Prims.string",
"FStar.List.iter",
"Prims.bool",
"FStar.ST.op_Colon_Equals",
"FStar.Heap.trivial_preorder",
"Prims.unit",
"FStar.Pervasives.Native.option",
"Options.find_cmd_option",
"FStar.ST.op_Bang"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end | false | false | Options.fst | {
"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"
} | null | val set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit | [] | Options.set_implies | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | options: FStar.ST.ref (Prims.list Options.cmd_option) -> implies: Prims.list Prims.string
-> FStar.All.ML Prims.unit | {
"end_col": 11,
"end_line": 201,
"start_col": 2,
"start_line": 195
} |
Prims.Tot | val string_starts_with (big small: string) : Tot bool | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small | val string_starts_with (big small: string) : Tot bool
let string_starts_with (big small: string) : Tot bool = | false | null | false | let small_len = String.length small in
if String.length big < small_len then false else String.sub big 0 small_len = small | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"Prims.string",
"Prims.op_LessThan",
"FStar.String.length",
"Prims.bool",
"Prims.op_Equality",
"FStar.String.sub",
"Prims.nat"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies | false | true | Options.fst | {
"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"
} | null | val string_starts_with (big small: string) : Tot bool | [] | Options.string_starts_with | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | big: Prims.string -> small: Prims.string -> Prims.bool | {
"end_col": 41,
"end_line": 207,
"start_col": 55,
"start_line": 203
} |
FStar.All.ML | val get_clang_format_executable : unit -> ML string | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s | val get_clang_format_executable : unit -> ML string
let get_clang_format_executable () = | true | null | false | match !clang_format_executable with
| None -> ""
| Some s -> s | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"Options.vstring",
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.clang_format_executable"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format | false | false | Options.fst | {
"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"
} | null | val get_clang_format_executable : unit -> ML string | [] | Options.get_clang_format_executable | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.string | {
"end_col": 15,
"end_line": 432,
"start_col": 2,
"start_line": 430
} |
FStar.All.ML | val parse_cmd_line : unit -> ML (list string) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2 | val parse_cmd_line : unit -> ML (list string)
let parse_cmd_line () : ML (list string) = | true | null | false | let open FStar.Getopt in
let res =
FStar.Getopt.parse_cmdline fstar_options
(fun file ->
input_file := file :: !input_file;
Success)
in
match res with
| Success -> !input_file
| Help ->
display_usage ();
exit 0
| Error s ->
FStar.IO.print_string s;
exit 1
| _ -> exit 2 | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.list",
"Prims.string",
"FStar.Heap.trivial_preorder",
"Options.input_file",
"FStar.All.exit",
"Options.display_usage",
"FStar.IO.print_string",
"FStar.Getopt.parse_cmdline_res",
"FStar.Getopt.parse_cmdline",
"Options.fstar_options",
"FStar.Getopt.Success",
"FStar.ST.op_Colon_Equals",
"Prims.Cons"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2 | false | false | Options.fst | {
"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"
} | null | val parse_cmd_line : unit -> ML (list string) | [] | Options.parse_cmd_line | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (Prims.list Prims.string) | {
"end_col": 15,
"end_line": 395,
"start_col": 2,
"start_line": 389
} |
FStar.All.ML | val get_check_inplace_hashes : unit -> ML (list string) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_check_inplace_hashes () =
List.rev !inplace_hashes | val get_check_inplace_hashes : unit -> ML (list string)
let get_check_inplace_hashes () = | true | null | false | List.rev !inplace_hashes | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.List.Tot.Base.rev",
"Options.vstring",
"Prims.list",
"Prims.string",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.inplace_hashes"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes | false | false | Options.fst | {
"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"
} | null | val get_check_inplace_hashes : unit -> ML (list string) | [] | Options.get_check_inplace_hashes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (Prims.list Prims.string) | {
"end_col": 26,
"end_line": 455,
"start_col": 2,
"start_line": 455
} |
Prims.Tot | val fstar_options_of_cmd_option (options: ref (list cmd_option)) (o: cmd_option)
: Tot (list FStar.Getopt.opt) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end | val fstar_options_of_cmd_option (options: ref (list cmd_option)) (o: cmd_option)
: Tot (list FStar.Getopt.opt)
let fstar_options_of_cmd_option (options: ref (list cmd_option)) (o: cmd_option)
: Tot (list FStar.Getopt.opt) = | false | null | false | match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
match kind with
| OptBool v ->
[
(FStar.Getopt.noshort,
name,
FStar.Getopt.ZeroArgs
(fun _ ->
set_implies options implies;
v := true),
desc);
(FStar.Getopt.noshort,
negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := false),
negate_description desc)
]
| OptStringOption arg_desc valid v ->
[
(FStar.Getopt.noshort,
name,
FStar.Getopt.OneArg
((fun (x: string) ->
if valid x
then
(set_implies options implies;
v := Some x)
else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)),
arg_desc),
desc);
(FStar.Getopt.noshort,
negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := None),
negate_description desc)
]
| OptList arg_desc valid v ->
[
(FStar.Getopt.noshort,
name,
FStar.Getopt.OneArg
((fun (x: string) ->
if valid x
then
(set_implies options implies;
v := x :: !v)
else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)),
arg_desc),
desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := []), desc)
] | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"total"
] | [
"FStar.ST.ref",
"Prims.list",
"Options.cmd_option",
"FStar.Getopt.opt",
"Prims.Cons",
"Prims.Nil",
"Prims.string",
"Options.cmd_option_kind",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple4",
"FStar.Char.char",
"FStar.Getopt.opt_variant",
"Prims.unit",
"FStar.Getopt.noshort",
"FStar.Getopt.ZeroArgs",
"FStar.ST.op_Colon_Equals",
"FStar.Heap.trivial_preorder",
"Options.set_implies",
"Options.negate_name",
"Options.negate_description",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"FStar.Getopt.OneArg",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.Some",
"FStar.All.failwith",
"FStar.Printf.sprintf",
"FStar.Pervasives.Native.None",
"FStar.ST.op_Bang"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option) | false | true | Options.fst | {
"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"
} | null | val fstar_options_of_cmd_option (options: ref (list cmd_option)) (o: cmd_option)
: Tot (list FStar.Getopt.opt) | [] | Options.fstar_options_of_cmd_option | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | options: FStar.ST.ref (Prims.list Options.cmd_option) -> o: Options.cmd_option
-> Prims.list FStar.Getopt.opt | {
"end_col": 7,
"end_line": 273,
"start_col": 2,
"start_line": 222
} |
FStar.All.ML | val get_equate_types_list : unit -> ML (list (string & string)) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list | val get_equate_types_list : unit -> ML (list (string & string))
let get_equate_types_list () = | true | null | false | List.map (fun (x: valid_string valid_equate_types) ->
let [a ; b] = String.split [','] x in
(a, b))
!equate_types_list | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.List.map",
"Options.valid_string",
"Options.valid_equate_types",
"FStar.Pervasives.Native.tuple2",
"Prims.string",
"FStar.Pervasives.Native.Mktuple2",
"Prims.list",
"FStar.String.split",
"Prims.Cons",
"FStar.String.char",
"Prims.Nil",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.equate_types_list"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes | false | false | Options.fst | {
"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"
} | null | val get_equate_types_list : unit -> ML (list (string & string)) | [] | Options.get_equate_types_list | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (Prims.list (Prims.string * Prims.string)) | {
"end_col": 22,
"end_line": 462,
"start_col": 2,
"start_line": 458
} |
FStar.All.ML | val get_makefile : unit -> ML (option makefile_type) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake | val get_makefile : unit -> ML (option makefile_type)
let get_makefile _ = | true | null | false | match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.Pervasives.Native.None",
"HashingOptions.makefile_type",
"FStar.Pervasives.Native.Some",
"HashingOptions.MakefileGMake",
"HashingOptions.MakefileNMake",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_makefile",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.makefile"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps | false | false | Options.fst | {
"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"
} | null | val get_makefile : unit -> ML (option makefile_type) | [] | Options.get_makefile | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option HashingOptions.makefile_type) | {
"end_col": 38,
"end_line": 482,
"start_col": 2,
"start_line": 479
} |
FStar.All.ML | val get_config_file : unit -> ML (option string) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s | val get_config_file : unit -> ML (option string)
let get_config_file () = | true | null | false | match !config_file with
| None -> None
| Some s -> Some s | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.Pervasives.Native.None",
"Prims.string",
"Options.valid_string",
"Options.check_config_file_name",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.config_file"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs | false | false | Options.fst | {
"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"
} | null | val get_config_file : unit -> ML (option string) | [] | Options.get_config_file | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option Prims.string) | {
"end_col": 20,
"end_line": 514,
"start_col": 2,
"start_line": 512
} |
FStar.All.ML | val get_z3_witnesses: unit -> ML int | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_z3_witnesses () =
match !z3_witnesses with
| None -> 1
| Some s ->
try
let n = OS.int_of_string s in
if n < 1 then 1 else n
with _ -> 1 | val get_z3_witnesses: unit -> ML int
let get_z3_witnesses () = | true | null | false | match !z3_witnesses with
| None -> 1
| Some s ->
try
let n = OS.int_of_string s in
if n < 1 then 1 else n
with
| _ -> 1 | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"Prims.int",
"Options.vstring",
"FStar.All.try_with",
"Prims.op_LessThan",
"Prims.bool",
"OS.int_of_string",
"Prims.exn",
"FStar.Pervasives.Native.option",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.z3_witnesses"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding
let get_z3_test () = !z3_test
let get_z3_pos_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "neg" -> false
| _ -> true
let get_z3_neg_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "pos" -> false
| _ -> true | false | false | Options.fst | {
"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"
} | null | val get_z3_witnesses: unit -> ML int | [] | Options.get_z3_witnesses | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.int | {
"end_col": 13,
"end_line": 562,
"start_col": 2,
"start_line": 556
} |
FStar.All.ML | val get_z3_test: unit -> ML (option string) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_z3_test () = !z3_test | val get_z3_test: unit -> ML (option string)
let get_z3_test () = | true | null | false | !z3_test | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"Options.z3_test",
"Prims.string"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding | false | false | Options.fst | {
"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"
} | null | val get_z3_test: unit -> ML (option string) | [] | Options.get_z3_test | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option Prims.string) | {
"end_col": 29,
"end_line": 539,
"start_col": 21,
"start_line": 539
} |
FStar.All.ML | val get_save_z3_transcript: unit -> ML (option string) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_save_z3_transcript () = !save_z3_transcript | val get_save_z3_transcript: unit -> ML (option string)
let get_save_z3_transcript () = | true | null | false | !save_z3_transcript | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"Options.save_z3_transcript",
"Prims.string"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding
let get_z3_test () = !z3_test
let get_z3_pos_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "neg" -> false
| _ -> true
let get_z3_neg_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "pos" -> false
| _ -> true
let get_z3_witnesses () =
match !z3_witnesses with
| None -> 1
| Some s ->
try
let n = OS.int_of_string s in
if n < 1 then 1 else n
with _ -> 1
let get_debug _ = !debug
let get_z3_diff_test _ =
match !z3_diff_test with
| None -> None
| Some s -> let [p1; p2] = String.split [','] s in Some (p1, p2)
let get_z3_executable () =
match !z3_executable with
| None -> "z3"
| Some z3 -> z3 | false | false | Options.fst | {
"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"
} | null | val get_save_z3_transcript: unit -> ML (option string) | [] | Options.get_save_z3_transcript | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option Prims.string) | {
"end_col": 51,
"end_line": 576,
"start_col": 32,
"start_line": 576
} |
FStar.All.ML | val get_add_include : unit -> ML (list string) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_add_include () =
!add_include | val get_add_include : unit -> ML (list string)
let get_add_include () = | true | null | false | !add_include | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.list",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"Options.add_include",
"Prims.string"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s | false | false | Options.fst | {
"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"
} | null | val get_add_include : unit -> ML (list string) | [] | Options.get_add_include | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (Prims.list Prims.string) | {
"end_col": 14,
"end_line": 517,
"start_col": 2,
"start_line": 517
} |
FStar.All.ML | val get_input_stream_binding : unit -> ML input_stream_binding_t | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ()) | val get_input_stream_binding : unit -> ML input_stream_binding_t
let get_input_stream_binding _ = | true | null | false | let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None | Some "buffer" -> InputStreamBuffer
| Some "extern" -> InputStreamExtern (get_include ())
| Some "static" -> InputStreamStatic (get_include ()) | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"HashingOptions.InputStreamBuffer",
"HashingOptions.input_stream_binding_t",
"HashingOptions.InputStreamExtern",
"Prims.string",
"HashingOptions.InputStreamStatic",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_input_stream_binding",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.input_stream_binding",
"FStar.Pervasives.st_post_h",
"FStar.Monotonic.Heap.heap",
"Prims.l_Forall",
"Prims.pure_post",
"Prims.l_imp",
"Prims.guard_free",
"Prims.l_and",
"Prims.l_not",
"Prims.b2t",
"Options.vstring",
"Options.input_stream_include"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json | false | false | Options.fst | {
"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"
} | null | val get_input_stream_binding : unit -> ML input_stream_binding_t | [] | Options.get_input_stream_binding | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML HashingOptions.input_stream_binding_t | {
"end_col": 38,
"end_line": 507,
"start_col": 32,
"start_line": 495
} |
FStar.All.ML | val get_z3_diff_test: unit -> ML (option (string & string)) | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"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
}
] | false | let get_z3_diff_test _ =
match !z3_diff_test with
| None -> None
| Some s -> let [p1; p2] = String.split [','] s in Some (p1, p2) | val get_z3_diff_test: unit -> ML (option (string & string))
let get_z3_diff_test _ = | true | null | false | match !z3_diff_test with
| None -> None
| Some s ->
let [p1 ; p2] = String.split [','] s in
Some (p1, p2) | {
"checked_file": "Options.fst.checked",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"Prims.string",
"Options.valid_string",
"Options.valid_equate_types",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"Prims.list",
"FStar.String.split",
"Prims.Cons",
"FStar.String.char",
"Prims.Nil",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.z3_diff_test"
] | [] | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of FStar.Getopt.opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, name', _, _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, _, _, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption (_, _, arg, _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list FStar.Getopt.opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
(FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true), desc);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
),
desc
);
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := []),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption ('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdFStarOption (let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline fstar_options (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding
let get_z3_test () = !z3_test
let get_z3_pos_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "neg" -> false
| _ -> true
let get_z3_neg_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "pos" -> false
| _ -> true
let get_z3_witnesses () =
match !z3_witnesses with
| None -> 1
| Some s ->
try
let n = OS.int_of_string s in
if n < 1 then 1 else n
with _ -> 1
let get_debug _ = !debug | false | false | Options.fst | {
"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"
} | null | val get_z3_diff_test: unit -> ML (option (string & string)) | [] | Options.get_z3_diff_test | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML (FStar.Pervasives.Native.option (Prims.string * Prims.string)) | {
"end_col": 66,
"end_line": 569,
"start_col": 2,
"start_line": 567
} |
FStar.Pervasives.Lemma | val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma
(ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s) | val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma
(ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s))
let lemma_sum_pow_seq_bound #n s = | false | null | true | lemma_sum_pow_seq_bound_rec s (length s) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.natN",
"Vale.Bignum.Lemmas.lemma_sum_pow_seq_bound_rec",
"FStar.Seq.Base.length",
"Prims.unit"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_sum_pow_seq_bound (#n:nat) (s:seq (natN n)) : Lemma
(ensures 0 <= sum_pow_seq s /\ sum_pow_seq s < pow_int n (length s)) | [] | Vale.Bignum.Lemmas.lemma_sum_pow_seq_bound | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n)
-> FStar.Pervasives.Lemma
(ensures
0 <= Vale.Bignum.Defs.sum_pow_seq s /\
Vale.Bignum.Defs.sum_pow_seq s < Vale.Bignum.Defs.pow_int n (FStar.Seq.Base.length s)) | {
"end_col": 42,
"end_line": 48,
"start_col": 2,
"start_line": 48
} |
FStar.Pervasives.Lemma | val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
) | val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b)
let rec lemma_pow_nat a b = | false | null | true | if b > 0
then
(lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.op_GreaterThan",
"FStar.Math.Lemmas.nat_times_nat_is_nat",
"Vale.Bignum.Defs.pow_int",
"Prims.op_Subtraction",
"Prims.unit",
"Vale.Bignum.Lemmas.lemma_pow_nat",
"Prims.bool"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_pow_nat (a:nat) (b:nat) : Lemma (0 <= pow_int a b) | [
"recursion"
] | Vale.Bignum.Lemmas.lemma_pow_nat | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures 0 <= Vale.Bignum.Defs.pow_int a b) | {
"end_col": 3,
"end_line": 18,
"start_col": 2,
"start_line": 15
} |
FStar.Pervasives.Lemma | val lemma_add_lo_mul_right (#n:nat) (a b:natN n) (c:nat1) (m:int) : Lemma
(add_lo a b c * m == (let x = a * m + b * m + c * m in if a + b + c < n then x else x - n * m)) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all () | val lemma_add_lo_mul_right (#n:nat) (a b:natN n) (c:nat1) (m:int) : Lemma
(add_lo a b c * m == (let x = a * m + b * m + c * m in if a + b + c < n then x else x - n * m))
let lemma_add_lo_mul_right #n a b c m = | false | null | true | reveal_add_lo_all () | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.nat1",
"Prims.int",
"Vale.Bignum.Defs.reveal_add_lo_all",
"Prims.unit"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver | false | false | Vale.Bignum.Lemmas.fst | {
"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",
"smt.arith.nl=true"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_add_lo_mul_right (#n:nat) (a b:natN n) (c:nat1) (m:int) : Lemma
(add_lo a b c * m == (let x = a * m + b * m + c * m in if a + b + c < n then x else x - n * m)) | [] | Vale.Bignum.Lemmas.lemma_add_lo_mul_right | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Vale.Def.Words_s.natN n -> b: Vale.Def.Words_s.natN n -> c: Vale.Def.Words_s.nat1 -> m: Prims.int
-> FStar.Pervasives.Lemma
(ensures
Vale.Bignum.Defs.add_lo a b c * m ==
(let x = a * m + b * m + c * m in
(match a + b + c < n with
| true -> x
| _ -> x - n * m)
<:
Prims.int)) | {
"end_col": 22,
"end_line": 62,
"start_col": 2,
"start_line": 62
} |
FStar.Pervasives.Lemma | val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma
(requires i <= j /\ j <= length s)
(ensures sum_seq_left s i j == sum_seq_right s i j) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j | val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma
(requires i <= j /\ j <= length s)
(ensures sum_seq_left s i j == sum_seq_right s i j)
let lemma_sum_seq_left_right s i j = | false | null | true | lemma_sum_seq_left_right_rec s i j j | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Prims.int",
"Prims.nat",
"Vale.Bignum.Lemmas.lemma_sum_seq_left_right_rec",
"Prims.unit"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_sum_seq_left_right (s:seq int) (i j:nat) : Lemma
(requires i <= j /\ j <= length s)
(ensures sum_seq_left s i j == sum_seq_right s i j) | [] | Vale.Bignum.Lemmas.lemma_sum_seq_left_right | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq Prims.int -> i: Prims.nat -> j: Prims.nat
-> FStar.Pervasives.Lemma (requires i <= j /\ j <= FStar.Seq.Base.length s)
(ensures Vale.Bignum.Defs.sum_seq_left s i j == Vale.Bignum.Defs.sum_seq_right s i j) | {
"end_col": 38,
"end_line": 12,
"start_col": 2,
"start_line": 12
} |
FStar.Pervasives.Lemma | val lemma_seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Lemma
(requires length bs == length as0)
(ensures (
let (xs, ci) = seq_add as0 bs c0 in
sum_pow_seq xs + last_carry n (length as0) ci == sum_pow_seq as0 + sum_pow_seq bs + c0
)) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let lemma_seq_add #n as0 bs c0 =
lemma_seq_add_rec as0 bs c0 (length as0) | val lemma_seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Lemma
(requires length bs == length as0)
(ensures (
let (xs, ci) = seq_add as0 bs c0 in
sum_pow_seq xs + last_carry n (length as0) ci == sum_pow_seq as0 + sum_pow_seq bs + c0
))
let lemma_seq_add #n as0 bs c0 = | false | null | true | lemma_seq_add_rec as0 bs c0 (length as0) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.nat1",
"Vale.Bignum.Lemmas.lemma_seq_add_rec",
"FStar.Seq.Base.length",
"Prims.unit"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all ()
#pop-options
let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i)
=
if (i > 0) then (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc (==) {
sum_pow_seq_left xs i + last_carry n i ci;
== {}
xs.[i'] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
== {lemma_seq_add_rec as0 bs c0 i'}
xs.[i'] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 - last_carry n i' ci' + last_carry n i ci;
== {
reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[i'] bs.[i'] ci' (pow_int n i')
}
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}
) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_seq_add (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) : Lemma
(requires length bs == length as0)
(ensures (
let (xs, ci) = seq_add as0 bs c0 in
sum_pow_seq xs + last_carry n (length as0) ci == sum_pow_seq as0 + sum_pow_seq bs + c0
)) | [] | Vale.Bignum.Lemmas.lemma_seq_add | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
as0: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
c0: Vale.Def.Words_s.nat1
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length bs == FStar.Seq.Base.length as0)
(ensures
(let _ = Vale.Bignum.Lemmas.seq_add as0 bs c0 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ xs ci = _ in
Vale.Bignum.Defs.sum_pow_seq xs +
Vale.Bignum.Lemmas.last_carry n (FStar.Seq.Base.length as0) ci ==
Vale.Bignum.Defs.sum_pow_seq as0 + Vale.Bignum.Defs.sum_pow_seq bs + c0)
<:
Type0)) | {
"end_col": 42,
"end_line": 95,
"start_col": 2,
"start_line": 95
} |
FStar.Pervasives.Lemma | val lemma_seq_scale_carry (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma
(ensures (
snd (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) == 0
)) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let lemma_seq_scale_carry #n a bs d =
reveal_add_hi_all ();
reveal_mul_lo_all ();
reveal_mul_hi_all ();
let l = length bs in
if l = 0 then assert (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 0 == 0)
else if n = 1 then lemma_seq_scale_carry1 a bs d (l + 1)
else (
lemma_mul_n_bound a bs.[l - 1];
lemma_mul_div_n_lt a bs.[l - 1];
()
) | val lemma_seq_scale_carry (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma
(ensures (
snd (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) == 0
))
let lemma_seq_scale_carry #n a bs d = | false | null | true | reveal_add_hi_all ();
reveal_mul_lo_all ();
reveal_mul_hi_all ();
let l = length bs in
if l = 0
then assert (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 0 == 0)
else
if n = 1
then lemma_seq_scale_carry1 a bs d (l + 1)
else
(lemma_mul_n_bound a bs.[ l - 1 ];
lemma_mul_div_n_lt a bs.[ l - 1 ];
()) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Vale.Def.Words_s.natN",
"FStar.Seq.Base.seq",
"Prims.op_Equality",
"Prims.int",
"Prims._assert",
"Prims.eq2",
"Vale.Bignum.Lemmas.seq_add_c",
"Vale.Bignum.Lemmas.seq_scale_lo",
"Vale.Bignum.Lemmas.seq_scale_hi",
"Prims.bool",
"Vale.Bignum.Lemmas.lemma_seq_scale_carry1",
"Prims.op_Addition",
"Prims.unit",
"Vale.Bignum.Defs.lemma_mul_div_n_lt",
"Vale.Bignum.Lemmas.op_String_Access",
"Prims.op_Subtraction",
"Vale.Bignum.Defs.lemma_mul_n_bound",
"FStar.Seq.Base.length",
"Vale.Bignum.Defs.reveal_mul_hi_all",
"Vale.Bignum.Defs.reveal_mul_lo_all",
"Vale.Bignum.Defs.reveal_add_hi_all"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all ()
#pop-options
let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i)
=
if (i > 0) then (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc (==) {
sum_pow_seq_left xs i + last_carry n i ci;
== {}
xs.[i'] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
== {lemma_seq_add_rec as0 bs c0 i'}
xs.[i'] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 - last_carry n i' ci' + last_carry n i ci;
== {
reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[i'] bs.[i'] ci' (pow_int n i')
}
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}
)
let lemma_seq_add #n as0 bs c0 =
lemma_seq_add_rec as0 bs c0 (length as0)
#push-options "--z3rlimit 100 --z3cliopt smt.arith.nl=true --max_ifuel 0"
#restart-solver
let rec lemma_seq_scale_rec (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat) : Lemma
(requires i <= length bs)
(ensures (
a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)
))
(decreases i)
=
reveal_mul_lo_all ();
reveal_mul_hi_all ();
if i = 0 then (
assert (sum_pow_seq_left (seq_scale_hi a bs d) 0 == 0);
assert (sum_pow_seq_left (seq_scale_hi a bs d) 1 == d)
) else (
lemma_seq_scale_rec a bs d (i - 1)
)
#pop-options
let rec lemma_seq_scale_carry1 (a:natN 1) (bs:seq (natN 1)) (d:natN 1) (i:nat) : Lemma
(requires i <= length bs + 1)
(ensures (
seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0
))
=
reveal_add_hi_all ();
if i > 0 then lemma_seq_scale_carry1 a bs d (i - 1) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_seq_scale_carry (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma
(ensures (
snd (seq_add (seq_scale_lo a bs) (seq_scale_hi a bs d) 0) == 0
)) | [] | Vale.Bignum.Lemmas.lemma_seq_scale_carry | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Vale.Def.Words_s.natN n ->
bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
d: Vale.Def.Words_s.natN n
-> FStar.Pervasives.Lemma
(ensures
FStar.Pervasives.Native.snd (Vale.Bignum.Lemmas.seq_add (Vale.Bignum.Lemmas.seq_scale_lo a bs)
(Vale.Bignum.Lemmas.seq_scale_hi a bs d)
0) ==
0) | {
"end_col": 3,
"end_line": 137,
"start_col": 2,
"start_line": 127
} |
FStar.Pervasives.Lemma | val lemma_sum_seq_left_right_rec (s: seq int) (i j k: nat)
: Lemma (requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k | val lemma_sum_seq_left_right_rec (s: seq int) (i j k: nat)
: Lemma (requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
let rec lemma_sum_seq_left_right_rec (s: seq int) (i j k: nat)
: Lemma (requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j) = | false | null | true | if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma",
""
] | [
"FStar.Seq.Base.seq",
"Prims.int",
"Prims.nat",
"Prims.op_LessThan",
"Vale.Bignum.Lemmas.lemma_sum_seq_left_right_rec",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Prims.squash",
"Prims.eq2",
"Prims.op_Addition",
"Vale.Bignum.Defs.sum_seq_left",
"Vale.Bignum.Defs.sum_seq_right",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_sum_seq_left_right_rec (s: seq int) (i j k: nat)
: Lemma (requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j) | [
"recursion"
] | Vale.Bignum.Lemmas.lemma_sum_seq_left_right_rec | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq Prims.int -> i: Prims.nat -> j: Prims.nat -> k: Prims.nat
-> FStar.Pervasives.Lemma (requires i <= j /\ j <= k /\ k <= FStar.Seq.Base.length s)
(ensures
Vale.Bignum.Defs.sum_seq_left s i j + Vale.Bignum.Defs.sum_seq_right s j k ==
Vale.Bignum.Defs.sum_seq_right s i k)
(decreases j) | {
"end_col": 58,
"end_line": 9,
"start_col": 2,
"start_line": 9
} |
FStar.Pervasives.Lemma | val lemma_seq_scale_carry1 (a: natN 1) (bs: seq (natN 1)) (d: natN 1) (i: nat)
: Lemma (requires i <= length bs + 1)
(ensures (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let rec lemma_seq_scale_carry1 (a:natN 1) (bs:seq (natN 1)) (d:natN 1) (i:nat) : Lemma
(requires i <= length bs + 1)
(ensures (
seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0
))
=
reveal_add_hi_all ();
if i > 0 then lemma_seq_scale_carry1 a bs d (i - 1) | val lemma_seq_scale_carry1 (a: natN 1) (bs: seq (natN 1)) (d: natN 1) (i: nat)
: Lemma (requires i <= length bs + 1)
(ensures (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0))
let rec lemma_seq_scale_carry1 (a: natN 1) (bs: seq (natN 1)) (d: natN 1) (i: nat)
: Lemma (requires i <= length bs + 1)
(ensures (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0)) = | false | null | true | reveal_add_hi_all ();
if i > 0 then lemma_seq_scale_carry1 a bs d (i - 1) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Vale.Def.Words_s.natN",
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.op_GreaterThan",
"Vale.Bignum.Lemmas.lemma_seq_scale_carry1",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.unit",
"Vale.Bignum.Defs.reveal_add_hi_all",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Prims.squash",
"Prims.eq2",
"Prims.int",
"Vale.Bignum.Lemmas.seq_add_c",
"Vale.Bignum.Lemmas.seq_scale_lo",
"Vale.Bignum.Lemmas.seq_scale_hi",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all ()
#pop-options
let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i)
=
if (i > 0) then (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc (==) {
sum_pow_seq_left xs i + last_carry n i ci;
== {}
xs.[i'] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
== {lemma_seq_add_rec as0 bs c0 i'}
xs.[i'] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 - last_carry n i' ci' + last_carry n i ci;
== {
reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[i'] bs.[i'] ci' (pow_int n i')
}
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}
)
let lemma_seq_add #n as0 bs c0 =
lemma_seq_add_rec as0 bs c0 (length as0)
#push-options "--z3rlimit 100 --z3cliopt smt.arith.nl=true --max_ifuel 0"
#restart-solver
let rec lemma_seq_scale_rec (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat) : Lemma
(requires i <= length bs)
(ensures (
a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)
))
(decreases i)
=
reveal_mul_lo_all ();
reveal_mul_hi_all ();
if i = 0 then (
assert (sum_pow_seq_left (seq_scale_hi a bs d) 0 == 0);
assert (sum_pow_seq_left (seq_scale_hi a bs d) 1 == d)
) else (
lemma_seq_scale_rec a bs d (i - 1)
)
#pop-options
let rec lemma_seq_scale_carry1 (a:natN 1) (bs:seq (natN 1)) (d:natN 1) (i:nat) : Lemma
(requires i <= length bs + 1)
(ensures (
seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0
)) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_seq_scale_carry1 (a: natN 1) (bs: seq (natN 1)) (d: natN 1) (i: nat)
: Lemma (requires i <= length bs + 1)
(ensures (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0)) | [
"recursion"
] | Vale.Bignum.Lemmas.lemma_seq_scale_carry1 | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Vale.Def.Words_s.natN 1 ->
bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN 1) ->
d: Vale.Def.Words_s.natN 1 ->
i: Prims.nat
-> FStar.Pervasives.Lemma (requires i <= FStar.Seq.Base.length bs + 1)
(ensures
Vale.Bignum.Lemmas.seq_add_c (Vale.Bignum.Lemmas.seq_scale_lo a bs)
(Vale.Bignum.Lemmas.seq_scale_hi a bs d)
0
i ==
0) | {
"end_col": 53,
"end_line": 124,
"start_col": 2,
"start_line": 123
} |
FStar.Pervasives.Lemma | val lemma_seq_scale_rec (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat)
: Lemma (requires i <= length bs)
(ensures
(a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)))
(decreases i) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let rec lemma_seq_scale_rec (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat) : Lemma
(requires i <= length bs)
(ensures (
a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)
))
(decreases i)
=
reveal_mul_lo_all ();
reveal_mul_hi_all ();
if i = 0 then (
assert (sum_pow_seq_left (seq_scale_hi a bs d) 0 == 0);
assert (sum_pow_seq_left (seq_scale_hi a bs d) 1 == d)
) else (
lemma_seq_scale_rec a bs d (i - 1)
) | val lemma_seq_scale_rec (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat)
: Lemma (requires i <= length bs)
(ensures
(a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)))
(decreases i)
let rec lemma_seq_scale_rec (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat)
: Lemma (requires i <= length bs)
(ensures
(a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)))
(decreases i) = | false | null | true | reveal_mul_lo_all ();
reveal_mul_hi_all ();
if i = 0
then
(assert (sum_pow_seq_left (seq_scale_hi a bs d) 0 == 0);
assert (sum_pow_seq_left (seq_scale_hi a bs d) 1 == d))
else (lemma_seq_scale_rec a bs d (i - 1)) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma",
""
] | [
"Prims.nat",
"Vale.Def.Words_s.natN",
"FStar.Seq.Base.seq",
"Prims.op_Equality",
"Prims.int",
"Prims._assert",
"Prims.eq2",
"Vale.Bignum.Defs.sum_pow_seq_left",
"Vale.Bignum.Lemmas.seq_scale_hi",
"Prims.unit",
"Prims.bool",
"Vale.Bignum.Lemmas.lemma_seq_scale_rec",
"Prims.op_Subtraction",
"Vale.Bignum.Defs.reveal_mul_hi_all",
"Vale.Bignum.Defs.reveal_mul_lo_all",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Prims.squash",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Vale.Bignum.Lemmas.seq_scale_lo",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all ()
#pop-options
let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i)
=
if (i > 0) then (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc (==) {
sum_pow_seq_left xs i + last_carry n i ci;
== {}
xs.[i'] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
== {lemma_seq_add_rec as0 bs c0 i'}
xs.[i'] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 - last_carry n i' ci' + last_carry n i ci;
== {
reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[i'] bs.[i'] ci' (pow_int n i')
}
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}
)
let lemma_seq_add #n as0 bs c0 =
lemma_seq_add_rec as0 bs c0 (length as0)
#push-options "--z3rlimit 100 --z3cliopt smt.arith.nl=true --max_ifuel 0"
#restart-solver
let rec lemma_seq_scale_rec (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat) : Lemma
(requires i <= length bs)
(ensures (
a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)
))
(decreases i) | false | false | Vale.Bignum.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"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": 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",
"smt.arith.nl=true"
],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_seq_scale_rec (#n: nat) (a: natN n) (bs: seq (natN n)) (d: natN n) (i: nat)
: Lemma (requires i <= length bs)
(ensures
(a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)))
(decreases i) | [
"recursion"
] | Vale.Bignum.Lemmas.lemma_seq_scale_rec | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Vale.Def.Words_s.natN n ->
bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
d: Vale.Def.Words_s.natN n ->
i: Prims.nat
-> FStar.Pervasives.Lemma (requires i <= FStar.Seq.Base.length bs)
(ensures
a * Vale.Bignum.Defs.sum_pow_seq_left bs i + d ==
Vale.Bignum.Defs.sum_pow_seq_left (Vale.Bignum.Lemmas.seq_scale_lo a bs) i +
Vale.Bignum.Defs.sum_pow_seq_left (Vale.Bignum.Lemmas.seq_scale_hi a bs d) (i + 1))
(decreases i) | {
"end_col": 3,
"end_line": 114,
"start_col": 2,
"start_line": 107
} |
FStar.Pervasives.Lemma | val lemma_seq_scale (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma
(ensures (
sum_pow_seq (seq_scale a bs d) == sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d) /\
sum_pow_seq (seq_scale a bs d) == a * sum_pow_seq bs + d
)) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let lemma_seq_scale #n a bs d =
let l = length bs in
calc (==) {
sum_pow_seq (seq_scale a bs d);
== {
lemma_seq_scale_carry a bs d;
lemma_seq_add_rec (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 (l + 1)
}
sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d);
};
calc (==) {
sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d);
== {assert (0 * pow_int n l == 0)}
sum_pow_seq_left (seq_scale_lo a bs) l + sum_pow_seq (seq_scale_hi a bs d);
== {lemma_seq_scale_rec a bs d (length bs)}
a * sum_pow_seq bs + d;
} | val lemma_seq_scale (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma
(ensures (
sum_pow_seq (seq_scale a bs d) == sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d) /\
sum_pow_seq (seq_scale a bs d) == a * sum_pow_seq bs + d
))
let lemma_seq_scale #n a bs d = | false | null | true | let l = length bs in
calc ( == ) {
sum_pow_seq (seq_scale a bs d);
( == ) { (lemma_seq_scale_carry a bs d;
lemma_seq_add_rec (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 (l + 1)) }
sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d);
};
calc ( == ) {
sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d);
( == ) { assert (0 * pow_int n l == 0) }
sum_pow_seq_left (seq_scale_lo a bs) l + sum_pow_seq (seq_scale_hi a bs d);
( == ) { lemma_seq_scale_rec a bs d (length bs) }
a * sum_pow_seq bs + d;
} | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Vale.Def.Words_s.natN",
"FStar.Seq.Base.seq",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Addition",
"Vale.Bignum.Defs.sum_pow_seq",
"Vale.Bignum.Lemmas.seq_scale_lo",
"Vale.Bignum.Lemmas.seq_scale_hi",
"FStar.Mul.op_Star",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Vale.Bignum.Defs.sum_pow_seq_left",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims._assert",
"Vale.Bignum.Defs.pow_int",
"Prims.squash",
"Vale.Bignum.Lemmas.lemma_seq_scale_rec",
"FStar.Seq.Base.length",
"Vale.Bignum.Lemmas.seq_scale",
"Vale.Bignum.Lemmas.lemma_seq_add_rec",
"Vale.Bignum.Lemmas.lemma_seq_scale_carry"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all ()
#pop-options
let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i)
=
if (i > 0) then (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc (==) {
sum_pow_seq_left xs i + last_carry n i ci;
== {}
xs.[i'] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
== {lemma_seq_add_rec as0 bs c0 i'}
xs.[i'] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 - last_carry n i' ci' + last_carry n i ci;
== {
reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[i'] bs.[i'] ci' (pow_int n i')
}
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}
)
let lemma_seq_add #n as0 bs c0 =
lemma_seq_add_rec as0 bs c0 (length as0)
#push-options "--z3rlimit 100 --z3cliopt smt.arith.nl=true --max_ifuel 0"
#restart-solver
let rec lemma_seq_scale_rec (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat) : Lemma
(requires i <= length bs)
(ensures (
a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)
))
(decreases i)
=
reveal_mul_lo_all ();
reveal_mul_hi_all ();
if i = 0 then (
assert (sum_pow_seq_left (seq_scale_hi a bs d) 0 == 0);
assert (sum_pow_seq_left (seq_scale_hi a bs d) 1 == d)
) else (
lemma_seq_scale_rec a bs d (i - 1)
)
#pop-options
let rec lemma_seq_scale_carry1 (a:natN 1) (bs:seq (natN 1)) (d:natN 1) (i:nat) : Lemma
(requires i <= length bs + 1)
(ensures (
seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0
))
=
reveal_add_hi_all ();
if i > 0 then lemma_seq_scale_carry1 a bs d (i - 1)
let lemma_seq_scale_carry #n a bs d =
reveal_add_hi_all ();
reveal_mul_lo_all ();
reveal_mul_hi_all ();
let l = length bs in
if l = 0 then assert (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 0 == 0)
else if n = 1 then lemma_seq_scale_carry1 a bs d (l + 1)
else (
lemma_mul_n_bound a bs.[l - 1];
lemma_mul_div_n_lt a bs.[l - 1];
()
) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_seq_scale (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) : Lemma
(ensures (
sum_pow_seq (seq_scale a bs d) == sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d) /\
sum_pow_seq (seq_scale a bs d) == a * sum_pow_seq bs + d
)) | [] | Vale.Bignum.Lemmas.lemma_seq_scale | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Vale.Def.Words_s.natN n ->
bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
d: Vale.Def.Words_s.natN n
-> FStar.Pervasives.Lemma
(ensures
Vale.Bignum.Defs.sum_pow_seq (Vale.Bignum.Lemmas.seq_scale a bs d) ==
Vale.Bignum.Defs.sum_pow_seq (Vale.Bignum.Lemmas.seq_scale_lo a bs) +
Vale.Bignum.Defs.sum_pow_seq (Vale.Bignum.Lemmas.seq_scale_hi a bs d) /\
Vale.Bignum.Defs.sum_pow_seq (Vale.Bignum.Lemmas.seq_scale a bs d) ==
a * Vale.Bignum.Defs.sum_pow_seq bs + d) | {
"end_col": 3,
"end_line": 155,
"start_col": 31,
"start_line": 139
} |
FStar.Pervasives.Lemma | val lemma_scale_add (#n:nat) (l:nat) (a d:natN n) (bs rs ys zs qs xs:seq (natN n)) : Lemma
(requires length bs == l /\ length rs == l + 1 /\ rs.[l] == 0)
(ensures (
let c0 = 0 in
let ys = init (l + 1) (ys_init a bs) in
let zs = init (l + 1) (zs_init a bs d) in
let (qs, qc) = seq_add rs zs c0 in
let (xs, xc) = seq_add qs ys c0 in
sum_pow_seq xs == sum_pow_seq rs + a * sum_pow_seq bs + d /\ qc == 0 /\ xc == 0
)) | [
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let lemma_scale_add #n l a d bs rs ys zs qs xs =
let ys = init (l + 1) (ys_init a bs) in
let zs = init (l + 1) (zs_init a bs d) in
let c0 = 0 in
let o1 = 0 in
let (qs, _) = seq_add rs zs c0 in
let (xs, _) = seq_add qs ys c0 in
assert (equal ys (seq_scale_lo a bs));
assert (equal zs (seq_scale_hi a bs d));
lemma_sum_pow_seq_bound bs;
lemma_sum_pow_seq_bound xs;
lemma_sum_pow_seq_bound qs;
lemma_sum_pow_seq_bound_rec rs l;
lemma_mul_nat_bound a (n - 1) (sum_pow_seq bs) (pow_int n l - 1);
lemma_seq_add qs ys c0;
lemma_seq_add rs zs o1;
lemma_seq_scale a bs d;
() | val lemma_scale_add (#n:nat) (l:nat) (a d:natN n) (bs rs ys zs qs xs:seq (natN n)) : Lemma
(requires length bs == l /\ length rs == l + 1 /\ rs.[l] == 0)
(ensures (
let c0 = 0 in
let ys = init (l + 1) (ys_init a bs) in
let zs = init (l + 1) (zs_init a bs d) in
let (qs, qc) = seq_add rs zs c0 in
let (xs, xc) = seq_add qs ys c0 in
sum_pow_seq xs == sum_pow_seq rs + a * sum_pow_seq bs + d /\ qc == 0 /\ xc == 0
))
let lemma_scale_add #n l a d bs rs ys zs qs xs = | false | null | true | let ys = init (l + 1) (ys_init a bs) in
let zs = init (l + 1) (zs_init a bs d) in
let c0 = 0 in
let o1 = 0 in
let qs, _ = seq_add rs zs c0 in
let xs, _ = seq_add qs ys c0 in
assert (equal ys (seq_scale_lo a bs));
assert (equal zs (seq_scale_hi a bs d));
lemma_sum_pow_seq_bound bs;
lemma_sum_pow_seq_bound xs;
lemma_sum_pow_seq_bound qs;
lemma_sum_pow_seq_bound_rec rs l;
lemma_mul_nat_bound a (n - 1) (sum_pow_seq bs) (pow_int n l - 1);
lemma_seq_add qs ys c0;
lemma_seq_add rs zs o1;
lemma_seq_scale a bs d;
() | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Vale.Def.Words_s.natN",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat1",
"Prims.unit",
"Vale.Bignum.Lemmas.lemma_seq_scale",
"Vale.Bignum.Lemmas.lemma_seq_add",
"Vale.Bignum.Defs.lemma_mul_nat_bound",
"Prims.op_Subtraction",
"Vale.Bignum.Defs.sum_pow_seq",
"Vale.Bignum.Defs.pow_int",
"Vale.Bignum.Lemmas.lemma_sum_pow_seq_bound_rec",
"Vale.Bignum.Lemmas.lemma_sum_pow_seq_bound",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.Bignum.Lemmas.seq_scale_hi",
"Vale.Bignum.Lemmas.seq_scale_lo",
"FStar.Pervasives.Native.tuple2",
"Vale.Bignum.Lemmas.seq_add",
"Prims.int",
"FStar.Seq.Base.init",
"Prims.op_Addition",
"Vale.Bignum.Lemmas.zs_init",
"Vale.Bignum.Lemmas.ys_init"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all ()
#pop-options
let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i)
=
if (i > 0) then (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc (==) {
sum_pow_seq_left xs i + last_carry n i ci;
== {}
xs.[i'] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
== {lemma_seq_add_rec as0 bs c0 i'}
xs.[i'] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 - last_carry n i' ci' + last_carry n i ci;
== {
reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[i'] bs.[i'] ci' (pow_int n i')
}
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}
)
let lemma_seq_add #n as0 bs c0 =
lemma_seq_add_rec as0 bs c0 (length as0)
#push-options "--z3rlimit 100 --z3cliopt smt.arith.nl=true --max_ifuel 0"
#restart-solver
let rec lemma_seq_scale_rec (#n:nat) (a:natN n) (bs:seq (natN n)) (d:natN n) (i:nat) : Lemma
(requires i <= length bs)
(ensures (
a * sum_pow_seq_left bs i + d ==
sum_pow_seq_left (seq_scale_lo a bs) i + sum_pow_seq_left (seq_scale_hi a bs d) (i + 1)
))
(decreases i)
=
reveal_mul_lo_all ();
reveal_mul_hi_all ();
if i = 0 then (
assert (sum_pow_seq_left (seq_scale_hi a bs d) 0 == 0);
assert (sum_pow_seq_left (seq_scale_hi a bs d) 1 == d)
) else (
lemma_seq_scale_rec a bs d (i - 1)
)
#pop-options
let rec lemma_seq_scale_carry1 (a:natN 1) (bs:seq (natN 1)) (d:natN 1) (i:nat) : Lemma
(requires i <= length bs + 1)
(ensures (
seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 i == 0
))
=
reveal_add_hi_all ();
if i > 0 then lemma_seq_scale_carry1 a bs d (i - 1)
let lemma_seq_scale_carry #n a bs d =
reveal_add_hi_all ();
reveal_mul_lo_all ();
reveal_mul_hi_all ();
let l = length bs in
if l = 0 then assert (seq_add_c (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 0 == 0)
else if n = 1 then lemma_seq_scale_carry1 a bs d (l + 1)
else (
lemma_mul_n_bound a bs.[l - 1];
lemma_mul_div_n_lt a bs.[l - 1];
()
)
let lemma_seq_scale #n a bs d =
let l = length bs in
calc (==) {
sum_pow_seq (seq_scale a bs d);
== {
lemma_seq_scale_carry a bs d;
lemma_seq_add_rec (seq_scale_lo a bs) (seq_scale_hi a bs d) 0 (l + 1)
}
sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d);
};
calc (==) {
sum_pow_seq (seq_scale_lo a bs) + sum_pow_seq (seq_scale_hi a bs d);
== {assert (0 * pow_int n l == 0)}
sum_pow_seq_left (seq_scale_lo a bs) l + sum_pow_seq (seq_scale_hi a bs d);
== {lemma_seq_scale_rec a bs d (length bs)}
a * sum_pow_seq bs + d;
} | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_scale_add (#n:nat) (l:nat) (a d:natN n) (bs rs ys zs qs xs:seq (natN n)) : Lemma
(requires length bs == l /\ length rs == l + 1 /\ rs.[l] == 0)
(ensures (
let c0 = 0 in
let ys = init (l + 1) (ys_init a bs) in
let zs = init (l + 1) (zs_init a bs d) in
let (qs, qc) = seq_add rs zs c0 in
let (xs, xc) = seq_add qs ys c0 in
sum_pow_seq xs == sum_pow_seq rs + a * sum_pow_seq bs + d /\ qc == 0 /\ xc == 0
)) | [] | Vale.Bignum.Lemmas.lemma_scale_add | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
l: Prims.nat ->
a: Vale.Def.Words_s.natN n ->
d: Vale.Def.Words_s.natN n ->
bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
rs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
ys: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
zs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
qs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
xs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n)
-> FStar.Pervasives.Lemma
(requires FStar.Seq.Base.length bs == l /\ FStar.Seq.Base.length rs == l + 1 /\ rs.[ l ] == 0)
(ensures
(let c0 = 0 in
let ys = FStar.Seq.Base.init (l + 1) (Vale.Bignum.Lemmas.ys_init a bs) in
let zs = FStar.Seq.Base.init (l + 1) (Vale.Bignum.Lemmas.zs_init a bs d) in
let _ = Vale.Bignum.Lemmas.seq_add rs zs c0 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ qs qc = _ in
let _ = Vale.Bignum.Lemmas.seq_add qs ys c0 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ xs xc = _ in
Vale.Bignum.Defs.sum_pow_seq xs ==
Vale.Bignum.Defs.sum_pow_seq rs + a * Vale.Bignum.Defs.sum_pow_seq bs + d /\ qc == 0 /\
xc == 0)
<:
Type0)
<:
Type0)) | {
"end_col": 4,
"end_line": 174,
"start_col": 48,
"start_line": 157
} |
FStar.Pervasives.Lemma | val lemma_sum_pow_seq_bound_rec (#n: nat) (s: seq (natN n)) (i: nat{i <= length s})
: Lemma (ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
) | val lemma_sum_pow_seq_bound_rec (#n: nat) (s: seq (natN n)) (i: nat{i <= length s})
: Lemma (ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
let rec lemma_sum_pow_seq_bound_rec (#n: nat) (s: seq (natN n)) (i: nat{i <= length s})
: Lemma (ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i) = | false | null | true | let open FStar.Math.Lemmas in
if i > 0
then
(calc ( <= ) {
0;
( <= ) { lemma_sum_pow_seq_bound_rec s (i - 1) }
sum_pow_seq_left s (i - 1);
( <= ) { (lemma_pow_nat n (i - 1);
nat_times_nat_is_nat s.[ i - 1 ] (pow_int n (i - 1))) }
s.[ i - 1 ] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
( == ) { () }
sum_pow_seq_left s i;
};
calc ( <= ) {
sum_pow_seq_left s i + 1;
( == ) { () }
s.[ i - 1 ] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
( <= ) { lemma_sum_pow_seq_bound_rec s (i - 1) }
s.[ i - 1 ] * pow_int n (i - 1) + pow_int n (i - 1);
( <= ) { (lemma_pow_nat n (i - 1);
lemma_mult_le_right (pow_int n (i - 1)) s.[ i - 1 ] (n - 1)) }
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
( == ) { () }
pow_int n i;
}) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.natN",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Prims.op_GreaterThan",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.op_Addition",
"Vale.Bignum.Defs.sum_pow_seq_left",
"Vale.Bignum.Defs.pow_int",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.eq2",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Vale.Bignum.Lemmas.op_String_Access",
"Vale.Bignum.Defs.sum_seq_left",
"Vale.Bignum.Defs.pow_seq",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Vale.Bignum.Lemmas.lemma_sum_pow_seq_bound_rec",
"FStar.Math.Lemmas.lemma_mult_le_right",
"Vale.Bignum.Lemmas.lemma_pow_nat",
"FStar.Math.Lemmas.nat_times_nat_is_nat",
"Prims.bool",
"Prims.l_True",
"Prims.l_and",
"Prims.op_LessThan",
"FStar.Pervasives.pattern"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_sum_pow_seq_bound_rec (#n: nat) (s: seq (natN n)) (i: nat{i <= length s})
: Lemma (ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i) | [
"recursion"
] | Vale.Bignum.Lemmas.lemma_sum_pow_seq_bound_rec | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> i: Prims.nat{i <= FStar.Seq.Base.length s}
-> FStar.Pervasives.Lemma
(ensures
0 <= Vale.Bignum.Defs.sum_pow_seq_left s i /\
Vale.Bignum.Defs.sum_pow_seq_left s i < Vale.Bignum.Defs.pow_int n i) | {
"end_col": 3,
"end_line": 45,
"start_col": 2,
"start_line": 23
} |
FStar.Pervasives.Lemma | val lemma_seq_add_rec (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat)
: Lemma (requires i <= length as0 /\ length bs == length as0)
(ensures
(let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci ==
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0))
(decreases i) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum.Defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Bignum",
"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
}
] | false | let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i)
=
if (i > 0) then (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc (==) {
sum_pow_seq_left xs i + last_carry n i ci;
== {}
xs.[i'] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
== {lemma_seq_add_rec as0 bs c0 i'}
xs.[i'] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 - last_carry n i' ci' + last_carry n i ci;
== {
reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[i'] bs.[i'] ci' (pow_int n i')
}
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}
) | val lemma_seq_add_rec (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat)
: Lemma (requires i <= length as0 /\ length bs == length as0)
(ensures
(let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci ==
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0))
(decreases i)
let rec lemma_seq_add_rec (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat)
: Lemma (requires i <= length as0 /\ length bs == length as0)
(ensures
(let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci ==
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0))
(decreases i) = | false | null | true | if (i > 0)
then
(let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
let i' = i - 1 in
let ci' = seq_add_c as0 bs c0 i' in
calc ( == ) {
sum_pow_seq_left xs i + last_carry n i ci;
( == ) { () }
xs.[ i' ] * pow_int n i' + sum_pow_seq_left xs i' + last_carry n i ci;
( == ) { lemma_seq_add_rec as0 bs c0 i' }
xs.[ i' ] * pow_int n i' + sum_pow_seq_left as0 i' + sum_pow_seq_left bs i' + c0 -
last_carry n i' ci' +
last_carry n i ci;
( == ) { (reveal_add_hi_all ();
lemma_last_carry_mul n i' ci';
lemma_add_lo_mul_right as0.[ i' ] bs.[ i' ] ci' (pow_int n i')) }
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0;
}) | {
"checked_file": "Vale.Bignum.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Bignum.Lemmas.fst"
} | [
"lemma",
""
] | [
"Prims.nat",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.nat1",
"Prims.op_GreaterThan",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Addition",
"Vale.Bignum.Defs.sum_pow_seq_left",
"Vale.Bignum.Lemmas.last_carry",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Vale.Bignum.Lemmas.op_String_Access",
"Vale.Bignum.Defs.pow_int",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Vale.Bignum.Lemmas.lemma_seq_add_rec",
"Vale.Bignum.Lemmas.lemma_add_lo_mul_right",
"Vale.Bignum.Lemmas.lemma_last_carry_mul",
"Vale.Bignum.Defs.reveal_add_hi_all",
"Vale.Bignum.Lemmas.seq_add_c",
"FStar.Pervasives.Native.fst",
"Vale.Bignum.Lemmas.seq_add",
"Prims.bool",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"FStar.Pervasives.pattern"
] | [] | module Vale.Bignum.Lemmas
open FStar.Mul
let rec lemma_sum_seq_left_right_rec (s:seq int) (i j k:nat) : Lemma
(requires i <= j /\ j <= k /\ k <= length s)
(ensures sum_seq_left s i j + sum_seq_right s j k == sum_seq_right s i k)
(decreases j)
=
if i < j then lemma_sum_seq_left_right_rec s i (j - 1) k
let lemma_sum_seq_left_right s i j =
lemma_sum_seq_left_right_rec s i j j
let rec lemma_pow_nat a b =
if b > 0 then (
lemma_pow_nat a (b - 1);
FStar.Math.Lemmas.nat_times_nat_is_nat a (pow_int a (b - 1))
)
let rec lemma_sum_pow_seq_bound_rec (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : Lemma
(ensures 0 <= sum_pow_seq_left s i /\ sum_pow_seq_left s i < pow_int n i)
=
let open FStar.Math.Lemmas in
if i > 0 then (
calc (<=) {
0;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
sum_pow_seq_left s (i - 1);
<= {lemma_pow_nat n (i - 1); nat_times_nat_is_nat s.[i - 1] (pow_int n (i - 1))}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1);
== {}
sum_pow_seq_left s i;
};
calc (<=) {
sum_pow_seq_left s i + 1;
== {}
s.[i - 1] * pow_int n (i - 1) + sum_seq_left (pow_seq s) 0 (i - 1) + 1;
<= {lemma_sum_pow_seq_bound_rec s (i - 1)}
s.[i - 1] * pow_int n (i - 1) + pow_int n (i - 1);
<= {lemma_pow_nat n (i - 1); lemma_mult_le_right (pow_int n (i - 1)) s.[i - 1] (n - 1)}
(n - 1) * pow_int n (i - 1) + pow_int n (i - 1);
== {}
pow_int n i;
}
)
let lemma_sum_pow_seq_bound #n s =
lemma_sum_pow_seq_bound_rec s (length s)
let lemma_seq_add_is_norm #n as0 bs c0 i =
()
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_last_carry_mul a b c =
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#restart-solver
let lemma_add_lo_mul_right #n a b c m =
reveal_add_lo_all ()
#pop-options
let rec lemma_seq_add_rec (#n:nat) (as0 bs:seq (natN n)) (c0:nat1) (i:nat) : Lemma
(requires i <= length as0 /\ length bs == length as0)
(ensures (
let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci == sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0
))
(decreases i) | false | false | Vale.Bignum.Lemmas.fst | {
"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"
} | null | val lemma_seq_add_rec (#n: nat) (as0 bs: seq (natN n)) (c0: nat1) (i: nat)
: Lemma (requires i <= length as0 /\ length bs == length as0)
(ensures
(let xs = fst (seq_add as0 bs c0) in
let ci = seq_add_c as0 bs c0 i in
sum_pow_seq_left xs i + last_carry n i ci ==
sum_pow_seq_left as0 i + sum_pow_seq_left bs i + c0))
(decreases i) | [
"recursion"
] | Vale.Bignum.Lemmas.lemma_seq_add_rec | {
"file_name": "vale/code/crypto/bignum/Vale.Bignum.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
as0: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
bs: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) ->
c0: Vale.Def.Words_s.nat1 ->
i: Prims.nat
-> FStar.Pervasives.Lemma
(requires
i <= FStar.Seq.Base.length as0 /\ FStar.Seq.Base.length bs == FStar.Seq.Base.length as0)
(ensures
(let xs = FStar.Pervasives.Native.fst (Vale.Bignum.Lemmas.seq_add as0 bs c0) in
let ci = Vale.Bignum.Lemmas.seq_add_c as0 bs c0 i in
Vale.Bignum.Defs.sum_pow_seq_left xs i + Vale.Bignum.Lemmas.last_carry n i ci ==
Vale.Bignum.Defs.sum_pow_seq_left as0 i + Vale.Bignum.Defs.sum_pow_seq_left bs i + c0))
(decreases i) | {
"end_col": 3,
"end_line": 92,
"start_col": 2,
"start_line": 74
} |
FStar.Tactics.Effect.Tac | val debug_log (f: (unit -> T.Tac unit)) : T.Tac unit | [
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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
}
] | false | let debug_log (f: unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level_no_module "readback" then f() | val debug_log (f: (unit -> T.Tac unit)) : T.Tac unit
let debug_log (f: (unit -> T.Tac unit)) : T.Tac unit = | true | null | false | if RU.debug_at_level_no_module "readback" then f () | {
"checked_file": "Pulse.Readback.fst.checked",
"dependencies": [
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Readback.fst"
} | [] | [
"Prims.unit",
"Pulse.RuntimeUtils.debug_at_level_no_module",
"Prims.bool"
] | [] | module Pulse.Readback
module R = FStar.Reflection.V2
open Pulse.Syntax.Base
open Pulse.Reflection.Util
module RU = Pulse.RuntimeUtils
module T = FStar.Tactics | false | false | Pulse.Readback.fst | {
"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"
} | null | val debug_log (f: (unit -> T.Tac unit)) : T.Tac unit | [] | Pulse.Readback.debug_log | {
"file_name": "lib/steel/pulse/Pulse.Readback.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | f: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit) -> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 103,
"end_line": 8,
"start_col": 53,
"start_line": 8
} |
Prims.Tot | val readback_qual (q:R.aqualv)
: option qualifier | [
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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
}
] | false | let readback_qual = function
| R.Q_Implicit -> Some Implicit
| _ -> None | val readback_qual (q:R.aqualv)
: option qualifier
let readback_qual = | false | null | false | function
| R.Q_Implicit -> Some Implicit
| _ -> None | {
"checked_file": "Pulse.Readback.fst.checked",
"dependencies": [
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Readback.fst"
} | [
"total"
] | [
"FStar.Reflection.V2.Data.aqualv",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.qualifier",
"Pulse.Syntax.Base.Implicit",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | module Pulse.Readback
module R = FStar.Reflection.V2
open Pulse.Syntax.Base
open Pulse.Reflection.Util
module RU = Pulse.RuntimeUtils
module T = FStar.Tactics
module P = Pulse.Syntax.Printer
let debug_log (f: unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level_no_module "readback" then f()
let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b =
match f with
| None -> None
| Some x -> g x
#push-options "--z3rlimit_factor 20"
// TODO: FIXME: may be mark as opaque_to_smt
let try_readback_st_comp
(t:R.term)
(readback_ty:(t':R.term ->
option (ty:term { elab_term ty == t' })))
: option (c:comp{elab_comp c == t}) =
let open R in
let hd, args = collect_app_ln t in
match inspect_ln hd with
| Tv_UInst fv [u] ->
let fv_lid = inspect_fv fv in
if fv_lid = stt_lid
then match args with
| [res; pre; post] ->
(match inspect_ln (fst post) with
| Tv_Abs b body ->
let { qual=aq; attrs=attrs; sort=sort } =
inspect_binder b
in
assume (fv == stt_fv);
assume (aq == Q_Explicit /\
attrs == [] /\
sort == fst res /\
snd res == Q_Explicit /\
snd pre == Q_Explicit /\
snd post == Q_Explicit);
assume (t == mk_stt_comp u (fst res) (fst pre) (mk_abs (fst res) R.Q_Explicit body));
let? res' = readback_ty (fst res) in
let? pre' = readback_ty (fst pre) in
let? post' = readback_ty body in
let c = C_ST {u; res=res'; pre=pre';post=post'} in
Some (c <: c:Pulse.Syntax.Base.comp{ elab_comp c == t })
| _ -> None)
| _ -> None
else if fv_lid = stt_atomic_lid || fv_lid = stt_ghost_lid
then match args with
| [res; opened; pre; post] ->
(match inspect_ln (fst post) with
| Tv_Abs b body ->
let { qual=aq; attrs=attrs }
= inspect_binder b
in
let? res' = readback_ty (fst res) in
let? opened' = readback_ty (fst opened) in
let? pre' = readback_ty (fst pre) in
let? post' = readback_ty body in
if fv_lid = stt_atomic_lid
then begin
assume (t == mk_stt_atomic_comp u (fst res) (fst opened) (fst pre) (mk_abs (fst res) R.Q_Explicit body));
let c = C_STAtomic opened' ({u; res=res'; pre=pre';post=post'}) in
Some (c <: c:Pulse.Syntax.Base.comp { elab_comp c == t })
end
else begin
assume (t == mk_stt_ghost_comp u (fst res) (fst opened) (fst pre) (mk_abs (fst res) R.Q_Explicit body));
let c = C_STGhost opened' ({u; res=res'; pre=pre';post=post'}) in
Some (c <: c:Pulse.Syntax.Base.comp { elab_comp c == t })
end
| _ -> None)
| _ -> None
else None
| _ -> None
#pop-options | false | true | Pulse.Readback.fst | {
"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"
} | null | val readback_qual (q:R.aqualv)
: option qualifier | [] | Pulse.Readback.readback_qual | {
"file_name": "lib/steel/pulse/Pulse.Readback.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | q: FStar.Reflection.V2.Data.aqualv -> FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier | {
"end_col": 13,
"end_line": 85,
"start_col": 20,
"start_line": 83
} |
Prims.Tot | val op_let_Question (f: option 'a) (g: ('a -> option 'b)) : option 'b | [
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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
}
] | false | let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b =
match f with
| None -> None
| Some x -> g x | val op_let_Question (f: option 'a) (g: ('a -> option 'b)) : option 'b
let op_let_Question (f: option 'a) (g: ('a -> option 'b)) : option 'b = | false | null | false | match f with
| None -> None
| Some x -> g x | {
"checked_file": "Pulse.Readback.fst.checked",
"dependencies": [
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Readback.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.None"
] | [] | module Pulse.Readback
module R = FStar.Reflection.V2
open Pulse.Syntax.Base
open Pulse.Reflection.Util
module RU = Pulse.RuntimeUtils
module T = FStar.Tactics
module P = Pulse.Syntax.Printer
let debug_log (f: unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level_no_module "readback" then f() | false | false | Pulse.Readback.fst | {
"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"
} | null | val op_let_Question (f: option 'a) (g: ('a -> option 'b)) : option 'b | [] | Pulse.Readback.op_let_Question | {
"file_name": "lib/steel/pulse/Pulse.Readback.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | f: FStar.Pervasives.Native.option 'a -> g: (_: 'a -> FStar.Pervasives.Native.option 'b)
-> FStar.Pervasives.Native.option 'b | {
"end_col": 17,
"end_line": 13,
"start_col": 2,
"start_line": 11
} |
Prims.Tot | val readback_comp (t:R.term)
: option (c:comp{ elab_comp c == t}) | [
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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
}
] | false | let readback_comp (t:R.term)
: option (c:comp { elab_comp c == t }) =
let ropt = try_readback_st_comp t readback_ty in
match ropt with
| Some c ->
// debug_log (fun _ -> T.print (Printf.sprintf "readback_comp: %s as\n%s\n" (T.term_to_string t) (P.comp_to_string c)));
ropt
| _ ->
let? t' = readback_ty t in
Some (C_Tot t' <: c:comp{ elab_comp c == t }) | val readback_comp (t:R.term)
: option (c:comp{ elab_comp c == t})
let readback_comp (t: R.term) : option (c: comp{elab_comp c == t}) = | false | null | false | let ropt = try_readback_st_comp t readback_ty in
match ropt with
| Some c -> ropt
| _ ->
let? t' = readback_ty t in
Some (C_Tot t' <: c: comp{elab_comp c == t}) | {
"checked_file": "Pulse.Readback.fst.checked",
"dependencies": [
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Readback.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"Pulse.Syntax.Base.comp",
"Prims.eq2",
"Pulse.Elaborate.Pure.elab_comp",
"FStar.Pervasives.Native.option",
"Pulse.Readback.op_let_Question",
"Pulse.Syntax.Base.term",
"Pulse.Elaborate.Pure.elab_term",
"Pulse.Readback.readback_ty",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.C_Tot",
"Pulse.Readback.try_readback_st_comp"
] | [] | module Pulse.Readback
module R = FStar.Reflection.V2
open Pulse.Syntax.Base
open Pulse.Reflection.Util
module RU = Pulse.RuntimeUtils
module T = FStar.Tactics
module P = Pulse.Syntax.Printer
let debug_log (f: unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level_no_module "readback" then f()
let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b =
match f with
| None -> None
| Some x -> g x
#push-options "--z3rlimit_factor 20"
// TODO: FIXME: may be mark as opaque_to_smt
let try_readback_st_comp
(t:R.term)
(readback_ty:(t':R.term ->
option (ty:term { elab_term ty == t' })))
: option (c:comp{elab_comp c == t}) =
let open R in
let hd, args = collect_app_ln t in
match inspect_ln hd with
| Tv_UInst fv [u] ->
let fv_lid = inspect_fv fv in
if fv_lid = stt_lid
then match args with
| [res; pre; post] ->
(match inspect_ln (fst post) with
| Tv_Abs b body ->
let { qual=aq; attrs=attrs; sort=sort } =
inspect_binder b
in
assume (fv == stt_fv);
assume (aq == Q_Explicit /\
attrs == [] /\
sort == fst res /\
snd res == Q_Explicit /\
snd pre == Q_Explicit /\
snd post == Q_Explicit);
assume (t == mk_stt_comp u (fst res) (fst pre) (mk_abs (fst res) R.Q_Explicit body));
let? res' = readback_ty (fst res) in
let? pre' = readback_ty (fst pre) in
let? post' = readback_ty body in
let c = C_ST {u; res=res'; pre=pre';post=post'} in
Some (c <: c:Pulse.Syntax.Base.comp{ elab_comp c == t })
| _ -> None)
| _ -> None
else if fv_lid = stt_atomic_lid || fv_lid = stt_ghost_lid
then match args with
| [res; opened; pre; post] ->
(match inspect_ln (fst post) with
| Tv_Abs b body ->
let { qual=aq; attrs=attrs }
= inspect_binder b
in
let? res' = readback_ty (fst res) in
let? opened' = readback_ty (fst opened) in
let? pre' = readback_ty (fst pre) in
let? post' = readback_ty body in
if fv_lid = stt_atomic_lid
then begin
assume (t == mk_stt_atomic_comp u (fst res) (fst opened) (fst pre) (mk_abs (fst res) R.Q_Explicit body));
let c = C_STAtomic opened' ({u; res=res'; pre=pre';post=post'}) in
Some (c <: c:Pulse.Syntax.Base.comp { elab_comp c == t })
end
else begin
assume (t == mk_stt_ghost_comp u (fst res) (fst opened) (fst pre) (mk_abs (fst res) R.Q_Explicit body));
let c = C_STGhost opened' ({u; res=res'; pre=pre';post=post'}) in
Some (c <: c:Pulse.Syntax.Base.comp { elab_comp c == t })
end
| _ -> None)
| _ -> None
else None
| _ -> None
#pop-options
let readback_qual = function
| R.Q_Implicit -> Some Implicit
| _ -> None
// WARNING WARNING WARNING: THIS DEFINITION MAKES THE CONTEXT INCONSISTENT
// #push-options "--admit_smt_queries true"
// let collect_app_refined (t:R.term) : res:(R.term & list R.argv){fst res << t /\ (forall a. L.memP a (snd res) ==> a << t)} =
// R.collect_app_ln t
// #pop-options
// let readback_ty_ascribed (t:R.term { let t = R.inspect_ln t in
// R.Tv_AscribedT? t || R.Tv_AscribedC? t })
// : option (ty:term { elab_term ty == t }) =
// match R.inspect_ln t with
// //
// // The following is dropping the ascription, which is not ideal
// // However, if we don't, then ascriptions start to come in the way of
// // R.term_eq used to decide equality of tm_fstar terms,
// // which then results in framing failures
// //
// // At least in the examples it came up, the ascription was a redundant
// // ascription on F* Tm_Match
// // I tried an F* patch that did not add the ascription, if it was already
// // ascribed, but that failed a couple of proofs in HACL* : (
// //
// | R.Tv_AscribedT t _ _ _
// | R.Tv_AscribedC t _ _ _ -> Some (tm_fstar t (R.range_of_term t))
// #pop-options
let rec readback_ty (t:R.term)
: option (ty:term { elab_term ty == t }) =
let open R in
let open Pulse.Syntax.Base in
let w (res:term') = with_range res (RU.range_of_term t) in
let return (res:term' { elab_term (w res) == t})
: option (ty:term { elab_term ty == t})
= Some (w res)
in
match inspect_ln t with
| Tv_FVar fv ->
let fv_lid = inspect_fv fv in
if fv_lid = vprop_lid
then return Tm_VProp
else if fv_lid = emp_lid
then return Tm_Emp
else if fv_lid = inames_lid
then return Tm_Inames
else if fv_lid = emp_inames_lid
then return Tm_EmpInames
else return (Tm_FStar t)
| Tv_App hd (a, q) ->
admit(); //this case doesn't work because it is using collect_app_ln, etc.
let aux () =
match q with
| R.Q_Meta _ -> None
| _ -> return (Tm_FStar t)
in
let head, args = collect_app_ln t in
begin
match inspect_ln head, args with
| Tv_FVar fv, [a1; a2] ->
if inspect_fv fv = star_lid
then (
let t1 : R.term = fst a1 in
let t2 : R.term = fst a2 in
assume (t1 << t);
assume (t2 << t);
let? t1 = readback_ty t1 in
let? t2 = readback_ty t2 in
return (Tm_Star t1 t2)
)
else aux ()
| Tv_UInst fv [u], [a1; a2] ->
if inspect_fv fv = exists_lid ||
inspect_fv fv = forall_lid
then (
let t1 : R.term = fst a1 in
let t2 : R.term = fst a2 in
let? ty = readback_ty t1 in
let? (ppname, range, p) =
match inspect_ln t2 with
| Tv_Abs b body ->
let? p = readback_ty body in
let bview = inspect_binder b in
Some (bview.ppname, RU.binder_range b, p) <: option (ppname_t & range & term)
| _ -> None in // TODO: FIXME: provide error from this function?
let b = { binder_ty = ty; binder_ppname = mk_ppname ppname range } in
if inspect_fv fv = exists_lid
then return (Tm_ExistsSL u b p)
else return (Tm_ForallSL u b p)
)
else aux ()
| Tv_FVar fv, [a] ->
if inspect_fv fv = pure_lid
then (
let t1 : R.term = fst a in
let? t1 = readback_ty t1 in
return (Tm_Pure t1)
)
else aux ()
| _ -> aux ()
end
| Tv_Refine _ _
| Tv_Arrow _ _
| Tv_Type _
| Tv_Const _
| Tv_Let _ _ _ _ _
| Tv_Var _
| Tv_BVar _
| Tv_UInst _ _
| Tv_Match _ _ _
| Tv_Abs _ _ ->
return (Tm_FStar t)
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
//this case doesn't work because it is unascribing
admit();
readback_ty t
| Tv_Uvar _ _ -> None // TODO: FIXME: T.fail "readback_ty: unexpected Tv_Uvar"
| Tv_Unknown ->
return Tm_Unknown
| Tv_Unsupp -> None | false | false | Pulse.Readback.fst | {
"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"
} | null | val readback_comp (t:R.term)
: option (c:comp{ elab_comp c == t}) | [] | Pulse.Readback.readback_comp | {
"file_name": "lib/steel/pulse/Pulse.Readback.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: FStar.Reflection.Types.term
-> FStar.Pervasives.Native.option (c:
Pulse.Syntax.Base.comp{Pulse.Elaborate.Pure.elab_comp c == t}) | {
"end_col": 49,
"end_line": 223,
"start_col": 42,
"start_line": 214
} |
Prims.Tot | val va_req_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
: prop | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) : prop =
(va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret) | val va_req_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
: prop
let va_req_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
: prop = | false | null | false | (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\
(alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0)
roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\
Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0)
(va_get_reg 4 va_s0)
roundkeys_b
(Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0)
Secret /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0)
hkeys_b
3
(va_get_mem_layout va_s0)
Secret) | {
"checked_file": "Vale.AES.PPC64LE.GF128_Init.fsti.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fsti"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Prims.l_and",
"Vale.PPC64LE.Decls.va_require_total",
"Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.PPC64LE.Memory.is_initial_heap",
"Vale.PPC64LE.Decls.va_get_mem_layout",
"Vale.PPC64LE.Decls.va_get_mem",
"Prims.l_or",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.AES_common_s.AES_256",
"Vale.PPC64LE.Decls.buffers_disjoint128",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Vale.PPC64LE.Decls.buffer128_as_seq",
"Vale.AES.AES_BE_s.key_to_round_keys_word",
"Vale.PPC64LE.Decls.validSrcAddrs128",
"Vale.PPC64LE.Decls.va_get_reg",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.Decls.validDstAddrs128",
"Prims.prop"
] | [] | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- Keyhash_init
val va_code_Keyhash_init : alg:algorithm -> Tot va_code
val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool
let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) | false | true | Vale.AES.PPC64LE.GF128_Init.fsti | {
"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"
} | null | val va_req_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
: prop | [] | Vale.AES.PPC64LE.GF128_Init.va_req_Keyhash_init | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
roundkeys_b: Vale.PPC64LE.Memory.buffer128 ->
hkeys_b: Vale.PPC64LE.Memory.buffer128
-> Prims.prop | {
"end_col": 68,
"end_line": 46,
"start_col": 2,
"start_line": 38
} |
Prims.Tot | val va_wp_Keyhash_init
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128)
(hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem
va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128
roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem
va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\
Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b
(Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_memLayout:vale_heap_layout) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32)
(va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let
va_sM = va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10
(va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem
va_s0)))))))))) in va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem
va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0
0 0 0)) ==> va_k va_sM (()))) | val va_wp_Keyhash_init
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_Keyhash_init
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\
(alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0)
roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\
Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0)
(va_get_reg 4 va_s0)
roundkeys_b
(Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0)
Secret /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0)
hkeys_b
3
(va_get_mem_layout va_s0)
Secret /\
(forall (va_x_mem: vale_heap) (va_x_heap1: vale_heap) (va_x_memLayout: vale_heap_layout)
(va_x_r10: nat64) (va_x_v0: quad32) (va_x_v1: quad32) (va_x_v2: quad32) (va_x_v3: quad32)
(va_x_v4: quad32) (va_x_v5: quad32) (va_x_v6: quad32).
let va_sM =
va_upd_vec 6
va_x_v6
(va_upd_vec 5
va_x_v5
(va_upd_vec 4
va_x_v4
(va_upd_vec 3
va_x_v3
(va_upd_vec 2
va_x_v2
(va_upd_vec 1
va_x_v1
(va_upd_vec 0
va_x_v0
(va_upd_reg 10
va_x_r10
(va_upd_mem_layout va_x_memLayout
(va_upd_mem_heaplet 1
va_x_heap1
(va_upd_mem va_x_mem va_s0))))))))))
in
va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\
Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem va_sM)
hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.AES.PPC64LE.GF128_Init.fsti.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fsti"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.PPC64LE.Memory.is_initial_heap",
"Vale.PPC64LE.Decls.va_get_mem_layout",
"Vale.PPC64LE.Decls.va_get_mem",
"Prims.l_or",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.AES_common_s.AES_256",
"Vale.PPC64LE.Decls.buffers_disjoint128",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Vale.PPC64LE.Decls.buffer128_as_seq",
"Vale.AES.AES_BE_s.key_to_round_keys_word",
"Vale.PPC64LE.Decls.validSrcAddrs128",
"Vale.PPC64LE.Decls.va_get_reg",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.Decls.validDstAddrs128",
"Prims.l_Forall",
"Vale.PPC64LE.InsBasic.vale_heap",
"Vale.Arch.HeapImpl.vale_heap_layout",
"Vale.PPC64LE.Memory.nat64",
"Vale.PPC64LE.Memory.quad32",
"Prims.l_imp",
"Vale.PPC64LE.Decls.modifies_buffer128",
"Vale.AES.OptPublic_BE.hkeys_reqs_pub",
"Vale.PPC64LE.Decls.s128",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec",
"Vale.PPC64LE.Decls.va_upd_reg",
"Vale.PPC64LE.Decls.va_upd_mem_layout",
"Vale.PPC64LE.Decls.va_upd_mem_heaplet",
"Vale.PPC64LE.Decls.va_upd_mem"
] | [] | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- Keyhash_init
val va_code_Keyhash_init : alg:algorithm -> Tot va_code
val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool
let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) : prop =
(va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret)
let va_ens_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) (va_sM:va_state) (va_fM:va_fuel) : prop =
(va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\ va_ensure_total va_b0 va_s0 va_sM
va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0)
(va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0
0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
val va_lemma_Keyhash_init : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) ->
roundkeys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\
Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg
key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))
[@ va_qattr]
let va_wp_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) | false | true | Vale.AES.PPC64LE.GF128_Init.fsti | {
"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"
} | null | val va_wp_Keyhash_init
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.AES.PPC64LE.GF128_Init.va_wp_Keyhash_init | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
roundkeys_b: Vale.PPC64LE.Memory.buffer128 ->
hkeys_b: Vale.PPC64LE.Memory.buffer128 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 33,
"end_line": 101,
"start_col": 2,
"start_line": 83
} |
Prims.Tot | val va_ens_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_sM: va_state)
(va_fM: va_fuel)
: prop | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_ens_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) (va_sM:va_state) (va_fM:va_fuel) : prop =
(va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\ va_ensure_total va_b0 va_s0 va_sM
va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0)
(va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0
0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) | val va_ens_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_sM: va_state)
(va_fM: va_fuel)
: prop
let va_ens_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_sM: va_state)
(va_fM: va_fuel)
: prop = | false | null | false | (va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\
va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\
Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem va_sM)
hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\
va_state_eq va_sM
(va_update_vec 6
va_sM
(va_update_vec 5
va_sM
(va_update_vec 4
va_sM
(va_update_vec 3
va_sM
(va_update_vec 2
va_sM
(va_update_vec 1
va_sM
(va_update_vec 0
va_sM
(va_update_reg 10
va_sM
(va_update_mem_layout va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))
))) | {
"checked_file": "Vale.AES.PPC64LE.GF128_Init.fsti.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fsti"
} | [
"total"
] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.Decls.va_fuel",
"Prims.l_and",
"Vale.AES.PPC64LE.GF128_Init.va_req_Keyhash_init",
"Vale.PPC64LE.Decls.va_ensure_total",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.PPC64LE.Decls.modifies_buffer128",
"Vale.PPC64LE.Decls.va_get_mem",
"Vale.AES.OptPublic_BE.hkeys_reqs_pub",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Vale.PPC64LE.Decls.s128",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_reg",
"Vale.PPC64LE.Decls.va_update_mem_layout",
"Vale.PPC64LE.Decls.va_update_mem_heaplet",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_update_mem",
"Prims.prop"
] | [] | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- Keyhash_init
val va_code_Keyhash_init : alg:algorithm -> Tot va_code
val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool
let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) : prop =
(va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret)
let va_ens_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) | false | true | Vale.AES.PPC64LE.GF128_Init.fsti | {
"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"
} | null | val va_ens_Keyhash_init
(va_b0: va_code)
(va_s0: va_state)
(alg: algorithm)
(key: (seq nat32))
(roundkeys_b hkeys_b: buffer128)
(va_sM: va_state)
(va_fM: va_fuel)
: prop | [] | Vale.AES.PPC64LE.GF128_Init.va_ens_Keyhash_init | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
roundkeys_b: Vale.PPC64LE.Memory.buffer128 ->
hkeys_b: Vale.PPC64LE.Memory.buffer128 ->
va_sM: Vale.PPC64LE.Decls.va_state ->
va_fM: Vale.PPC64LE.Decls.va_fuel
-> Prims.prop | {
"end_col": 63,
"end_line": 57,
"start_col": 2,
"start_line": 49
} |
Prims.Tot | val va_quick_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Keyhash_init alg)) | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES256_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128)
(hkeys_b:buffer128) : (va_quickCode unit (va_code_Keyhash_init alg)) =
(va_QProc (va_code_Keyhash_init alg) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet
1; va_Mod_mem]) (va_wp_Keyhash_init alg key roundkeys_b hkeys_b) (va_wpProof_Keyhash_init alg
key roundkeys_b hkeys_b)) | val va_quick_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Keyhash_init alg))
let va_quick_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Keyhash_init alg)) = | false | null | false | (va_QProc (va_code_Keyhash_init alg)
([
va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem
])
(va_wp_Keyhash_init alg key roundkeys_b hkeys_b)
(va_wpProof_Keyhash_init alg key roundkeys_b hkeys_b)) | {
"checked_file": "Vale.AES.PPC64LE.GF128_Init.fsti.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.OptPublic_BE.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.PPC64LE.GF128_Init.fsti"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_layout",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"Vale.AES.PPC64LE.GF128_Init.va_wp_Keyhash_init",
"Vale.AES.PPC64LE.GF128_Init.va_wpProof_Keyhash_init",
"Vale.PPC64LE.QuickCode.va_quickCode"
] | [] | module Vale.AES.PPC64LE.GF128_Init
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
open Vale.AES.AES_BE_s
open Vale.AES.AES256_helpers_BE
open Vale.AES.PPC64LE.AES
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.AES.OptPublic_BE
//-- Keyhash_init
val va_code_Keyhash_init : alg:algorithm -> Tot va_code
val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool
let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) : prop =
(va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret)
let va_ens_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32))
(roundkeys_b:buffer128) (hkeys_b:buffer128) (va_sM:va_state) (va_fM:va_fuel) : prop =
(va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\ va_ensure_total va_b0 va_s0 va_sM
va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0)
(va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0
0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
val va_lemma_Keyhash_init : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) ->
roundkeys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\
Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128
(va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
(va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\
Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg
key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM
(va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))
[@ va_qattr]
let va_wp_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128)
(hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem
va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128
roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem
va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\
Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b
(Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3
(va_get_mem_layout va_s0) Secret /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap)
(va_x_memLayout:vale_heap_layout) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32)
(va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let
va_sM = va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10
(va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem
va_s0)))))))))) in va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem
va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0
0 0 0)) ==> va_k va_sM (())))
val va_wpProof_Keyhash_init : alg:algorithm -> key:(seq nat32) -> roundkeys_b:buffer128 ->
hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Keyhash_init alg key roundkeys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Keyhash_init alg) ([va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) | false | false | Vale.AES.PPC64LE.GF128_Init.fsti | {
"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"
} | null | val va_quick_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Keyhash_init alg)) | [] | Vale.AES.PPC64LE.GF128_Init.va_quick_Keyhash_init | {
"file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
roundkeys_b: Vale.PPC64LE.Memory.buffer128 ->
hkeys_b: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init alg) | {
"end_col": 29,
"end_line": 116,
"start_col": 2,
"start_line": 113
} |
FStar.Pervasives.Lemma | val lemma_nat_from_uints64_le_4: b:lseq uint64 4 -> Lemma
(nat_from_intseq_le b == v b.[0] + v b.[1] * pow2 64 +
v b.[2] * pow2 64 * pow2 64 + v b.[3] * pow2 64 * pow2 64 * pow2 64) | [
{
"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": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"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
}
] | false | let lemma_nat_from_uints64_le_4 b =
let res = nat_from_intseq_le b in
nat_from_intseq_le_slice_lemma b 1;
nat_from_intseq_le_lemma0 (Seq.slice b 0 1);
assert (res == v b.[0] + pow2 64 * (nat_from_intseq_le (Seq.slice b 1 4)));
nat_from_intseq_le_slice_lemma #U64 #SEC #3 (Seq.slice b 1 4) 1;
nat_from_intseq_le_lemma0 (Seq.slice b 1 2);
assert (nat_from_intseq_le (Seq.slice b 1 4) == v b.[1] + pow2 64 * (nat_from_intseq_le (Seq.slice b 2 4)));
nat_from_intseq_le_slice_lemma #U64 #SEC #2 (Seq.slice b 2 4) 1;
nat_from_intseq_le_lemma0 (Seq.slice b 2 3);
assert (nat_from_intseq_le (Seq.slice b 2 4) == v b.[2] + pow2 64 * (nat_from_intseq_le (Seq.slice b 3 4)));
nat_from_intseq_le_lemma0 (Seq.slice b 3 4);
assert (res == v b.[0] + pow2 64 * (v b.[1] + pow2 64 * (v b.[2] + pow2 64 * v b.[3]))) | val lemma_nat_from_uints64_le_4: b:lseq uint64 4 -> Lemma
(nat_from_intseq_le b == v b.[0] + v b.[1] * pow2 64 +
v b.[2] * pow2 64 * pow2 64 + v b.[3] * pow2 64 * pow2 64 * pow2 64)
let lemma_nat_from_uints64_le_4 b = | false | null | true | let res = nat_from_intseq_le b in
nat_from_intseq_le_slice_lemma b 1;
nat_from_intseq_le_lemma0 (Seq.slice b 0 1);
assert (res == v b.[ 0 ] + pow2 64 * (nat_from_intseq_le (Seq.slice b 1 4)));
nat_from_intseq_le_slice_lemma #U64 #SEC #3 (Seq.slice b 1 4) 1;
nat_from_intseq_le_lemma0 (Seq.slice b 1 2);
assert (nat_from_intseq_le (Seq.slice b 1 4) ==
v b.[ 1 ] + pow2 64 * (nat_from_intseq_le (Seq.slice b 2 4)));
nat_from_intseq_le_slice_lemma #U64 #SEC #2 (Seq.slice b 2 4) 1;
nat_from_intseq_le_lemma0 (Seq.slice b 2 3);
assert (nat_from_intseq_le (Seq.slice b 2 4) ==
v b.[ 2 ] + pow2 64 * (nat_from_intseq_le (Seq.slice b 3 4)));
nat_from_intseq_le_lemma0 (Seq.slice b 3 4);
assert (res == v b.[ 0 ] + pow2 64 * (v b.[ 1 ] + pow2 64 * (v b.[ 2 ] + pow2 64 * v b.[ 3 ]))) | {
"checked_file": "Hacl.Impl.Curve25519.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Lemmas.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Sequence.op_String_Access",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.unit",
"Lib.ByteSequence.nat_from_intseq_le_lemma0",
"FStar.Seq.Base.slice",
"Lib.ByteSequence.nat_from_intseq_le",
"Lib.ByteSequence.nat_from_intseq_le_slice_lemma",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t"
] | [] | module Hacl.Impl.Curve25519.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val lemma_nat_from_uints64_le_4: b:lseq uint64 4 -> Lemma
(nat_from_intseq_le b == v b.[0] + v b.[1] * pow2 64 +
v b.[2] * pow2 64 * pow2 64 + v b.[3] * pow2 64 * pow2 64 * pow2 64) | false | false | Hacl.Impl.Curve25519.Lemmas.fst | {
"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"
} | null | val lemma_nat_from_uints64_le_4: b:lseq uint64 4 -> Lemma
(nat_from_intseq_le b == v b.[0] + v b.[1] * pow2 64 +
v b.[2] * pow2 64 * pow2 64 + v b.[3] * pow2 64 * pow2 64 * pow2 64) | [] | Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Sequence.lseq Lib.IntTypes.uint64 4
-> FStar.Pervasives.Lemma
(ensures
Lib.ByteSequence.nat_from_intseq_le b ==
Lib.IntTypes.v b.[ 0 ] + Lib.IntTypes.v b.[ 1 ] * Prims.pow2 64 +
(Lib.IntTypes.v b.[ 2 ] * Prims.pow2 64) * Prims.pow2 64 +
((Lib.IntTypes.v b.[ 3 ] * Prims.pow2 64) * Prims.pow2 64) * Prims.pow2 64) | {
"end_col": 89,
"end_line": 29,
"start_col": 35,
"start_line": 14
} |
FStar.Tactics.Effect.Tac | val print_st_typing (#g #t #c: _) (d: st_typing g t c) : T.Tac string | [
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"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
}
] | false | let rec print_st_typing #g #t #c (d:st_typing g t c)
: T.Tac string
= match d with
| T_Abs g x q b u body c tt body_typing ->
Printf.sprintf "(T_Abs ... %s)" (print_st_typing body_typing)
| T_STApp _ _ _ _ _ _ _ _ ->
"T_STApp"
| T_Return _ _ _ _ _ _ _ _ _ _ _ ->
"T_Return"
| T_Lift _ _ _ _ d _ ->
Printf.sprintf "(T_Lift %s)" (print_st_typing d)
| T_Bind g e1 e2 c1 c2 b x c d1 _ d2 _ ->
Printf.sprintf "(T_Bind %s %s)" (print_st_typing d1) (print_st_typing d2)
| T_TotBind g e1 e2 t1 c2 b x _ d ->
Printf.sprintf "(T_TotBind %s)" (print_st_typing d)
| T_Frame g e c frame _ body ->
Printf.sprintf "(T_Frame %s %s)" (Pulse.Syntax.Printer.term_to_string frame) (print_st_typing body)
| T_If _ _ _ _ _ _ _ _ _ _ _ ->
"T_If"
| T_Match _ _ _ _ _ _ _ _ _ _ ->
"T_Match"
| T_Equiv g e c c' d eq ->
Printf.sprintf "(T_Equiv %s)"
(print_st_typing d)
// Printf.sprintf "(T_Equiv \n\t{%s}\n\t{%s}\n\t %s)"
// (Pulse.Syntax.Printer.comp_to_string c)
// (Pulse.Syntax.Printer.comp_to_string c')
// (print_st_typing d)
| T_IntroPure _ _ _ _ ->
"T_IntroPure"
| T_Rewrite _ _ _ _ _ ->
"T_Rewrite"
| _ -> "<UNK>" | val print_st_typing (#g #t #c: _) (d: st_typing g t c) : T.Tac string
let rec print_st_typing #g #t #c (d: st_typing g t c) : T.Tac string = | true | null | false | match d with
| T_Abs g x q b u body c tt body_typing ->
Printf.sprintf "(T_Abs ... %s)" (print_st_typing body_typing)
| T_STApp _ _ _ _ _ _ _ _ -> "T_STApp"
| T_Return _ _ _ _ _ _ _ _ _ _ _ -> "T_Return"
| T_Lift _ _ _ _ d _ -> Printf.sprintf "(T_Lift %s)" (print_st_typing d)
| T_Bind g e1 e2 c1 c2 b x c d1 _ d2 _ ->
Printf.sprintf "(T_Bind %s %s)" (print_st_typing d1) (print_st_typing d2)
| T_TotBind g e1 e2 t1 c2 b x _ d -> Printf.sprintf "(T_TotBind %s)" (print_st_typing d)
| T_Frame g e c frame _ body ->
Printf.sprintf "(T_Frame %s %s)"
(Pulse.Syntax.Printer.term_to_string frame)
(print_st_typing body)
| T_If _ _ _ _ _ _ _ _ _ _ _ -> "T_If"
| T_Match _ _ _ _ _ _ _ _ _ _ -> "T_Match"
| T_Equiv g e c c' d eq -> Printf.sprintf "(T_Equiv %s)" (print_st_typing d)
| T_IntroPure _ _ _ _ -> "T_IntroPure"
| T_Rewrite _ _ _ _ _ -> "T_Rewrite"
| _ -> "<UNK>" | {
"checked_file": "Pulse.Typing.Printer.fst.checked",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Typing.Printer.fst"
} | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp",
"Pulse.Typing.st_typing",
"Pulse.Syntax.Base.var",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_None",
"Pulse.Syntax.Base.typ",
"Pulse.Typing.Env.lookup",
"FStar.Pervasives.Native.option",
"Pulse.Syntax.Base.qualifier",
"Pulse.Syntax.Base.binder",
"Pulse.Syntax.Base.universe",
"Prims.l_not",
"FStar.Set.mem",
"Pulse.Syntax.Naming.freevars_st",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty",
"Pulse.Syntax.Pure.tm_type",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Syntax.Naming.open_st_term_nv",
"FStar.Pervasives.Native.Mktuple2",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname",
"FStar.Printf.sprintf",
"Prims.string",
"Pulse.Typing.Printer.print_st_typing",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.comp_st",
"Pulse.Syntax.Pure.tm_arrow",
"Pulse.Typing.as_binder",
"Pulse.Syntax.Base.ctag",
"Prims.bool",
"Prims.l_and",
"Pulse.Syntax.Naming.freevars",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Naming.open_term",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.lift_comp",
"Prims.eq2",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Base.comp_u",
"Pulse.Typing.bind_comp",
"Pulse.Syntax.Base.v_as_nv",
"Pulse.Syntax.Printer.term_to_string",
"FStar.Set.union",
"Pulse.Typing.tm_bool",
"Pulse.Typing.mk_eq2",
"Pulse.Syntax.Pure.u0",
"Pulse.Typing.tm_true",
"Pulse.Typing.tm_false",
"Pulse.Typing.my_erased",
"Pulse.Typing.comp_typing",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"Pulse.Syntax.Base.pattern",
"Pulse.Typing.brs_typing",
"Pulse.Typing.pats_complete",
"FStar.List.Tot.Base.map",
"FStar.Reflection.V2.Data.pattern",
"Pulse.Elaborate.Pure.elab_pat",
"Pulse.Typing.st_equiv",
"Pulse.Typing.tm_prop",
"Pulse.Typing.prop_validity",
"Pulse.Syntax.Base.vprop",
"Pulse.Typing.vprop_equiv"
] | [] | module Pulse.Typing.Printer
module T = FStar.Tactics
open Pulse.Syntax.Printer
open Pulse.Typing
#push-options "--query_stats --ifuel 1 --z3rlimit_factor 4 --split_queries no"
let rec print_st_typing #g #t #c (d:st_typing g t c) | false | false | Pulse.Typing.Printer.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val print_st_typing (#g #t #c: _) (d: st_typing g t c) : T.Tac string | [
"recursion"
] | Pulse.Typing.Printer.print_st_typing | {
"file_name": "lib/steel/pulse/Pulse.Typing.Printer.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | d: Pulse.Typing.st_typing g t c -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 18,
"end_line": 52,
"start_col": 4,
"start_line": 10
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "EverParse3d.Readable",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"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
}
] | false | let triv = B.trivial_preorder LowParse.Bytes.byte | let triv = | false | null | false | B.trivial_preorder LowParse.Bytes.byte | {
"checked_file": "EverParse3d.InputBuffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverParse3d.Readable.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.InputBuffer.fsti"
} | [
"total"
] | [
"LowStar.Buffer.trivial_preorder",
"LowParse.Bytes.byte"
] | [] | module EverParse3d.InputBuffer
module B = LowStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module LPL = LowParse.Low.Base
module R = EverParse3d.Readable
inline_for_extraction | false | true | EverParse3d.InputBuffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val triv : LowStar.Monotonic.Buffer.srel LowParse.Bytes.byte | [] | EverParse3d.InputBuffer.triv | {
"file_name": "src/3d/prelude/buffer/EverParse3d.InputBuffer.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowStar.Monotonic.Buffer.srel LowParse.Bytes.byte | {
"end_col": 49,
"end_line": 12,
"start_col": 11,
"start_line": 12
} |
|
Prims.GTot | val live_input_buffer
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
: GTot Type0 | [
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "EverParse3d.Readable",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "EverParse3d.Readable",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"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
}
] | false | let live_input_buffer
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
: GTot Type0
= LPL.live_slice h (slice_of sl) /\
R.valid_perm h perm_of | val live_input_buffer
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
: GTot Type0
let live_input_buffer
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
: GTot Type0 = | false | null | false | LPL.live_slice h (slice_of sl) /\ R.valid_perm h perm_of | {
"checked_file": "EverParse3d.InputBuffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverParse3d.Readable.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.InputBuffer.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.UInt32.t",
"EverParse3d.InputBuffer.input_buffer_t",
"EverParse3d.Readable.perm",
"LowParse.Bytes.byte",
"LowParse.Slice.__proj__Mkslice__item__base",
"EverParse3d.InputBuffer.triv",
"EverParse3d.InputBuffer.slice_of",
"Prims.l_and",
"LowParse.Slice.live_slice",
"EverParse3d.Readable.valid_perm"
] | [] | module EverParse3d.InputBuffer
module B = LowStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module LPL = LowParse.Low.Base
module R = EverParse3d.Readable
inline_for_extraction
noextract
let triv = B.trivial_preorder LowParse.Bytes.byte
inline_for_extraction
noextract
val input_buffer_t (len: U32.t) : Type0
include LowParse.Low.Base
val slice_of (#len: U32.t) (x: input_buffer_t len) : GTot (sl: slice triv triv { sl.LPL.len == len })
inline_for_extraction
noextract
let slice_length (#len: U32.t) (x: input_buffer_t len) : Tot (v: U32.t { v == (slice_of x).LPL.len }) =
len
let live_input_buffer
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base) | false | false | EverParse3d.InputBuffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val live_input_buffer
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
: GTot Type0 | [] | EverParse3d.InputBuffer.live_input_buffer | {
"file_name": "src/3d/prelude/buffer/EverParse3d.InputBuffer.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
h: FStar.Monotonic.HyperStack.mem ->
sl: EverParse3d.InputBuffer.input_buffer_t len ->
perm_of: EverParse3d.Readable.perm (Mkslice?.base (EverParse3d.InputBuffer.slice_of sl))
-> Prims.GTot Type0 | {
"end_col": 24,
"end_line": 34,
"start_col": 2,
"start_line": 33
} |
Prims.GTot | val valid_input_buffer
(#k: parser_kind)
(#t: Type u#0)
(p: parser k t)
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
(pos: U32.t)
: GTot Type0 | [
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "EverParse3d.Readable",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "EverParse3d.Readable",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"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
}
] | false | let valid_input_buffer
(#k: parser_kind)
(#t: Type u#0)
(p: parser k t)
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
(pos: U32.t)
: GTot Type0
= LPL.valid p h (slice_of sl) pos /\
R.valid_perm h perm_of | val valid_input_buffer
(#k: parser_kind)
(#t: Type u#0)
(p: parser k t)
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
(pos: U32.t)
: GTot Type0
let valid_input_buffer
(#k: parser_kind)
(#t: Type u#0)
(p: parser k t)
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
(pos: U32.t)
: GTot Type0 = | false | null | false | LPL.valid p h (slice_of sl) pos /\ R.valid_perm h perm_of | {
"checked_file": "EverParse3d.InputBuffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverParse3d.Readable.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.InputBuffer.fsti"
} | [
"sometrivial"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"FStar.UInt32.t",
"EverParse3d.InputBuffer.input_buffer_t",
"EverParse3d.Readable.perm",
"LowParse.Bytes.byte",
"LowParse.Slice.__proj__Mkslice__item__base",
"EverParse3d.InputBuffer.triv",
"EverParse3d.InputBuffer.slice_of",
"Prims.l_and",
"LowParse.Low.Base.Spec.valid",
"EverParse3d.Readable.valid_perm"
] | [] | module EverParse3d.InputBuffer
module B = LowStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module LPL = LowParse.Low.Base
module R = EverParse3d.Readable
inline_for_extraction
noextract
let triv = B.trivial_preorder LowParse.Bytes.byte
inline_for_extraction
noextract
val input_buffer_t (len: U32.t) : Type0
include LowParse.Low.Base
val slice_of (#len: U32.t) (x: input_buffer_t len) : GTot (sl: slice triv triv { sl.LPL.len == len })
inline_for_extraction
noextract
let slice_length (#len: U32.t) (x: input_buffer_t len) : Tot (v: U32.t { v == (slice_of x).LPL.len }) =
len
let live_input_buffer
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
: GTot Type0
= LPL.live_slice h (slice_of sl) /\
R.valid_perm h perm_of
let valid_input_buffer
(#k: parser_kind)
(#t: Type u#0)
(p: parser k t)
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
(pos: U32.t) | false | false | EverParse3d.InputBuffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_input_buffer
(#k: parser_kind)
(#t: Type u#0)
(p: parser k t)
(h: HS.mem)
(#len: U32.t)
(sl: input_buffer_t len)
(perm_of: R.perm (slice_of sl).base)
(pos: U32.t)
: GTot Type0 | [] | EverParse3d.InputBuffer.valid_input_buffer | {
"file_name": "src/3d/prelude/buffer/EverParse3d.InputBuffer.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: EverParse3d.InputBuffer.input_buffer_t len ->
perm_of: EverParse3d.Readable.perm (Mkslice?.base (EverParse3d.InputBuffer.slice_of sl)) ->
pos: FStar.UInt32.t
-> Prims.GTot Type0 | {
"end_col": 24,
"end_line": 47,
"start_col": 2,
"start_line": 46
} |
Prims.Tot | val slice_length (#len: U32.t) (x: input_buffer_t len) : Tot (v: U32.t{v == (slice_of x).LPL.len}) | [
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "EverParse3d.Readable",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "EverParse3d.Readable",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"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
}
] | false | let slice_length (#len: U32.t) (x: input_buffer_t len) : Tot (v: U32.t { v == (slice_of x).LPL.len }) =
len | val slice_length (#len: U32.t) (x: input_buffer_t len) : Tot (v: U32.t{v == (slice_of x).LPL.len})
let slice_length (#len: U32.t) (x: input_buffer_t len) : Tot (v: U32.t{v == (slice_of x).LPL.len}) = | false | null | false | len | {
"checked_file": "EverParse3d.InputBuffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverParse3d.Readable.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.InputBuffer.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"EverParse3d.InputBuffer.input_buffer_t",
"Prims.eq2",
"LowParse.Slice.__proj__Mkslice__item__len",
"EverParse3d.InputBuffer.triv",
"EverParse3d.InputBuffer.slice_of"
] | [] | module EverParse3d.InputBuffer
module B = LowStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module LPL = LowParse.Low.Base
module R = EverParse3d.Readable
inline_for_extraction
noextract
let triv = B.trivial_preorder LowParse.Bytes.byte
inline_for_extraction
noextract
val input_buffer_t (len: U32.t) : Type0
include LowParse.Low.Base
val slice_of (#len: U32.t) (x: input_buffer_t len) : GTot (sl: slice triv triv { sl.LPL.len == len })
inline_for_extraction
noextract | false | false | EverParse3d.InputBuffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val slice_length (#len: U32.t) (x: input_buffer_t len) : Tot (v: U32.t{v == (slice_of x).LPL.len}) | [] | EverParse3d.InputBuffer.slice_length | {
"file_name": "src/3d/prelude/buffer/EverParse3d.InputBuffer.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: EverParse3d.InputBuffer.input_buffer_t len
-> v: FStar.UInt32.t{v == Mkslice?.len (EverParse3d.InputBuffer.slice_of x)} | {
"end_col": 5,
"end_line": 25,
"start_col": 2,
"start_line": 25
} |
FStar.Pervasives.Lemma | val lemma_pow2_le (m n:nat) : Lemma (requires m <= n) (ensures pow2 m <= pow2 n) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m | val lemma_pow2_le (m n:nat) : Lemma (requires m <= n) (ensures pow2 m <= pow2 n)
let lemma_pow2_le m n = | false | null | true | FStar.Math.Lemmas.pow2_le_compat n m | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.nat",
"FStar.Math.Lemmas.pow2_le_compat",
"Prims.unit"
] | [] | module Vale.Math.Bits
open FStar.Mul | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_pow2_le (m n:nat) : Lemma (requires m <= n) (ensures pow2 m <= pow2 n) | [] | Vale.Math.Bits.lemma_pow2_le | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Prims.nat -> n: Prims.nat
-> FStar.Pervasives.Lemma (requires m <= n) (ensures Prims.pow2 m <= Prims.pow2 n) | {
"end_col": 60,
"end_line": 4,
"start_col": 24,
"start_line": 4
} |
FStar.Pervasives.Lemma | val lemma_i2b_with_all (n:pos) (p:Type0) : Lemma
(requires lemmas_i2b_all ==> p)
(ensures p) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_with_all n p =
lemma_i2b_all () | val lemma_i2b_with_all (n:pos) (p:Type0) : Lemma
(requires lemmas_i2b_all ==> p)
(ensures p)
let lemma_i2b_with_all n p = | false | null | true | lemma_i2b_all () | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"Vale.Math.Bits.lemma_i2b_all",
"Prims.unit"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b
let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b
let mul_hide #n a b =
FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b
let lemma_i2b_all () =
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b);
() | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_with_all (n:pos) (p:Type0) : Lemma
(requires lemmas_i2b_all ==> p)
(ensures p) | [] | Vale.Math.Bits.lemma_i2b_with_all | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.pos -> p: Type0
-> FStar.Pervasives.Lemma (requires Vale.Math.Bits.lemmas_i2b_all ==> p) (ensures p) | {
"end_col": 18,
"end_line": 85,
"start_col": 2,
"start_line": 85
} |
FStar.Pervasives.Lemma | val lemma_to_is_bv8 (a:uint_t 32) : Lemma
(requires a < 0x100)
(ensures is_bv8 (b_i2b a)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_to_is_bv8 a =
int2bv_lemma_ult_1 a 0x100;
lemma_to_is_bv8_bv (int2bv a);
assert_norm (b_i2b a == int2bv a) | val lemma_to_is_bv8 (a:uint_t 32) : Lemma
(requires a < 0x100)
(ensures is_bv8 (b_i2b a))
let lemma_to_is_bv8 a = | false | null | true | int2bv_lemma_ult_1 a 0x100;
lemma_to_is_bv8_bv (int2bv a);
assert_norm (b_i2b a == int2bv a) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.BV.int2bv",
"Prims.unit",
"Vale.Math.Bits.lemma_to_is_bv8_bv",
"FStar.BV.int2bv_lemma_ult_1"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b
let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b
let mul_hide #n a b =
FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b
let lemma_i2b_all () =
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b);
()
let lemma_i2b_with_all n p =
lemma_i2b_all ()
let lemma_i2b_equal #n x y =
lemma_i2b_all ();
lemma_i2b_eq x y
#reset-options "--initial_fuel 0 --max_fuel 0"
let lemma_bveq #n a b =
let ia = bv2int a in
let ib = bv2int b in
int2bv_logxor #n #ia #ib #(bvxor a b) ();
int2bv_logxor #n #ia #ia #(bvxor a a) ();
assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia));
assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib);
assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia);
assert (logxor #n ia ib == logxor #n ia ia);
logxor_self ia;
logxor_neq_nonzero ia ib;
()
let lemma_to_is_bv8_bv (a:bv_t 32) : Lemma
(requires bvult a (int2bv 0x100))
(ensures is_bv8 a)
=
lemma_bveq a (bvand a (int2bv 0xff));
assert_norm (is_bv8 a) | false | false | Vale.Math.Bits.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_to_is_bv8 (a:uint_t 32) : Lemma
(requires a < 0x100)
(ensures is_bv8 (b_i2b a)) | [] | Vale.Math.Bits.lemma_to_is_bv8 | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t 32
-> FStar.Pervasives.Lemma (requires a < 0x100)
(ensures Vale.Math.Bits.is_bv8 (Vale.Math.Bits.b_i2b a)) | {
"end_col": 35,
"end_line": 115,
"start_col": 2,
"start_line": 113
} |
Prims.Pure | val add_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> a + b < pow2 n ==> x == a + b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b | val add_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> a + b < pow2 n ==> x == a + b)
let add_hide #n a b = | false | null | false | if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.UInt.add_mod",
"Prims.unit",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.pow2",
"FStar.Math.Lemmas.modulo_lemma",
"Prims.bool"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
() | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val add_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> a + b < pow2 n ==> x == a + b) | [] | Vale.Math.Bits.add_hide | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n) | {
"end_col": 13,
"end_line": 58,
"start_col": 2,
"start_line": 57
} |
FStar.Pervasives.Lemma | val lemma_i2b_mul (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) | val lemma_i2b_mul (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_mul #n a b = | false | null | true | int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.mul_mod",
"Vale.Math.Bits.b_mul",
"Prims.unit",
"FStar.BV.int2bv_mul",
"FStar.BV.bvmul",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_mul (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) | [] | Vale.Math.Bits.lemma_i2b_mul | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.mul_mod a b) ==
Vale.Math.Bits.b_mul (Vale.Math.Bits.b_i2b a) b) | {
"end_col": 65,
"end_line": 44,
"start_col": 2,
"start_line": 43
} |
FStar.Pervasives.Lemma | val lemma_i2b_div (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma
(b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) | val lemma_i2b_div (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma
(b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_div #n a b = | false | null | true | int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.int",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.udiv",
"Vale.Math.Bits.b_div",
"Prims.unit",
"FStar.BV.int2bv_div",
"FStar.BV.bvdiv",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_div (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma
(b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) | [] | Vale.Math.Bits.lemma_i2b_div | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0}
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.udiv a b) == Vale.Math.Bits.b_div (Vale.Math.Bits.b_i2b a) b) | {
"end_col": 62,
"end_line": 48,
"start_col": 2,
"start_line": 47
} |
FStar.Pervasives.Lemma | val lemma_i2b_uext (#n m:pos) (a:uint_t n) : Lemma
(b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) | val lemma_i2b_uext (#n m:pos) (a:uint_t n) : Lemma
(b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_uext #n m a = | false | null | true | Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Prims.op_Addition",
"Vale.Math.Bits.b_i2b",
"Vale.Math.Bits.uext",
"Vale.Math.Bits.b_uext",
"Prims.unit",
"Vale.Lib.Bv_s.int2bv_uext"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_uext (#n m:pos) (a:uint_t n) : Lemma
(b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) | [] | Vale.Math.Bits.lemma_i2b_uext | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Prims.pos -> a: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (Vale.Math.Bits.uext a) == Vale.Math.Bits.b_uext (Vale.Math.Bits.b_i2b a)
) | {
"end_col": 65,
"end_line": 12,
"start_col": 2,
"start_line": 11
} |
FStar.Pervasives.Lemma | val lemma_i2b_eq (#n:pos) (a b:uint_t n) : Lemma
(requires b_i2b a == b_i2b b)
(ensures a == b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b | val lemma_i2b_eq (#n:pos) (a b:uint_t n) : Lemma
(requires b_i2b a == b_i2b b)
(ensures a == b)
let lemma_i2b_eq #n a b = | false | null | true | assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.BV.int2bv_lemma_2",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.l_imp",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_eq (#n:pos) (a b:uint_t n) : Lemma
(requires b_i2b a == b_i2b b)
(ensures a == b) | [] | Vale.Math.Bits.lemma_i2b_eq | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma (requires Vale.Math.Bits.b_i2b a == Vale.Math.Bits.b_i2b b)
(ensures a == b) | {
"end_col": 23,
"end_line": 8,
"start_col": 2,
"start_line": 7
} |
FStar.Pervasives.Lemma | val lemma_i2b_sub (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) | val lemma_i2b_sub (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b = | false | null | true | int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.sub_mod",
"Vale.Math.Bits.b_sub",
"Prims.unit",
"FStar.BV.int2bv_sub",
"FStar.BV.bvsub",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_sub (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) | [] | Vale.Math.Bits.lemma_i2b_sub | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.sub_mod a b) ==
Vale.Math.Bits.b_sub (Vale.Math.Bits.b_i2b a) (Vale.Math.Bits.b_i2b b)) | {
"end_col": 73,
"end_line": 40,
"start_col": 2,
"start_line": 39
} |
FStar.Pervasives.Lemma | val lemma_i2b_equal (#n:pos) (x y:uint_t n) : Lemma
(requires lemmas_i2b_all ==> b_i2b x == b_i2b y)
(ensures x == y) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_equal #n x y =
lemma_i2b_all ();
lemma_i2b_eq x y | val lemma_i2b_equal (#n:pos) (x y:uint_t n) : Lemma
(requires lemmas_i2b_all ==> b_i2b x == b_i2b y)
(ensures x == y)
let lemma_i2b_equal #n x y = | false | null | true | lemma_i2b_all ();
lemma_i2b_eq x y | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"Vale.Math.Bits.lemma_i2b_eq",
"Prims.unit",
"Vale.Math.Bits.lemma_i2b_all"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b
let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b
let mul_hide #n a b =
FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b
let lemma_i2b_all () =
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b);
()
let lemma_i2b_with_all n p =
lemma_i2b_all () | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_equal (#n:pos) (x y:uint_t n) : Lemma
(requires lemmas_i2b_all ==> b_i2b x == b_i2b y)
(ensures x == y) | [] | Vale.Math.Bits.lemma_i2b_equal | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: FStar.UInt.uint_t n -> y: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(requires Vale.Math.Bits.lemmas_i2b_all ==> Vale.Math.Bits.b_i2b x == Vale.Math.Bits.b_i2b y)
(ensures x == y) | {
"end_col": 18,
"end_line": 89,
"start_col": 2,
"start_line": 88
} |
FStar.Pervasives.Lemma | val lemma_i2b_add (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) | val lemma_i2b_add (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_add #n a b = | false | null | true | int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.add_mod",
"Vale.Math.Bits.b_add",
"Prims.unit",
"FStar.BV.int2bv_add",
"FStar.BV.bvadd",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_add (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) | [] | Vale.Math.Bits.lemma_i2b_add | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.add_mod a b) ==
Vale.Math.Bits.b_add (Vale.Math.Bits.b_i2b a) (Vale.Math.Bits.b_i2b b)) | {
"end_col": 73,
"end_line": 36,
"start_col": 2,
"start_line": 35
} |
FStar.Pervasives.Lemma | val lemma_i2b_mod (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma
(b_i2b #n (mod #n a b) == b_mod #n (b_i2b a) b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
() | val lemma_i2b_mod (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma
(b_i2b #n (mod #n a b) == b_mod #n (b_i2b a) b)
let lemma_i2b_mod #n a b = | false | null | true | int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
() | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.int",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"FStar.BV.int2bv",
"FStar.UInt.mod",
"Vale.Math.Bits.b_i2b",
"FStar.BV.bvmod",
"Vale.Math.Bits.b_mod",
"FStar.BV.int2bv_mod"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_mod (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma
(b_i2b #n (mod #n a b) == b_mod #n (b_i2b a) b) | [] | Vale.Math.Bits.lemma_i2b_mod | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0}
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.mod a b) == Vale.Math.Bits.b_mod (Vale.Math.Bits.b_i2b a) b) | {
"end_col": 4,
"end_line": 54,
"start_col": 2,
"start_line": 51
} |
Prims.Pure | val sub_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> 0 <= a - b ==> x == a - b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b | val sub_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> 0 <= a - b ==> x == a - b)
let sub_hide #n a b = | false | null | false | if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.UInt.sub_mod",
"Prims.unit",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"FStar.Math.Lemmas.modulo_lemma",
"Prims.pow2",
"Prims.bool"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val sub_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> 0 <= a - b ==> x == a - b) | [] | Vale.Math.Bits.sub_hide | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n) | {
"end_col": 13,
"end_line": 62,
"start_col": 2,
"start_line": 61
} |
Prims.Pure | val mul_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> 0 <= a * b /\ (a * b < pow2 n ==> x == a * b)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let mul_hide #n a b =
FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b | val mul_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> 0 <= a * b /\ (a * b < pow2 n ==> x == a * b))
let mul_hide #n a b = | false | null | false | FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.UInt.mul_mod",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.op_LessThan",
"FStar.Math.Lemmas.modulo_lemma",
"Prims.bool",
"FStar.Math.Lemmas.nat_times_nat_is_nat"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b
let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val mul_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n)
(requires True)
(ensures fun x -> 0 <= a * b /\ (a * b < pow2 n ==> x == a * b)) | [] | Vale.Math.Bits.mul_hide | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n) | {
"end_col": 13,
"end_line": 68,
"start_col": 2,
"start_line": 65
} |
FStar.Pervasives.Lemma | val lemma_to_is_bv8_bv (a: bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_to_is_bv8_bv (a:bv_t 32) : Lemma
(requires bvult a (int2bv 0x100))
(ensures is_bv8 a)
=
lemma_bveq a (bvand a (int2bv 0xff));
assert_norm (is_bv8 a) | val lemma_to_is_bv8_bv (a: bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a)
let lemma_to_is_bv8_bv (a: bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a) = | false | null | true | lemma_bveq a (bvand a (int2bv 0xff));
assert_norm (is_bv8 a) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"FStar.BV.bv_t",
"FStar.Pervasives.assert_norm",
"Vale.Math.Bits.is_bv8",
"Prims.unit",
"Vale.Math.Bits.lemma_bveq",
"FStar.BV.bvand",
"FStar.BV.int2bv",
"Prims.b2t",
"FStar.BV.bvult",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b
let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b
let mul_hide #n a b =
FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b
let lemma_i2b_all () =
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b);
()
let lemma_i2b_with_all n p =
lemma_i2b_all ()
let lemma_i2b_equal #n x y =
lemma_i2b_all ();
lemma_i2b_eq x y
#reset-options "--initial_fuel 0 --max_fuel 0"
let lemma_bveq #n a b =
let ia = bv2int a in
let ib = bv2int b in
int2bv_logxor #n #ia #ib #(bvxor a b) ();
int2bv_logxor #n #ia #ia #(bvxor a a) ();
assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia));
assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib);
assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia);
assert (logxor #n ia ib == logxor #n ia ia);
logxor_self ia;
logxor_neq_nonzero ia ib;
()
let lemma_to_is_bv8_bv (a:bv_t 32) : Lemma
(requires bvult a (int2bv 0x100))
(ensures is_bv8 a) | false | false | Vale.Math.Bits.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_to_is_bv8_bv (a: bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a) | [] | Vale.Math.Bits.lemma_to_is_bv8_bv | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.BV.bv_t 32
-> FStar.Pervasives.Lemma (requires FStar.BV.bvult a (FStar.BV.int2bv 0x100))
(ensures Vale.Math.Bits.is_bv8 a) | {
"end_col": 24,
"end_line": 110,
"start_col": 2,
"start_line": 109
} |
FStar.Pervasives.Lemma | val lemma_i2b_shl (#n:pos) (a:uint_t n) (b:uint_t n) : Lemma
(b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) | val lemma_i2b_shl (#n:pos) (a:uint_t n) (b:uint_t n) : Lemma
(b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shl #n a b = | false | null | true | int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.shift_left",
"Vale.Math.Bits.b_shl",
"Prims.unit",
"FStar.BV.int2bv_shl",
"FStar.BV.bvshl",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_shl (#n:pos) (a:uint_t n) (b:uint_t n) : Lemma
(b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) | [] | Vale.Math.Bits.lemma_i2b_shl | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.shift_left a b) ==
Vale.Math.Bits.b_shl (Vale.Math.Bits.b_i2b a) b) | {
"end_col": 68,
"end_line": 28,
"start_col": 2,
"start_line": 27
} |
FStar.Pervasives.Lemma | val lemma_i2b_shr (#n:pos) (a:uint_t n) (b:uint_t n) : Lemma
(b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) | val lemma_i2b_shr (#n:pos) (a:uint_t n) (b:uint_t n) : Lemma
(b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_shr #n a b = | false | null | true | int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.shift_right",
"Vale.Math.Bits.b_shr",
"Prims.unit",
"FStar.BV.int2bv_shr",
"FStar.BV.bvshr",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_shr (#n:pos) (a:uint_t n) (b:uint_t n) : Lemma
(b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) | [] | Vale.Math.Bits.lemma_i2b_shr | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.shift_right a b) ==
Vale.Math.Bits.b_shr (Vale.Math.Bits.b_i2b a) b) | {
"end_col": 69,
"end_line": 32,
"start_col": 2,
"start_line": 31
} |
FStar.Pervasives.Lemma | val lemma_bveq (#n:pos) (a b:bv_t n) : Lemma
(requires bveq #n a b)
(ensures a == b) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_bveq #n a b =
let ia = bv2int a in
let ib = bv2int b in
int2bv_logxor #n #ia #ib #(bvxor a b) ();
int2bv_logxor #n #ia #ia #(bvxor a a) ();
assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia));
assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib);
assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia);
assert (logxor #n ia ib == logxor #n ia ia);
logxor_self ia;
logxor_neq_nonzero ia ib;
() | val lemma_bveq (#n:pos) (a b:bv_t n) : Lemma
(requires bveq #n a b)
(ensures a == b)
let lemma_bveq #n a b = | false | null | true | let ia = bv2int a in
let ib = bv2int b in
int2bv_logxor #n #ia #ib #(bvxor a b) ();
int2bv_logxor #n #ia #ia #(bvxor a a) ();
assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia));
assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib);
assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia);
assert (logxor #n ia ib == logxor #n ia ia);
logxor_self ia;
logxor_neq_nonzero ia ib;
() | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.BV.bv_t",
"Prims.unit",
"FStar.UInt.logxor_neq_nonzero",
"FStar.UInt.logxor_self",
"Prims._assert",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt.logxor",
"FStar.BV.bv2int",
"FStar.BV.int2bv",
"FStar.BV.int2bv_logxor",
"FStar.BV.bvxor"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b
let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b
let mul_hide #n a b =
FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b
let lemma_i2b_all () =
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b);
()
let lemma_i2b_with_all n p =
lemma_i2b_all ()
let lemma_i2b_equal #n x y =
lemma_i2b_all ();
lemma_i2b_eq x y | false | false | Vale.Math.Bits.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_bveq (#n:pos) (a b:bv_t n) : Lemma
(requires bveq #n a b)
(ensures a == b) | [] | Vale.Math.Bits.lemma_bveq | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.BV.bv_t n -> b: FStar.BV.bv_t n
-> FStar.Pervasives.Lemma (requires Vale.Math.Bits.bveq a b) (ensures a == b) | {
"end_col": 4,
"end_line": 103,
"start_col": 23,
"start_line": 92
} |
FStar.Pervasives.Lemma | val lemma_i2b_or (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) | val lemma_i2b_or (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b = | false | null | true | int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.logor",
"Vale.Math.Bits.b_or",
"Prims.unit",
"FStar.BV.int2bv_logor",
"FStar.BV.bvor",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_or (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) | [] | Vale.Math.Bits.lemma_i2b_or | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.logor a b) ==
Vale.Math.Bits.b_or (Vale.Math.Bits.b_i2b a) (Vale.Math.Bits.b_i2b b)) | {
"end_col": 70,
"end_line": 20,
"start_col": 2,
"start_line": 19
} |
FStar.Pervasives.Lemma | val lemma_i2b_xor (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) | val lemma_i2b_xor (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b = | false | null | true | int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.logxor",
"Vale.Math.Bits.b_xor",
"Prims.unit",
"FStar.BV.int2bv_logxor",
"FStar.BV.bvxor",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_xor (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) | [] | Vale.Math.Bits.lemma_i2b_xor | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.logxor a b) ==
Vale.Math.Bits.b_xor (Vale.Math.Bits.b_i2b a) (Vale.Math.Bits.b_i2b b)) | {
"end_col": 72,
"end_line": 24,
"start_col": 2,
"start_line": 23
} |
FStar.Pervasives.Lemma | val lemma_i2b_and (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) | val lemma_i2b_and (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_and #n a b = | false | null | true | int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.logand",
"Vale.Math.Bits.b_and",
"Prims.unit",
"FStar.BV.int2bv_logand",
"FStar.BV.bvand",
"FStar.BV.int2bv"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_and (#n:pos) (a b:uint_t n) : Lemma
(b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) | [] | Vale.Math.Bits.lemma_i2b_and | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Bits.b_i2b (FStar.UInt.logand a b) ==
Vale.Math.Bits.b_and (Vale.Math.Bits.b_i2b a) (Vale.Math.Bits.b_i2b b)) | {
"end_col": 72,
"end_line": 16,
"start_col": 2,
"start_line": 15
} |
FStar.Pervasives.Lemma | val lemma_i2b_all (_:unit) : Lemma lemmas_i2b_all | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.BV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"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
}
] | false | let lemma_i2b_all () =
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b);
() | val lemma_i2b_all (_:unit) : Lemma lemmas_i2b_all
let lemma_i2b_all () = | false | null | true | FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b);
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b);
() | {
"checked_file": "Vale.Math.Bits.fst.checked",
"dependencies": [
"Vale.Lib.Bv_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Bits.fst"
} | [
"lemma"
] | [
"Prims.unit",
"FStar.Classical.forall_intro_3",
"Prims.pos",
"FStar.UInt.uint_t",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.int",
"Prims.eq2",
"FStar.BV.bv_t",
"Vale.Math.Bits.b_i2b",
"FStar.UInt.mod",
"Vale.Math.Bits.b_mod",
"Vale.Math.Bits.lemma_i2b_mod",
"FStar.UInt.udiv",
"Vale.Math.Bits.b_div",
"Vale.Math.Bits.lemma_i2b_div",
"FStar.UInt.mul_mod",
"Vale.Math.Bits.b_mul",
"Vale.Math.Bits.lemma_i2b_mul",
"FStar.UInt.sub_mod",
"Vale.Math.Bits.b_sub",
"Vale.Math.Bits.lemma_i2b_sub",
"FStar.UInt.add_mod",
"Vale.Math.Bits.b_add",
"Vale.Math.Bits.lemma_i2b_add",
"FStar.UInt.shift_right",
"Vale.Math.Bits.b_shr",
"Vale.Math.Bits.lemma_i2b_shr",
"FStar.UInt.shift_left",
"Vale.Math.Bits.b_shl",
"Vale.Math.Bits.lemma_i2b_shl",
"FStar.UInt.logxor",
"Vale.Math.Bits.b_xor",
"Vale.Math.Bits.lemma_i2b_xor",
"FStar.UInt.logor",
"Vale.Math.Bits.b_or",
"Vale.Math.Bits.lemma_i2b_or",
"FStar.UInt.logand",
"Vale.Math.Bits.b_and",
"Vale.Math.Bits.lemma_i2b_and",
"Prims.op_Addition",
"Vale.Math.Bits.uext",
"Vale.Math.Bits.b_uext",
"Vale.Math.Bits.lemma_i2b_uext"
] | [] | module Vale.Math.Bits
open FStar.Mul
let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m
let lemma_i2b_eq #n a b =
assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b);
int2bv_lemma_2 #n a b
let lemma_i2b_uext #n m a =
Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a);
assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a))
let lemma_i2b_and #n a b =
int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b))
let lemma_i2b_or #n a b =
int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b))
let lemma_i2b_xor #n a b =
int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b))
let lemma_i2b_shl #n a b =
int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b)
let lemma_i2b_shr #n a b =
int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b)
let lemma_i2b_add #n a b =
int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b))
let lemma_i2b_sub #n a b =
int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) ();
assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) ();
assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_mod #n a b =
int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) ();
assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b);
assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b));
()
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n);
add_mod a b
let sub_hide #n a b =
if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n);
sub_mod a b
let mul_hide #n a b =
FStar.Math.Lemmas.nat_times_nat_is_nat a b;
if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n);
assert_norm (mul_mod a b == (a * b) % pow2 n);
mul_mod a b | false | false | Vale.Math.Bits.fst | {
"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"
} | null | val lemma_i2b_all (_:unit) : Lemma lemmas_i2b_all | [] | Vale.Math.Bits.lemma_i2b_all | {
"file_name": "vale/code/lib/math/Vale.Math.Bits.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.Math.Bits.lemmas_i2b_all) | {
"end_col": 4,
"end_line": 82,
"start_col": 2,
"start_line": 71
} |
Prims.Tot | val serialize32_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_flbytes sz)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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
}
] | false | let serialize32_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer32 (serialize_flbytes sz))
= fun (input: B32.lbytes sz) ->
B32.hide_reveal input;
(input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) | val serialize32_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_flbytes sz))
let serialize32_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_flbytes sz)) = | false | null | false | fun (input: B32.lbytes sz) ->
B32.hide_reveal input;
(input <: (res: bytes32{serializer32_correct (serialize_flbytes sz) input res})) | {
"checked_file": "LowParse.SLow.Bytes.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Bytes.fst.checked",
"LowParse.SLow.VLGen.fst.checked",
"LowParse.SLow.VLData.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Bytes.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Bytes.lbytes",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.Base.total_constant_size_parser_kind",
"LowParse.Spec.Bytes.parse_flbytes",
"LowParse.Spec.Bytes.serialize_flbytes",
"Prims.unit",
"FStar.Bytes.hide_reveal",
"LowParse.SLow.Base.serializer32"
] | [] | module LowParse.SLow.Bytes
include LowParse.Spec.Bytes
include LowParse.SLow.VLData
include LowParse.SLow.VLGen
module B32 = FStar.Bytes
module Seq = FStar.Seq
module U32 = FStar.UInt32
inline_for_extraction
let parse32_flbytes_gen
(sz: nat { sz < 4294967296 } )
(x: B32.lbytes sz)
: Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } )
= B32.hide_reveal x;
x
#set-options "--z3rlimit 32"
inline_for_extraction
let parse32_flbytes
(sz: nat)
(sz' : U32.t { U32.v sz' == sz } )
: Tot (
lt_pow2_32 sz;
parser32 (parse_flbytes sz)
)
= lt_pow2_32 sz;
make_total_constant_size_parser32
sz
sz'
#(B32.lbytes sz)
(parse_flbytes_gen sz)
()
(parse32_flbytes_gen sz)
inline_for_extraction
let serialize32_flbytes
(sz: nat { sz < 4294967296 } ) | false | false | LowParse.SLow.Bytes.fst | {
"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"
} | null | val serialize32_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_flbytes sz)) | [] | LowParse.SLow.Bytes.serialize32_flbytes | {
"file_name": "src/lowparse/LowParse.SLow.Bytes.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | sz: Prims.nat{sz < 4294967296}
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.Bytes.serialize_flbytes sz) | {
"end_col": 88,
"end_line": 43,
"start_col": 2,
"start_line": 41
} |
Prims.Tot | val serialize32_all_bytes:serializer32 serialize_all_bytes | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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
}
] | false | let serialize32_all_bytes
: serializer32 serialize_all_bytes
= fun (input: B32.bytes) ->
(input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) | val serialize32_all_bytes:serializer32 serialize_all_bytes
let serialize32_all_bytes:serializer32 serialize_all_bytes = | false | null | false | fun (input: B32.bytes) ->
(input <: (res: bytes32{serializer32_correct serialize_all_bytes input res})) | {
"checked_file": "LowParse.SLow.Bytes.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Bytes.fst.checked",
"LowParse.SLow.VLGen.fst.checked",
"LowParse.SLow.VLData.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Bytes.fst"
} | [
"total"
] | [
"FStar.Bytes.bytes",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes"
] | [] | module LowParse.SLow.Bytes
include LowParse.Spec.Bytes
include LowParse.SLow.VLData
include LowParse.SLow.VLGen
module B32 = FStar.Bytes
module Seq = FStar.Seq
module U32 = FStar.UInt32
inline_for_extraction
let parse32_flbytes_gen
(sz: nat { sz < 4294967296 } )
(x: B32.lbytes sz)
: Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } )
= B32.hide_reveal x;
x
#set-options "--z3rlimit 32"
inline_for_extraction
let parse32_flbytes
(sz: nat)
(sz' : U32.t { U32.v sz' == sz } )
: Tot (
lt_pow2_32 sz;
parser32 (parse_flbytes sz)
)
= lt_pow2_32 sz;
make_total_constant_size_parser32
sz
sz'
#(B32.lbytes sz)
(parse_flbytes_gen sz)
()
(parse32_flbytes_gen sz)
inline_for_extraction
let serialize32_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer32 (serialize_flbytes sz))
= fun (input: B32.lbytes sz) ->
B32.hide_reveal input;
(input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } ))
inline_for_extraction
let parse32_all_bytes
: parser32 parse_all_bytes
= fun (input: B32.bytes) ->
let res = Some (input, B32.len input) in
(res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } ))
inline_for_extraction
let serialize32_all_bytes | false | true | LowParse.SLow.Bytes.fst | {
"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"
} | null | val serialize32_all_bytes:serializer32 serialize_all_bytes | [] | LowParse.SLow.Bytes.serialize32_all_bytes | {
"file_name": "src/lowparse/LowParse.SLow.Bytes.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.SLow.Base.serializer32 LowParse.Spec.Bytes.serialize_all_bytes | {
"end_col": 83,
"end_line": 56,
"start_col": 2,
"start_line": 55
} |
Prims.Tot | val parse32_flbytes_gen (sz: nat{sz < 4294967296}) (x: B32.lbytes sz)
: Tot (y: B32.lbytes sz {y == parse_flbytes_gen sz (B32.reveal x)}) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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
}
] | false | let parse32_flbytes_gen
(sz: nat { sz < 4294967296 } )
(x: B32.lbytes sz)
: Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } )
= B32.hide_reveal x;
x | val parse32_flbytes_gen (sz: nat{sz < 4294967296}) (x: B32.lbytes sz)
: Tot (y: B32.lbytes sz {y == parse_flbytes_gen sz (B32.reveal x)})
let parse32_flbytes_gen (sz: nat{sz < 4294967296}) (x: B32.lbytes sz)
: Tot (y: B32.lbytes sz {y == parse_flbytes_gen sz (B32.reveal x)}) = | false | null | false | B32.hide_reveal x;
x | {
"checked_file": "LowParse.SLow.Bytes.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Bytes.fst.checked",
"LowParse.SLow.VLGen.fst.checked",
"LowParse.SLow.VLData.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Bytes.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Bytes.lbytes",
"Prims.unit",
"FStar.Bytes.hide_reveal",
"Prims.eq2",
"LowParse.Spec.Bytes.parse_flbytes_gen",
"FStar.Bytes.reveal"
] | [] | module LowParse.SLow.Bytes
include LowParse.Spec.Bytes
include LowParse.SLow.VLData
include LowParse.SLow.VLGen
module B32 = FStar.Bytes
module Seq = FStar.Seq
module U32 = FStar.UInt32
inline_for_extraction
let parse32_flbytes_gen
(sz: nat { sz < 4294967296 } )
(x: B32.lbytes sz) | false | false | LowParse.SLow.Bytes.fst | {
"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"
} | null | val parse32_flbytes_gen (sz: nat{sz < 4294967296}) (x: B32.lbytes sz)
: Tot (y: B32.lbytes sz {y == parse_flbytes_gen sz (B32.reveal x)}) | [] | LowParse.SLow.Bytes.parse32_flbytes_gen | {
"file_name": "src/lowparse/LowParse.SLow.Bytes.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | sz: Prims.nat{sz < 4294967296} -> x: FStar.Bytes.lbytes sz
-> y: FStar.Bytes.lbytes sz {y == LowParse.Spec.Bytes.parse_flbytes_gen sz (FStar.Bytes.reveal x)} | {
"end_col": 3,
"end_line": 16,
"start_col": 2,
"start_line": 15
} |
Prims.Tot | val size32_all_bytes:size32 serialize_all_bytes | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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
}
] | false | let size32_all_bytes
: size32 serialize_all_bytes
= fun (input: B32.bytes) ->
let res = B32.len input in
(res <: (res: U32.t { size32_postcond serialize_all_bytes input res } )) | val size32_all_bytes:size32 serialize_all_bytes
let size32_all_bytes:size32 serialize_all_bytes = | false | null | false | fun (input: B32.bytes) ->
let res = B32.len input in
(res <: (res: U32.t{size32_postcond serialize_all_bytes input res})) | {
"checked_file": "LowParse.SLow.Bytes.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Bytes.fst.checked",
"LowParse.SLow.VLGen.fst.checked",
"LowParse.SLow.VLData.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Bytes.fst"
} | [
"total"
] | [
"FStar.Bytes.bytes",
"FStar.UInt32.t",
"LowParse.SLow.Base.size32_postcond",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"FStar.Bytes.len"
] | [] | module LowParse.SLow.Bytes
include LowParse.Spec.Bytes
include LowParse.SLow.VLData
include LowParse.SLow.VLGen
module B32 = FStar.Bytes
module Seq = FStar.Seq
module U32 = FStar.UInt32
inline_for_extraction
let parse32_flbytes_gen
(sz: nat { sz < 4294967296 } )
(x: B32.lbytes sz)
: Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } )
= B32.hide_reveal x;
x
#set-options "--z3rlimit 32"
inline_for_extraction
let parse32_flbytes
(sz: nat)
(sz' : U32.t { U32.v sz' == sz } )
: Tot (
lt_pow2_32 sz;
parser32 (parse_flbytes sz)
)
= lt_pow2_32 sz;
make_total_constant_size_parser32
sz
sz'
#(B32.lbytes sz)
(parse_flbytes_gen sz)
()
(parse32_flbytes_gen sz)
inline_for_extraction
let serialize32_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer32 (serialize_flbytes sz))
= fun (input: B32.lbytes sz) ->
B32.hide_reveal input;
(input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } ))
inline_for_extraction
let parse32_all_bytes
: parser32 parse_all_bytes
= fun (input: B32.bytes) ->
let res = Some (input, B32.len input) in
(res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } ))
inline_for_extraction
let serialize32_all_bytes
: serializer32 serialize_all_bytes
= fun (input: B32.bytes) ->
(input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } ))
inline_for_extraction
let parse32_bounded_vlbytes'
(min: nat)
(min32: U32.t { U32.v min32 == min } )
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(max32: U32.t { U32.v max32 == max } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser32 (parse_bounded_vlbytes' min max l))
= parse32_synth
_
(synth_bounded_vlbytes min max)
(fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max))
(parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes)
()
inline_for_extraction
let parse32_bounded_vlbytes
(min: nat)
(min32: U32.t { U32.v min32 == min } )
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(max32: U32.t { U32.v max32 == max } )
: Tot (parser32 (parse_bounded_vlbytes min max))
= parse32_bounded_vlbytes' min min32 max max32 (log256' max)
inline_for_extraction
let serialize32_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer32 (serialize_bounded_vlbytes_aux min max l))
=
serialize32_bounded_vldata_strong'
min
max
l
#_
#_
#parse_all_bytes
#serialize_all_bytes
serialize32_all_bytes
inline_for_extraction
let serialize32_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer32 (serialize_bounded_vlbytes' min max l))
= serialize32_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(serialize32_bounded_vlbytes_aux min max l)
(fun (x: parse_bounded_vlbytes_t min max) ->
(x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
)
(fun x -> x)
()
inline_for_extraction
let serialize32_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4
: Tot (serializer32 (serialize_bounded_vlbytes min max))
= serialize32_bounded_vlbytes' min max (log256' max)
inline_for_extraction
let size32_all_bytes | false | true | LowParse.SLow.Bytes.fst | {
"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"
} | null | val size32_all_bytes:size32 serialize_all_bytes | [] | LowParse.SLow.Bytes.size32_all_bytes | {
"file_name": "src/lowparse/LowParse.SLow.Bytes.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.SLow.Base.size32 LowParse.Spec.Bytes.serialize_all_bytes | {
"end_col": 74,
"end_line": 128,
"start_col": 2,
"start_line": 126
} |
Prims.Tot | val parse32_flbytes (sz: nat) (sz': U32.t{U32.v sz' == sz})
: Tot
(lt_pow2_32 sz;
parser32 (parse_flbytes sz)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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
}
] | false | let parse32_flbytes
(sz: nat)
(sz' : U32.t { U32.v sz' == sz } )
: Tot (
lt_pow2_32 sz;
parser32 (parse_flbytes sz)
)
= lt_pow2_32 sz;
make_total_constant_size_parser32
sz
sz'
#(B32.lbytes sz)
(parse_flbytes_gen sz)
()
(parse32_flbytes_gen sz) | val parse32_flbytes (sz: nat) (sz': U32.t{U32.v sz' == sz})
: Tot
(lt_pow2_32 sz;
parser32 (parse_flbytes sz))
let parse32_flbytes (sz: nat) (sz': U32.t{U32.v sz' == sz})
: Tot
(lt_pow2_32 sz;
parser32 (parse_flbytes sz)) = | false | null | false | lt_pow2_32 sz;
make_total_constant_size_parser32 sz
sz'
#(B32.lbytes sz)
(parse_flbytes_gen sz)
()
(parse32_flbytes_gen sz) | {
"checked_file": "LowParse.SLow.Bytes.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Bytes.fst.checked",
"LowParse.SLow.VLGen.fst.checked",
"LowParse.SLow.VLData.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Bytes.fst"
} | [
"total"
] | [
"Prims.nat",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"LowParse.SLow.Combinators.make_total_constant_size_parser32",
"FStar.Bytes.lbytes",
"LowParse.Spec.Bytes.parse_flbytes_gen",
"LowParse.SLow.Bytes.parse32_flbytes_gen",
"Prims.unit",
"LowParse.Spec.Bytes.lt_pow2_32",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.Base.total_constant_size_parser_kind",
"LowParse.Spec.Bytes.parse_flbytes"
] | [] | module LowParse.SLow.Bytes
include LowParse.Spec.Bytes
include LowParse.SLow.VLData
include LowParse.SLow.VLGen
module B32 = FStar.Bytes
module Seq = FStar.Seq
module U32 = FStar.UInt32
inline_for_extraction
let parse32_flbytes_gen
(sz: nat { sz < 4294967296 } )
(x: B32.lbytes sz)
: Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } )
= B32.hide_reveal x;
x
#set-options "--z3rlimit 32"
inline_for_extraction
let parse32_flbytes
(sz: nat)
(sz' : U32.t { U32.v sz' == sz } )
: Tot (
lt_pow2_32 sz;
parser32 (parse_flbytes sz) | false | false | LowParse.SLow.Bytes.fst | {
"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"
} | null | val parse32_flbytes (sz: nat) (sz': U32.t{U32.v sz' == sz})
: Tot
(lt_pow2_32 sz;
parser32 (parse_flbytes sz)) | [] | LowParse.SLow.Bytes.parse32_flbytes | {
"file_name": "src/lowparse/LowParse.SLow.Bytes.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | sz: Prims.nat -> sz': FStar.UInt32.t{FStar.UInt32.v sz' == sz}
-> (LowParse.Spec.Bytes.lt_pow2_32 sz;
LowParse.SLow.Base.parser32 (LowParse.Spec.Bytes.parse_flbytes sz)) | {
"end_col": 28,
"end_line": 35,
"start_col": 2,
"start_line": 28
} |
Prims.Tot | val serialize32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292})
: Tot (serializer32 (serialize_bounded_vlbytes min max)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.VLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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
}
] | false | let serialize32_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4
: Tot (serializer32 (serialize_bounded_vlbytes min max))
= serialize32_bounded_vlbytes' min max (log256' max) | val serialize32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292})
: Tot (serializer32 (serialize_bounded_vlbytes min max))
let serialize32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292})
: Tot (serializer32 (serialize_bounded_vlbytes min max)) = | false | null | false | serialize32_bounded_vlbytes' min max (log256' max) | {
"checked_file": "LowParse.SLow.Bytes.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Bytes.fst.checked",
"LowParse.SLow.VLGen.fst.checked",
"LowParse.SLow.VLData.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Bytes.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.SLow.Bytes.serialize32_bounded_vlbytes'",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.SLow.Base.serializer32",
"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",
"LowParse.Spec.Bytes.serialize_bounded_vlbytes"
] | [] | module LowParse.SLow.Bytes
include LowParse.Spec.Bytes
include LowParse.SLow.VLData
include LowParse.SLow.VLGen
module B32 = FStar.Bytes
module Seq = FStar.Seq
module U32 = FStar.UInt32
inline_for_extraction
let parse32_flbytes_gen
(sz: nat { sz < 4294967296 } )
(x: B32.lbytes sz)
: Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } )
= B32.hide_reveal x;
x
#set-options "--z3rlimit 32"
inline_for_extraction
let parse32_flbytes
(sz: nat)
(sz' : U32.t { U32.v sz' == sz } )
: Tot (
lt_pow2_32 sz;
parser32 (parse_flbytes sz)
)
= lt_pow2_32 sz;
make_total_constant_size_parser32
sz
sz'
#(B32.lbytes sz)
(parse_flbytes_gen sz)
()
(parse32_flbytes_gen sz)
inline_for_extraction
let serialize32_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer32 (serialize_flbytes sz))
= fun (input: B32.lbytes sz) ->
B32.hide_reveal input;
(input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } ))
inline_for_extraction
let parse32_all_bytes
: parser32 parse_all_bytes
= fun (input: B32.bytes) ->
let res = Some (input, B32.len input) in
(res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } ))
inline_for_extraction
let serialize32_all_bytes
: serializer32 serialize_all_bytes
= fun (input: B32.bytes) ->
(input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } ))
inline_for_extraction
let parse32_bounded_vlbytes'
(min: nat)
(min32: U32.t { U32.v min32 == min } )
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(max32: U32.t { U32.v max32 == max } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser32 (parse_bounded_vlbytes' min max l))
= parse32_synth
_
(synth_bounded_vlbytes min max)
(fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max))
(parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes)
()
inline_for_extraction
let parse32_bounded_vlbytes
(min: nat)
(min32: U32.t { U32.v min32 == min } )
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(max32: U32.t { U32.v max32 == max } )
: Tot (parser32 (parse_bounded_vlbytes min max))
= parse32_bounded_vlbytes' min min32 max max32 (log256' max)
inline_for_extraction
let serialize32_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer32 (serialize_bounded_vlbytes_aux min max l))
=
serialize32_bounded_vldata_strong'
min
max
l
#_
#_
#parse_all_bytes
#serialize_all_bytes
serialize32_all_bytes
inline_for_extraction
let serialize32_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer32 (serialize_bounded_vlbytes' min max l))
= serialize32_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(serialize32_bounded_vlbytes_aux min max l)
(fun (x: parse_bounded_vlbytes_t min max) ->
(x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
)
(fun x -> x)
()
inline_for_extraction
let serialize32_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 | false | false | LowParse.SLow.Bytes.fst | {
"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"
} | null | val serialize32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292})
: Tot (serializer32 (serialize_bounded_vlbytes min max)) | [] | LowParse.SLow.Bytes.serialize32_bounded_vlbytes | {
"file_name": "src/lowparse/LowParse.SLow.Bytes.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292}
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.Bytes.serialize_bounded_vlbytes min max) | {
"end_col": 52,
"end_line": 121,
"start_col": 2,
"start_line": 121
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.