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 create4 (x0 x1 x2 x3: uint64) : list uint64
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "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.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": 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 create4 (x0 x1 x2 x3:uint64) : list uint64 = [x0; x1; x2; x3]
val create4 (x0 x1 x2 x3: uint64) : list uint64 let create4 (x0 x1 x2 x3: uint64) : list uint64 =
false
null
false
[x0; x1; x2; x3]
{ "checked_file": "Hacl.Spec.P256.PrecompTable.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.P256.PrecompTable.fsti" }
[ "total" ]
[ "Lib.IntTypes.uint64", "Prims.Cons", "Prims.Nil", "Prims.list" ]
[]
module Hacl.Spec.P256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Impl.P256.Point module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module FL = FStar.List.Tot #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
true
Hacl.Spec.P256.PrecompTable.fsti
{ "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 create4 (x0 x1 x2 x3: uint64) : list uint64
[]
Hacl.Spec.P256.PrecompTable.create4
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.PrecompTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: Lib.IntTypes.uint64 -> x1: Lib.IntTypes.uint64 -> x2: Lib.IntTypes.uint64 -> x3: Lib.IntTypes.uint64 -> Prims.list Lib.IntTypes.uint64
{ "end_col": 65, "end_line": 16, "start_col": 49, "start_line": 16 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "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.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": 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 felem_list = x:list uint64{FL.length x == 4}
let felem_list =
false
null
false
x: list uint64 {FL.length x == 4}
{ "checked_file": "Hacl.Spec.P256.PrecompTable.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.P256.PrecompTable.fsti" }
[ "total" ]
[ "Prims.list", "Lib.IntTypes.uint64", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length" ]
[]
module Hacl.Spec.P256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Impl.P256.Point module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module FL = FStar.List.Tot #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" unfold let create4 (x0 x1 x2 x3:uint64) : list uint64 = [x0; x1; x2; x3]
false
true
Hacl.Spec.P256.PrecompTable.fsti
{ "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 felem_list : Type0
[]
Hacl.Spec.P256.PrecompTable.felem_list
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.PrecompTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 48, "end_line": 19, "start_col": 17, "start_line": 19 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "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.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": 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 point_list = x:list uint64{FL.length x == 12}
let point_list =
false
null
false
x: list uint64 {FL.length x == 12}
{ "checked_file": "Hacl.Spec.P256.PrecompTable.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.P256.PrecompTable.fsti" }
[ "total" ]
[ "Prims.list", "Lib.IntTypes.uint64", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length" ]
[]
module Hacl.Spec.P256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Impl.P256.Point module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module FL = FStar.List.Tot #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" unfold let create4 (x0 x1 x2 x3:uint64) : list uint64 = [x0; x1; x2; x3] inline_for_extraction noextract let felem_list = x:list uint64{FL.length x == 4}
false
true
Hacl.Spec.P256.PrecompTable.fsti
{ "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 point_list : Type0
[]
Hacl.Spec.P256.PrecompTable.point_list
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.PrecompTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 49, "end_line": 21, "start_col": 17, "start_line": 21 }
Prims.Tot
val proj_point_to_list (p: S.proj_point) : point_list
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "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.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": 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 proj_point_to_list (p:S.proj_point) : point_list = [@inline_let] let (px, py, pz) = p in [@inline_let] let pxM = SM.to_mont px in [@inline_let] let pyM = SM.to_mont py in [@inline_let] let pzM = SM.to_mont pz in FL.(felem_to_list pxM @ felem_to_list pyM @ felem_to_list pzM)
val proj_point_to_list (p: S.proj_point) : point_list let proj_point_to_list (p: S.proj_point) : point_list =
false
null
false
[@@ inline_let ]let px, py, pz = p in [@@ inline_let ]let pxM = SM.to_mont px in [@@ inline_let ]let pyM = SM.to_mont py in [@@ inline_let ]let pzM = SM.to_mont pz in let open FL in felem_to_list pxM @ felem_to_list pyM @ felem_to_list pzM
{ "checked_file": "Hacl.Spec.P256.PrecompTable.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.P256.PrecompTable.fsti" }
[ "total" ]
[ "Spec.P256.PointOps.proj_point", "Prims.nat", "FStar.List.Tot.Base.op_At", "Lib.IntTypes.uint64", "Hacl.Spec.P256.PrecompTable.felem_to_list", "Spec.P256.PointOps.felem", "Hacl.Spec.P256.Montgomery.to_mont", "Hacl.Spec.P256.PrecompTable.point_list" ]
[]
module Hacl.Spec.P256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Impl.P256.Point module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module FL = FStar.List.Tot #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" unfold let create4 (x0 x1 x2 x3:uint64) : list uint64 = [x0; x1; x2; x3] inline_for_extraction noextract let felem_list = x:list uint64{FL.length x == 4} inline_for_extraction noextract let point_list = x:list uint64{FL.length x == 12} inline_for_extraction noextract let felem_to_list (x:S.felem) : felem_list = [@inline_let] let x0 = x % pow2 64 in [@inline_let] let x1 = x / pow2 64 % pow2 64 in [@inline_let] let x2 = x / pow2 128 % pow2 64 in [@inline_let] let x3 = x / pow2 192 % pow2 64 in [@inline_let] let r = create4 (u64 x0) (u64 x1) (u64 x2) (u64 x3) in assert_norm (FL.length r = 4); r inline_for_extraction noextract
false
true
Hacl.Spec.P256.PrecompTable.fsti
{ "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 proj_point_to_list (p: S.proj_point) : point_list
[]
Hacl.Spec.P256.PrecompTable.proj_point_to_list
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.PrecompTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Spec.P256.PointOps.proj_point -> Hacl.Spec.P256.PrecompTable.point_list
{ "end_col": 64, "end_line": 39, "start_col": 2, "start_line": 35 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "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.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": 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 point_inv_list (p:point_list) = let x = Seq.seq_of_list p <: lseq uint64 12 in point_inv_seq x
let point_inv_list (p: point_list) =
false
null
false
let x = Seq.seq_of_list p <: lseq uint64 12 in point_inv_seq x
{ "checked_file": "Hacl.Spec.P256.PrecompTable.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.P256.PrecompTable.fsti" }
[ "total" ]
[ "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Impl.P256.Point.point_inv_seq", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.uint64", "Prims.logical" ]
[]
module Hacl.Spec.P256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Impl.P256.Point module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module FL = FStar.List.Tot #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" unfold let create4 (x0 x1 x2 x3:uint64) : list uint64 = [x0; x1; x2; x3] inline_for_extraction noextract let felem_list = x:list uint64{FL.length x == 4} inline_for_extraction noextract let point_list = x:list uint64{FL.length x == 12} inline_for_extraction noextract let felem_to_list (x:S.felem) : felem_list = [@inline_let] let x0 = x % pow2 64 in [@inline_let] let x1 = x / pow2 64 % pow2 64 in [@inline_let] let x2 = x / pow2 128 % pow2 64 in [@inline_let] let x3 = x / pow2 192 % pow2 64 in [@inline_let] let r = create4 (u64 x0) (u64 x1) (u64 x2) (u64 x3) in assert_norm (FL.length r = 4); r inline_for_extraction noextract let proj_point_to_list (p:S.proj_point) : point_list = [@inline_let] let (px, py, pz) = p in [@inline_let] let pxM = SM.to_mont px in [@inline_let] let pyM = SM.to_mont py in [@inline_let] let pzM = SM.to_mont pz in FL.(felem_to_list pxM @ felem_to_list pyM @ felem_to_list pzM)
false
true
Hacl.Spec.P256.PrecompTable.fsti
{ "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 point_inv_list : p: Hacl.Spec.P256.PrecompTable.point_list -> Prims.logical
[]
Hacl.Spec.P256.PrecompTable.point_inv_list
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.PrecompTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Spec.P256.PrecompTable.point_list -> Prims.logical
{ "end_col": 17, "end_line": 44, "start_col": 35, "start_line": 42 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "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.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": 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 point_eval_list (p:point_list) = let x = Seq.seq_of_list p <: lseq uint64 12 in from_mont_point (as_point_nat_seq x)
let point_eval_list (p: point_list) =
false
null
false
let x = Seq.seq_of_list p <: lseq uint64 12 in from_mont_point (as_point_nat_seq x)
{ "checked_file": "Hacl.Spec.P256.PrecompTable.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.P256.PrecompTable.fsti" }
[ "total" ]
[ "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Impl.P256.Point.from_mont_point", "Hacl.Impl.P256.Point.as_point_nat_seq", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.uint64", "Spec.P256.PointOps.proj_point" ]
[]
module Hacl.Spec.P256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Impl.P256.Point module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module FL = FStar.List.Tot #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" unfold let create4 (x0 x1 x2 x3:uint64) : list uint64 = [x0; x1; x2; x3] inline_for_extraction noextract let felem_list = x:list uint64{FL.length x == 4} inline_for_extraction noextract let point_list = x:list uint64{FL.length x == 12} inline_for_extraction noextract let felem_to_list (x:S.felem) : felem_list = [@inline_let] let x0 = x % pow2 64 in [@inline_let] let x1 = x / pow2 64 % pow2 64 in [@inline_let] let x2 = x / pow2 128 % pow2 64 in [@inline_let] let x3 = x / pow2 192 % pow2 64 in [@inline_let] let r = create4 (u64 x0) (u64 x1) (u64 x2) (u64 x3) in assert_norm (FL.length r = 4); r inline_for_extraction noextract let proj_point_to_list (p:S.proj_point) : point_list = [@inline_let] let (px, py, pz) = p in [@inline_let] let pxM = SM.to_mont px in [@inline_let] let pyM = SM.to_mont py in [@inline_let] let pzM = SM.to_mont pz in FL.(felem_to_list pxM @ felem_to_list pyM @ felem_to_list pzM) inline_for_extraction noextract let point_inv_list (p:point_list) = let x = Seq.seq_of_list p <: lseq uint64 12 in point_inv_seq x
false
true
Hacl.Spec.P256.PrecompTable.fsti
{ "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 point_eval_list : p: Hacl.Spec.P256.PrecompTable.point_list -> Spec.P256.PointOps.proj_point
[]
Hacl.Spec.P256.PrecompTable.point_eval_list
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.PrecompTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Spec.P256.PrecompTable.point_list -> Spec.P256.PointOps.proj_point
{ "end_col": 38, "end_line": 49, "start_col": 36, "start_line": 47 }
Prims.Tot
val felem_to_list (x: S.felem) : felem_list
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "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.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": 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 felem_to_list (x:S.felem) : felem_list = [@inline_let] let x0 = x % pow2 64 in [@inline_let] let x1 = x / pow2 64 % pow2 64 in [@inline_let] let x2 = x / pow2 128 % pow2 64 in [@inline_let] let x3 = x / pow2 192 % pow2 64 in [@inline_let] let r = create4 (u64 x0) (u64 x1) (u64 x2) (u64 x3) in assert_norm (FL.length r = 4); r
val felem_to_list (x: S.felem) : felem_list let felem_to_list (x: S.felem) : felem_list =
false
null
false
[@@ inline_let ]let x0 = x % pow2 64 in [@@ inline_let ]let x1 = x / pow2 64 % pow2 64 in [@@ inline_let ]let x2 = x / pow2 128 % pow2 64 in [@@ inline_let ]let x3 = x / pow2 192 % pow2 64 in [@@ inline_let ]let r = create4 (u64 x0) (u64 x1) (u64 x2) (u64 x3) in assert_norm (FL.length r = 4); r
{ "checked_file": "Hacl.Spec.P256.PrecompTable.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.P256.PrecompTable.fsti" }
[ "total" ]
[ "Spec.P256.PointOps.felem", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Lib.IntTypes.uint64", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.P256.PrecompTable.create4", "Lib.IntTypes.u64", "Prims.op_Modulus", "Prims.op_Division", "Prims.pow2", "Hacl.Spec.P256.PrecompTable.felem_list" ]
[]
module Hacl.Spec.P256.PrecompTable open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Impl.P256.Point module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module FL = FStar.List.Tot #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" unfold let create4 (x0 x1 x2 x3:uint64) : list uint64 = [x0; x1; x2; x3] inline_for_extraction noextract let felem_list = x:list uint64{FL.length x == 4} inline_for_extraction noextract let point_list = x:list uint64{FL.length x == 12} inline_for_extraction noextract
false
true
Hacl.Spec.P256.PrecompTable.fsti
{ "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 felem_to_list (x: S.felem) : felem_list
[]
Hacl.Spec.P256.PrecompTable.felem_to_list
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.PrecompTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.P256.PointOps.felem -> Hacl.Spec.P256.PrecompTable.felem_list
{ "end_col": 3, "end_line": 31, "start_col": 2, "start_line": 25 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 mem_of #a #f (s:ordset a f) x = mem x s
let mem_of #a #f (s: ordset a f) x =
false
null
false
mem x s
{ "checked_file": "FStar.OrdSet.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.OrdSet.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.OrdSet.cmp", "FStar.OrdSet.ordset", "FStar.OrdSet.mem", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.OrdSet type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} let rec sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = match l with | [] -> true | x::[] -> true | x::y::tl -> f x y && x <> y && sorted f (y::tl) val ordset (a:eqtype) (f:cmp a) : Type0 val hasEq_ordset: a:eqtype -> f:cmp a -> Lemma (requires (True)) (ensures (hasEq (ordset a f))) [SMTPat (hasEq (ordset a f))] val empty : #a:eqtype -> #f:cmp a -> Tot (ordset a f) val tail (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : ordset a f val head (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : a val mem : #a:eqtype -> #f:cmp a -> a -> s:ordset a f -> Tot bool
false
false
FStar.OrdSet.fsti
{ "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 mem_of : s: FStar.OrdSet.ordset a f -> x: a -> Prims.bool
[]
FStar.OrdSet.mem_of
{ "file_name": "ulib/experimental/FStar.OrdSet.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.OrdSet.ordset a f -> x: a -> Prims.bool
{ "end_col": 50, "end_line": 45, "start_col": 43, "start_line": 45 }
Prims.Tot
val strict_superset (#a #f: _) (s1 s2: ordset a f) : Tot bool
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 strict_superset #a #f (s1 s2: ordset a f) : Tot bool = strict_subset s2 s1
val strict_superset (#a #f: _) (s1 s2: ordset a f) : Tot bool let strict_superset #a #f (s1: ordset a f) (s2: ordset a f) : Tot bool =
false
null
false
strict_subset s2 s1
{ "checked_file": "FStar.OrdSet.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.OrdSet.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.OrdSet.cmp", "FStar.OrdSet.ordset", "FStar.OrdSet.strict_subset", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.OrdSet type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} let rec sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = match l with | [] -> true | x::[] -> true | x::y::tl -> f x y && x <> y && sorted f (y::tl) val ordset (a:eqtype) (f:cmp a) : Type0 val hasEq_ordset: a:eqtype -> f:cmp a -> Lemma (requires (True)) (ensures (hasEq (ordset a f))) [SMTPat (hasEq (ordset a f))] val empty : #a:eqtype -> #f:cmp a -> Tot (ordset a f) val tail (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : ordset a f val head (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : a val mem : #a:eqtype -> #f:cmp a -> a -> s:ordset a f -> Tot bool (* currying-friendly version of mem, ready to be used as a lambda *) unfold let mem_of #a #f (s:ordset a f) x = mem x s val last (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (x:a{(forall (z:a{mem z s}). f z x) /\ mem x s}) (* liat is the reverse of tail, i.e. a list of all but the last element. A shortcut to (fst (unsnoc s)), which as a word is composed in a remarkably similar fashion. *) val liat (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (l:ordset a f{ (forall x. mem x l = (mem x s && (x <> last s))) /\ (if tail s <> empty then (l <> empty) && (head s = head l) else true) }) val unsnoc (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (p:(ordset a f * a){ p = (liat s, last s) }) val as_list (#a:eqtype) (#f:cmp a) (s:ordset a f) : Tot (l:list a{ sorted f l /\ (forall x. (List.Tot.mem x l = mem x s)) }) val distinct (#a:eqtype) (f:cmp a) (l: list a) : Pure (ordset a f) (requires True) (ensures fun z -> forall x. (mem x z = List.Tot.Base.mem x l)) val union : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val intersect : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val choose : #a:eqtype -> #f:cmp a -> s:ordset a f -> Tot (option a) val remove : #a:eqtype -> #f:cmp a -> a -> ordset a f -> Tot (ordset a f) val size : #a:eqtype -> #f:cmp a -> ordset a f -> Tot nat val subset : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool let superset #a #f (s1 s2: ordset a f) : Tot bool = subset s2 s1 val singleton : #a:eqtype -> #f:cmp a -> a -> Tot (ordset a f) val minus : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f)
false
false
FStar.OrdSet.fsti
{ "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 strict_superset (#a #f: _) (s1 s2: ordset a f) : Tot bool
[]
FStar.OrdSet.strict_superset
{ "file_name": "ulib/experimental/FStar.OrdSet.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.OrdSet.ordset a f -> s2: FStar.OrdSet.ordset a f -> Prims.bool
{ "end_col": 78, "end_line": 88, "start_col": 59, "start_line": 88 }
Prims.Tot
val superset (#a #f: _) (s1 s2: ordset a f) : Tot bool
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 superset #a #f (s1 s2: ordset a f) : Tot bool = subset s2 s1
val superset (#a #f: _) (s1 s2: ordset a f) : Tot bool let superset #a #f (s1: ordset a f) (s2: ordset a f) : Tot bool =
false
null
false
subset s2 s1
{ "checked_file": "FStar.OrdSet.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.OrdSet.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.OrdSet.cmp", "FStar.OrdSet.ordset", "FStar.OrdSet.subset", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.OrdSet type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} let rec sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = match l with | [] -> true | x::[] -> true | x::y::tl -> f x y && x <> y && sorted f (y::tl) val ordset (a:eqtype) (f:cmp a) : Type0 val hasEq_ordset: a:eqtype -> f:cmp a -> Lemma (requires (True)) (ensures (hasEq (ordset a f))) [SMTPat (hasEq (ordset a f))] val empty : #a:eqtype -> #f:cmp a -> Tot (ordset a f) val tail (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : ordset a f val head (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : a val mem : #a:eqtype -> #f:cmp a -> a -> s:ordset a f -> Tot bool (* currying-friendly version of mem, ready to be used as a lambda *) unfold let mem_of #a #f (s:ordset a f) x = mem x s val last (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (x:a{(forall (z:a{mem z s}). f z x) /\ mem x s}) (* liat is the reverse of tail, i.e. a list of all but the last element. A shortcut to (fst (unsnoc s)), which as a word is composed in a remarkably similar fashion. *) val liat (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (l:ordset a f{ (forall x. mem x l = (mem x s && (x <> last s))) /\ (if tail s <> empty then (l <> empty) && (head s = head l) else true) }) val unsnoc (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (p:(ordset a f * a){ p = (liat s, last s) }) val as_list (#a:eqtype) (#f:cmp a) (s:ordset a f) : Tot (l:list a{ sorted f l /\ (forall x. (List.Tot.mem x l = mem x s)) }) val distinct (#a:eqtype) (f:cmp a) (l: list a) : Pure (ordset a f) (requires True) (ensures fun z -> forall x. (mem x z = List.Tot.Base.mem x l)) val union : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val intersect : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val choose : #a:eqtype -> #f:cmp a -> s:ordset a f -> Tot (option a) val remove : #a:eqtype -> #f:cmp a -> a -> ordset a f -> Tot (ordset a f) val size : #a:eqtype -> #f:cmp a -> ordset a f -> Tot nat
false
false
FStar.OrdSet.fsti
{ "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 superset (#a #f: _) (s1 s2: ordset a f) : Tot bool
[]
FStar.OrdSet.superset
{ "file_name": "ulib/experimental/FStar.OrdSet.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.OrdSet.ordset a f -> s2: FStar.OrdSet.ordset a f -> Prims.bool
{ "end_col": 64, "end_line": 81, "start_col": 52, "start_line": 81 }
Prims.Tot
val equal (#a: eqtype) (#f: cmp a) (s1 s2: ordset a f) : Tot prop
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 equal (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) : Tot prop = forall x. mem #_ #f x s1 = mem #_ #f x s2
val equal (#a: eqtype) (#f: cmp a) (s1 s2: ordset a f) : Tot prop let equal (#a: eqtype) (#f: cmp a) (s1 s2: ordset a f) : Tot prop =
false
null
false
forall x. mem #_ #f x s1 = mem #_ #f x s2
{ "checked_file": "FStar.OrdSet.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.OrdSet.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.OrdSet.cmp", "FStar.OrdSet.ordset", "Prims.l_Forall", "Prims.b2t", "Prims.op_Equality", "Prims.bool", "FStar.OrdSet.mem", "Prims.prop" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.OrdSet type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} let rec sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = match l with | [] -> true | x::[] -> true | x::y::tl -> f x y && x <> y && sorted f (y::tl) val ordset (a:eqtype) (f:cmp a) : Type0 val hasEq_ordset: a:eqtype -> f:cmp a -> Lemma (requires (True)) (ensures (hasEq (ordset a f))) [SMTPat (hasEq (ordset a f))] val empty : #a:eqtype -> #f:cmp a -> Tot (ordset a f) val tail (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : ordset a f val head (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : a val mem : #a:eqtype -> #f:cmp a -> a -> s:ordset a f -> Tot bool (* currying-friendly version of mem, ready to be used as a lambda *) unfold let mem_of #a #f (s:ordset a f) x = mem x s val last (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (x:a{(forall (z:a{mem z s}). f z x) /\ mem x s}) (* liat is the reverse of tail, i.e. a list of all but the last element. A shortcut to (fst (unsnoc s)), which as a word is composed in a remarkably similar fashion. *) val liat (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (l:ordset a f{ (forall x. mem x l = (mem x s && (x <> last s))) /\ (if tail s <> empty then (l <> empty) && (head s = head l) else true) }) val unsnoc (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (p:(ordset a f * a){ p = (liat s, last s) }) val as_list (#a:eqtype) (#f:cmp a) (s:ordset a f) : Tot (l:list a{ sorted f l /\ (forall x. (List.Tot.mem x l = mem x s)) }) val distinct (#a:eqtype) (f:cmp a) (l: list a) : Pure (ordset a f) (requires True) (ensures fun z -> forall x. (mem x z = List.Tot.Base.mem x l)) val union : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val intersect : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val choose : #a:eqtype -> #f:cmp a -> s:ordset a f -> Tot (option a) val remove : #a:eqtype -> #f:cmp a -> a -> ordset a f -> Tot (ordset a f) val size : #a:eqtype -> #f:cmp a -> ordset a f -> Tot nat val subset : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool let superset #a #f (s1 s2: ordset a f) : Tot bool = subset s2 s1 val singleton : #a:eqtype -> #f:cmp a -> a -> Tot (ordset a f) val minus : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val strict_subset: #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool let strict_superset #a #f (s1 s2: ordset a f) : Tot bool = strict_subset s2 s1 let disjoint #a #f (s1 s2 : ordset a f) : Tot bool = intersect s1 s2 = empty
false
false
FStar.OrdSet.fsti
{ "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 equal (#a: eqtype) (#f: cmp a) (s1 s2: ordset a f) : Tot prop
[]
FStar.OrdSet.equal
{ "file_name": "ulib/experimental/FStar.OrdSet.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.OrdSet.ordset a f -> s2: FStar.OrdSet.ordset a f -> Prims.prop
{ "end_col": 43, "end_line": 93, "start_col": 2, "start_line": 93 }
Prims.Tot
val sorted (#a: eqtype) (f: cmp a) (l: list a) : Tot bool
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = match l with | [] -> true | x::[] -> true | x::y::tl -> f x y && x <> y && sorted f (y::tl)
val sorted (#a: eqtype) (f: cmp a) (l: list a) : Tot bool let rec sorted (#a: eqtype) (f: cmp a) (l: list a) : Tot bool =
false
null
false
match l with | [] -> true | x :: [] -> true | x :: y :: tl -> f x y && x <> y && sorted f (y :: tl)
{ "checked_file": "FStar.OrdSet.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.OrdSet.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.OrdSet.cmp", "Prims.list", "Prims.op_AmpAmp", "Prims.op_disEquality", "FStar.OrdSet.sorted", "Prims.Cons", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.OrdSet type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f}
false
false
FStar.OrdSet.fsti
{ "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 sorted (#a: eqtype) (f: cmp a) (l: list a) : Tot bool
[ "recursion" ]
FStar.OrdSet.sorted
{ "file_name": "ulib/experimental/FStar.OrdSet.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: FStar.OrdSet.cmp a -> l: Prims.list a -> Prims.bool
{ "end_col": 51, "end_line": 29, "start_col": 2, "start_line": 26 }
Prims.Tot
val disjoint (#a #f: _) (s1 s2: ordset a f) : Tot bool
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 disjoint #a #f (s1 s2 : ordset a f) : Tot bool = intersect s1 s2 = empty
val disjoint (#a #f: _) (s1 s2: ordset a f) : Tot bool let disjoint #a #f (s1: ordset a f) (s2: ordset a f) : Tot bool =
false
null
false
intersect s1 s2 = empty
{ "checked_file": "FStar.OrdSet.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.OrdSet.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.OrdSet.cmp", "FStar.OrdSet.ordset", "Prims.op_Equality", "FStar.OrdSet.intersect", "FStar.OrdSet.empty", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.OrdSet type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} let rec sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = match l with | [] -> true | x::[] -> true | x::y::tl -> f x y && x <> y && sorted f (y::tl) val ordset (a:eqtype) (f:cmp a) : Type0 val hasEq_ordset: a:eqtype -> f:cmp a -> Lemma (requires (True)) (ensures (hasEq (ordset a f))) [SMTPat (hasEq (ordset a f))] val empty : #a:eqtype -> #f:cmp a -> Tot (ordset a f) val tail (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : ordset a f val head (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : a val mem : #a:eqtype -> #f:cmp a -> a -> s:ordset a f -> Tot bool (* currying-friendly version of mem, ready to be used as a lambda *) unfold let mem_of #a #f (s:ordset a f) x = mem x s val last (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (x:a{(forall (z:a{mem z s}). f z x) /\ mem x s}) (* liat is the reverse of tail, i.e. a list of all but the last element. A shortcut to (fst (unsnoc s)), which as a word is composed in a remarkably similar fashion. *) val liat (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (l:ordset a f{ (forall x. mem x l = (mem x s && (x <> last s))) /\ (if tail s <> empty then (l <> empty) && (head s = head l) else true) }) val unsnoc (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (p:(ordset a f * a){ p = (liat s, last s) }) val as_list (#a:eqtype) (#f:cmp a) (s:ordset a f) : Tot (l:list a{ sorted f l /\ (forall x. (List.Tot.mem x l = mem x s)) }) val distinct (#a:eqtype) (f:cmp a) (l: list a) : Pure (ordset a f) (requires True) (ensures fun z -> forall x. (mem x z = List.Tot.Base.mem x l)) val union : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val intersect : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val choose : #a:eqtype -> #f:cmp a -> s:ordset a f -> Tot (option a) val remove : #a:eqtype -> #f:cmp a -> a -> ordset a f -> Tot (ordset a f) val size : #a:eqtype -> #f:cmp a -> ordset a f -> Tot nat val subset : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool let superset #a #f (s1 s2: ordset a f) : Tot bool = subset s2 s1 val singleton : #a:eqtype -> #f:cmp a -> a -> Tot (ordset a f) val minus : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val strict_subset: #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool let strict_superset #a #f (s1 s2: ordset a f) : Tot bool = strict_subset s2 s1
false
false
FStar.OrdSet.fsti
{ "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 disjoint (#a #f: _) (s1 s2: ordset a f) : Tot bool
[]
FStar.OrdSet.disjoint
{ "file_name": "ulib/experimental/FStar.OrdSet.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s1: FStar.OrdSet.ordset a f -> s2: FStar.OrdSet.ordset a f -> Prims.bool
{ "end_col": 76, "end_line": 90, "start_col": 53, "start_line": 90 }
Prims.Tot
val inv (#a: _) (c: condition a) : (z: condition a {forall x. c x = not (z x)})
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 inv #a (c: condition a) : (z:condition a{forall x. c x = not (z x)}) = fun x -> not (c x)
val inv (#a: _) (c: condition a) : (z: condition a {forall x. c x = not (z x)}) let inv #a (c: condition a) : (z: condition a {forall x. c x = not (z x)}) =
false
null
false
fun x -> not (c x)
{ "checked_file": "FStar.OrdSet.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.OrdSet.fsti" }
[ "total" ]
[ "FStar.OrdSet.condition", "Prims.op_Negation", "Prims.bool", "Prims.l_Forall", "Prims.b2t", "Prims.op_Equality" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.OrdSet type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} let rec sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = match l with | [] -> true | x::[] -> true | x::y::tl -> f x y && x <> y && sorted f (y::tl) val ordset (a:eqtype) (f:cmp a) : Type0 val hasEq_ordset: a:eqtype -> f:cmp a -> Lemma (requires (True)) (ensures (hasEq (ordset a f))) [SMTPat (hasEq (ordset a f))] val empty : #a:eqtype -> #f:cmp a -> Tot (ordset a f) val tail (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : ordset a f val head (#a:eqtype) (#f:cmp a) (s:ordset a f{s<>empty}) : a val mem : #a:eqtype -> #f:cmp a -> a -> s:ordset a f -> Tot bool (* currying-friendly version of mem, ready to be used as a lambda *) unfold let mem_of #a #f (s:ordset a f) x = mem x s val last (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (x:a{(forall (z:a{mem z s}). f z x) /\ mem x s}) (* liat is the reverse of tail, i.e. a list of all but the last element. A shortcut to (fst (unsnoc s)), which as a word is composed in a remarkably similar fashion. *) val liat (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (l:ordset a f{ (forall x. mem x l = (mem x s && (x <> last s))) /\ (if tail s <> empty then (l <> empty) && (head s = head l) else true) }) val unsnoc (#a:eqtype) (#f:cmp a) (s: ordset a f{s <> empty}) : Tot (p:(ordset a f * a){ p = (liat s, last s) }) val as_list (#a:eqtype) (#f:cmp a) (s:ordset a f) : Tot (l:list a{ sorted f l /\ (forall x. (List.Tot.mem x l = mem x s)) }) val distinct (#a:eqtype) (f:cmp a) (l: list a) : Pure (ordset a f) (requires True) (ensures fun z -> forall x. (mem x z = List.Tot.Base.mem x l)) val union : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val intersect : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val choose : #a:eqtype -> #f:cmp a -> s:ordset a f -> Tot (option a) val remove : #a:eqtype -> #f:cmp a -> a -> ordset a f -> Tot (ordset a f) val size : #a:eqtype -> #f:cmp a -> ordset a f -> Tot nat val subset : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool let superset #a #f (s1 s2: ordset a f) : Tot bool = subset s2 s1 val singleton : #a:eqtype -> #f:cmp a -> a -> Tot (ordset a f) val minus : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) val strict_subset: #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool let strict_superset #a #f (s1 s2: ordset a f) : Tot bool = strict_subset s2 s1 let disjoint #a #f (s1 s2 : ordset a f) : Tot bool = intersect s1 s2 = empty let equal (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) : Tot prop = forall x. mem #_ #f x s1 = mem #_ #f x s2 val eq_lemma: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f -> Lemma (requires (equal s1 s2)) (ensures (s1 = s2)) [SMTPat (equal s1 s2)] val mem_empty: #a:eqtype -> #f:cmp a -> x:a -> Lemma (requires True) (ensures (not (mem #a #f x (empty #a #f)))) [SMTPat (mem #a #f x (empty #a #f))] val mem_singleton: #a:eqtype -> #f:cmp a -> x:a -> y:a -> Lemma (requires True) (ensures (mem #a #f y (singleton #a #f x)) = (x = y)) [SMTPat (mem #a #f y (singleton #a #f x))] val mem_union: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f -> x:a -> Lemma (requires True) (ensures (mem #a #f x (union #a #f s1 s2) = (mem #a #f x s1 || mem #a #f x s2))) [SMTPat (mem #a #f x (union #a #f s1 s2))] val mem_intersect: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f -> x:a -> Lemma (requires True) (ensures (mem #a #f x (intersect s1 s2) = (mem #a #f x s1 && mem #a #f x s2))) [SMTPat (mem #a #f x (intersect #a #f s1 s2))] val mem_subset: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f -> Lemma (requires True) (ensures (subset #a #f s1 s2 <==> (forall x. mem #a #f x s1 ==> mem #a #f x s2))) [SMTPat (subset #a #f s1 s2)] val choose_empty: #a:eqtype -> #f:cmp a -> Lemma (requires True) (ensures (None? (choose #a #f (empty #a #f)))) [SMTPat (choose #a #f (empty #a #f))] (* TODO: FIXME: Pattern does not contain all quantified vars *) val choose_s: #a:eqtype -> #f:cmp a -> s:ordset a f -> Lemma (requires (not (s = (empty #a #f)))) (ensures (Some? (choose #a #f s) /\ s = union #a #f (singleton #a #f (Some?.v (choose #a #f s))) (remove #a #f (Some?.v (choose #a #f s)) s))) [SMTPat (choose #a #f s)] val mem_remove: #a:eqtype -> #f:cmp a -> x:a -> y:a -> s:ordset a f -> Lemma (requires True) (ensures (mem #a #f x (remove #a #f y s) = (mem #a #f x s && not (x = y)))) [SMTPat (mem #a #f x (remove #a #f y s))] val eq_remove: #a:eqtype -> #f:cmp a -> x:a -> s:ordset a f -> Lemma (requires (not (mem #a #f x s))) (ensures (s = remove #a #f x s)) [SMTPat (remove #a #f x s)] val size_empty: #a:eqtype -> #f:cmp a -> s:ordset a f -> Lemma (requires True) (ensures ((size #a #f s = 0) = (s = empty #a #f))) [SMTPat (size #a #f s)] val size_remove: #a:eqtype -> #f:cmp a -> y:a -> s:ordset a f -> Lemma (requires (mem #a #f y s)) (ensures (size #a #f s = size #a #f (remove #a #f y s) + 1)) [SMTPat (size #a #f (remove #a #f y s))] val size_singleton: #a:eqtype -> #f:cmp a -> x:a -> Lemma (requires True) (ensures (size #a #f (singleton #a #f x) = 1)) [SMTPat (size #a #f (singleton #a #f x))] val subset_size: #a:eqtype -> #f:cmp a -> x:ordset a f -> y:ordset a f -> Lemma (requires (subset #a #f x y)) (ensures (size #a #f x <= size #a #f y)) [SMTPat (subset #a #f x y)] (**********) val size_union: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f -> Lemma (requires True) (ensures ((size #a #f (union #a #f s1 s2) >= size #a #f s1) && (size #a #f (union #a #f s1 s2) >= size #a #f s2))) [SMTPat (size #a #f (union #a #f s1 s2))] (**********) val fold (#a:eqtype) (#acc:Type) (#f:cmp a) (g:acc -> a -> acc) (init:acc) (s:ordset a f) : Tot acc val map (#a #b:eqtype) (#fa:cmp a) (#fb:cmp b) (g:a -> b) (sa:ordset a fa) : Pure (ordset b fb) (requires (forall x y. (x `fa` y ==> g x `fb` g y) /\ (x = y <==> g x = g y))) (ensures (fun sb -> (size sb <= size sa) /\ (as_list sb == FStar.List.Tot.map g (as_list sa)) /\ (let sa = as_list sa in let sb = as_list sb in Cons? sb ==> Cons? sa /\ Cons?.hd sb == g (Cons?.hd sa)))) val lemma_strict_subset_size (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) : Lemma (requires (strict_subset s1 s2)) (ensures (subset s1 s2 /\ size s1 < size s2)) [SMTPat (strict_subset s1 s2)] val lemma_minus_mem (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) (x:a) : Lemma (requires True) (ensures (mem x (minus s1 s2) = (mem x s1 && not (mem x s2)))) [SMTPat (mem x (minus s1 s2))] val lemma_strict_subset_exists_diff (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) : Lemma (requires subset s1 s2) (ensures (strict_subset s1 s2) <==> (exists x. (mem x s2 /\ not (mem x s1)))) type condition a = a -> bool
false
false
FStar.OrdSet.fsti
{ "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 inv (#a: _) (c: condition a) : (z: condition a {forall x. c x = not (z x)})
[]
FStar.OrdSet.inv
{ "file_name": "ulib/experimental/FStar.OrdSet.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
c: FStar.OrdSet.condition a -> z: FStar.OrdSet.condition a {forall (x: a). c x = Prims.op_Negation (z x)}
{ "end_col": 93, "end_line": 205, "start_col": 75, "start_line": 205 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2)
let union_contains_element_from_second_argument_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a) (y: a). {:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.union" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 union_contains_element_from_second_argument_fact : Prims.logical
[]
FStar.FiniteSet.Base.union_contains_element_from_second_argument_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 36, "end_line": 270, "start_col": 2, "start_line": 269 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s
let insert_fact =
false
null
false
forall (a: eqtype) (s: set a) (x: a) (o: a). {:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_iff", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.insert", "Prims.l_or", "Prims.eq2" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 insert_fact : Prims.logical
[]
FStar.FiniteSet.Base.insert_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 45, "end_line": 207, "start_col": 2, "start_line": 206 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a))
let empty_set_contains_no_elements_fact =
false
null
false
forall (a: eqtype) (o: a). {:pattern mem o (emptyset)} not (mem o (emptyset #a))
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "Prims.b2t", "Prims.op_Negation", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.emptyset" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 empty_set_contains_no_elements_fact : Prims.logical
[]
FStar.FiniteSet.Base.empty_set_contains_no_elements_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 81, "end_line": 166, "start_col": 2, "start_line": 166 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s)
let insert_contains_argument_fact =
false
null
false
forall (a: eqtype) (s: set a) (x: a). {:pattern insert x s} mem x (insert x s)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.insert" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 insert_contains_argument_fact : Prims.logical
[]
FStar.FiniteSet.Base.insert_contains_argument_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 22, "end_line": 216, "start_col": 2, "start_line": 215 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o
let singleton_contains_fact =
false
null
false
forall (a: eqtype) (r: a) (o: a). {:pattern mem o (singleton r)} mem o (singleton r) <==> r == o
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "Prims.l_iff", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.singleton", "Prims.eq2" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o);
false
true
FStar.FiniteSet.Base.fsti
{ "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 singleton_contains_fact : Prims.logical
[]
FStar.FiniteSet.Base.singleton_contains_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 97, "end_line": 191, "start_col": 2, "start_line": 191 }
Prims.Tot
val remove (#a: eqtype) (x: a) (s: set a) : set a
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x)
val remove (#a: eqtype) (x: a) (s: set a) : set a let remove (#a: eqtype) (x: a) (s: set a) : set a =
false
null
false
difference s (singleton x)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "FStar.FiniteSet.Base.difference", "FStar.FiniteSet.Base.singleton" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a)
false
false
FStar.FiniteSet.Base.fsti
{ "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 remove (#a: eqtype) (x: a) (s: set a) : set a
[]
FStar.FiniteSet.Base.remove
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> s: FStar.FiniteSet.Base.set a -> FStar.FiniteSet.Base.set a
{ "end_col": 28, "end_line": 146, "start_col": 2, "start_line": 146 }
Prims.Tot
val notin (#a: eqtype) (x: a) (s: set a) : bool
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s)
val notin (#a: eqtype) (x: a) (s: set a) : bool let notin (#a: eqtype) (x: a) (s: set a) : bool =
false
null
false
not (mem x s)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.op_Negation", "FStar.FiniteSet.Base.mem", "Prims.bool" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a)
false
false
FStar.FiniteSet.Base.fsti
{ "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 notin (#a: eqtype) (x: a) (s: set a) : bool
[]
FStar.FiniteSet.Base.notin
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> s: FStar.FiniteSet.Base.set a -> Prims.bool
{ "end_col": 15, "end_line": 150, "start_col": 2, "start_line": 150 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s))
let length_zero_fact =
false
null
false
forall (a: eqtype) (s: set a). {:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s))
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_and", "Prims.l_iff", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.FiniteSet.Base.cardinality", "Prims.eq2", "FStar.FiniteSet.Base.emptyset", "Prims.op_disEquality", "Prims.l_Exists", "FStar.FiniteSet.Base.mem" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x])));
false
true
FStar.FiniteSet.Base.fsti
{ "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 length_zero_fact : Prims.logical
[]
FStar.FiniteSet.Base.length_zero_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 52, "end_line": 177, "start_col": 2, "start_line": 175 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s)
let insert_contains_fact =
false
null
false
forall (a: eqtype) (s: set a) (x: a) (y: a). {:pattern insert x s; mem y s} mem y s ==> mem y (insert x s)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.insert" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 insert_contains_fact : Prims.logical
[]
FStar.FiniteSet.Base.insert_contains_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 34, "end_line": 225, "start_col": 2, "start_line": 224 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2
let intersection_cardinality_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Addition", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.union", "FStar.FiniteSet.Base.intersection" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b));
false
true
FStar.FiniteSet.Base.fsti
{ "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 intersection_cardinality_fact : Prims.logical
[]
FStar.FiniteSet.Base.intersection_cardinality_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 98, "end_line": 335, "start_col": 2, "start_line": 334 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1
let union_of_disjoint_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "FStar.FiniteSet.Base.disjoint", "Prims.l_and", "Prims.eq2", "FStar.FiniteSet.Base.difference", "FStar.FiniteSet.Base.union" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a);
false
true
FStar.FiniteSet.Base.fsti
{ "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 union_of_disjoint_fact : Prims.logical
[]
FStar.FiniteSet.Base.union_of_disjoint_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 93, "end_line": 281, "start_col": 2, "start_line": 280 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2
let intersection_idempotent_right_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.intersection" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b));
false
true
FStar.FiniteSet.Base.fsti
{ "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 intersection_idempotent_right_fact : Prims.logical
[]
FStar.FiniteSet.Base.intersection_idempotent_right_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 62, "end_line": 317, "start_col": 2, "start_line": 316 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1
let insert_nonmember_cardinality_fact =
false
null
false
forall (a: eqtype) (s: set a) (x: a). {:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "Prims.op_Negation", "FStar.FiniteSet.Base.mem", "Prims.op_Equality", "Prims.int", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.insert", "Prims.op_Addition" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1);
false
true
FStar.FiniteSet.Base.fsti
{ "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 insert_nonmember_cardinality_fact : Prims.logical
[]
FStar.FiniteSet.Base.insert_nonmember_cardinality_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 66, "end_line": 243, "start_col": 2, "start_line": 242 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2
let union_idempotent_right_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.union" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b));
false
true
FStar.FiniteSet.Base.fsti
{ "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 union_idempotent_right_fact : Prims.logical
[]
FStar.FiniteSet.Base.union_idempotent_right_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 41, "end_line": 299, "start_col": 2, "start_line": 298 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2
let intersection_contains_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a) (o: a). {:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_iff", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.intersection", "Prims.l_and" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 intersection_contains_fact : Prims.logical
[]
FStar.FiniteSet.Base.intersection_contains_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 56, "end_line": 290, "start_col": 2, "start_line": 289 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2)
let union_contains_element_from_first_argument_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a) (y: a). {:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.union" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 union_contains_element_from_first_argument_fact : Prims.logical
[]
FStar.FiniteSet.Base.union_contains_element_from_first_argument_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 36, "end_line": 261, "start_col": 2, "start_line": 260 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2
let union_contains_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a) (o: a). {:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_iff", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.union", "Prims.l_or" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 union_contains_fact : Prims.logical
[]
FStar.FiniteSet.Base.union_contains_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 49, "end_line": 252, "start_col": 2, "start_line": 251 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2
let intersection_idempotent_left_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.intersection" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b));
false
true
FStar.FiniteSet.Base.fsti
{ "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 intersection_idempotent_left_fact : Prims.logical
[]
FStar.FiniteSet.Base.intersection_idempotent_left_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 62, "end_line": 326, "start_col": 2, "start_line": 325 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2
let union_idempotent_left_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.eq2", "FStar.FiniteSet.Base.union" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b));
false
true
FStar.FiniteSet.Base.fsti
{ "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 union_idempotent_left_fact : Prims.logical
[]
FStar.FiniteSet.Base.union_idempotent_left_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 41, "end_line": 308, "start_col": 2, "start_line": 307 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2)
let difference_contains_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a) (o: a). {:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_iff", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.difference", "Prims.l_and", "Prims.op_Negation" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 difference_contains_fact : Prims.logical
[]
FStar.FiniteSet.Base.difference_contains_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 60, "end_line": 344, "start_col": 2, "start_line": 343 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2))
let difference_doesnt_include_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a) (y: a). {:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2))
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "Prims.op_Negation", "FStar.FiniteSet.Base.difference" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] );
false
true
FStar.FiniteSet.Base.fsti
{ "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 difference_doesnt_include_fact : Prims.logical
[]
FStar.FiniteSet.Base.difference_doesnt_include_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 47, "end_line": 353, "start_col": 2, "start_line": 352 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 equal_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2)
let equal_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern equal s1 s2} equal s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 <==> mem o s2)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_iff", "FStar.FiniteSet.Base.equal", "Prims.b2t", "FStar.FiniteSet.Base.mem" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o])); let subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) /// We represent the following Dafny axiom with `equal_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } /// Set#Equal(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] <==> b[o]));
false
true
FStar.FiniteSet.Base.fsti
{ "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 equal_fact : Prims.logical
[]
FStar.FiniteSet.Base.equal_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 86, "end_line": 385, "start_col": 2, "start_line": 384 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 insert_remove_fact = forall (a: eqtype) (x: a) (s: set a).{:pattern insert x (remove x s)} mem x s = true ==> insert x (remove x s) == s
let insert_remove_fact =
false
null
false
forall (a: eqtype) (x: a) (s: set a). {:pattern insert x (remove x s)} mem x s = true ==> insert x (remove x s) == s
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.bool", "FStar.FiniteSet.Base.mem", "Prims.eq2", "FStar.FiniteSet.Base.insert", "FStar.FiniteSet.Base.remove" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o])); let subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) /// We represent the following Dafny axiom with `equal_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } /// Set#Equal(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] <==> b[o])); let equal_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) /// We represent the following Dafny axiom with `equal_extensionality_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } // extensionality axiom for sets /// Set#Equal(a,b) ==> a == b); let equal_extensionality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 ==> s1 == s2 /// We represent the following Dafny axiom with `disjoint_fact`: /// /// axiom (forall<T> a: Set T, b: Set T :: { Set#Disjoint(a,b) } /// Set#Disjoint(a,b) <==> (forall o: T :: {a[o]} {b[o]} !a[o] || !b[o])); let disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern disjoint s1 s2} disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) /// We add a few more facts for the utility function `remove` and for `set_as_list`:
false
true
FStar.FiniteSet.Base.fsti
{ "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 insert_remove_fact : Prims.logical
[]
FStar.FiniteSet.Base.insert_remove_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 49, "end_line": 409, "start_col": 2, "start_line": 408 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern disjoint s1 s2} disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2))
let disjoint_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern disjoint s1 s2} disjoint s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} not (mem o s1) \/ not (mem o s2))
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_iff", "FStar.FiniteSet.Base.disjoint", "Prims.l_or", "Prims.b2t", "Prims.op_Negation", "FStar.FiniteSet.Base.mem" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o])); let subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) /// We represent the following Dafny axiom with `equal_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } /// Set#Equal(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] <==> b[o])); let equal_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) /// We represent the following Dafny axiom with `equal_extensionality_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } // extensionality axiom for sets /// Set#Equal(a,b) ==> a == b); let equal_extensionality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 ==> s1 == s2 /// We represent the following Dafny axiom with `disjoint_fact`: /// /// axiom (forall<T> a: Set T, b: Set T :: { Set#Disjoint(a,b) } /// Set#Disjoint(a,b) <==> (forall o: T :: {a[o]} {b[o]} !a[o] || !b[o]));
false
true
FStar.FiniteSet.Base.fsti
{ "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 disjoint_fact : Prims.logical
[]
FStar.FiniteSet.Base.disjoint_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 99, "end_line": 403, "start_col": 2, "start_line": 402 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2)
let subset_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern subset s1 s2} subset s1 s2 <==> (forall o. {:pattern mem o s1\/mem o s2} mem o s1 ==> mem o s2)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_iff", "FStar.FiniteSet.Base.subset", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o]));
false
true
FStar.FiniteSet.Base.fsti
{ "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 subset_fact : Prims.logical
[]
FStar.FiniteSet.Base.subset_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 86, "end_line": 376, "start_col": 2, "start_line": 375 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 equal_extensionality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 ==> s1 == s2
let equal_extensionality_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern equal s1 s2} equal s1 s2 ==> s1 == s2
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "FStar.FiniteSet.Base.equal", "Prims.eq2" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o])); let subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) /// We represent the following Dafny axiom with `equal_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } /// Set#Equal(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] <==> b[o])); let equal_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) /// We represent the following Dafny axiom with `equal_extensionality_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } // extensionality axiom for sets /// Set#Equal(a,b) ==> a == b);
false
true
FStar.FiniteSet.Base.fsti
{ "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 equal_extensionality_fact : Prims.logical
[]
FStar.FiniteSet.Base.equal_extensionality_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 28, "end_line": 394, "start_col": 2, "start_line": 393 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)
let difference_cardinality_fact =
false
null
false
forall (a: eqtype) (s1: set a) (s2: set a). {:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Addition", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.difference", "FStar.FiniteSet.Base.intersection", "FStar.FiniteSet.Base.union", "Prims.op_Subtraction" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b)));
false
true
FStar.FiniteSet.Base.fsti
{ "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 difference_cardinality_fact : Prims.logical
[]
FStar.FiniteSet.Base.difference_cardinality_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 89, "end_line": 367, "start_col": 2, "start_line": 365 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r)
let singleton_contains_argument_fact =
false
null
false
forall (a: eqtype) (r: a). {:pattern singleton r} mem r (singleton r)
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "Prims.b2t", "FStar.FiniteSet.Base.mem", "FStar.FiniteSet.Base.singleton" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]);
false
true
FStar.FiniteSet.Base.fsti
{ "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 singleton_contains_argument_fact : Prims.logical
[]
FStar.FiniteSet.Base.singleton_contains_argument_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 70, "end_line": 184, "start_col": 2, "start_line": 184 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 remove_insert_fact = forall (a: eqtype) (x: a) (s: set a).{:pattern remove x (insert x s)} mem x s = false ==> remove x (insert x s) == s
let remove_insert_fact =
false
null
false
forall (a: eqtype) (x: a) (s: set a). {:pattern remove x (insert x s)} mem x s = false ==> remove x (insert x s) == s
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.bool", "FStar.FiniteSet.Base.mem", "Prims.eq2", "FStar.FiniteSet.Base.remove", "FStar.FiniteSet.Base.insert" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o])); let subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) /// We represent the following Dafny axiom with `equal_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } /// Set#Equal(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] <==> b[o])); let equal_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) /// We represent the following Dafny axiom with `equal_extensionality_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } // extensionality axiom for sets /// Set#Equal(a,b) ==> a == b); let equal_extensionality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 ==> s1 == s2 /// We represent the following Dafny axiom with `disjoint_fact`: /// /// axiom (forall<T> a: Set T, b: Set T :: { Set#Disjoint(a,b) } /// Set#Disjoint(a,b) <==> (forall o: T :: {a[o]} {b[o]} !a[o] || !b[o])); let disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern disjoint s1 s2} disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) /// We add a few more facts for the utility function `remove` and for `set_as_list`: let insert_remove_fact = forall (a: eqtype) (x: a) (s: set a).{:pattern insert x (remove x s)} mem x s = true ==> insert x (remove x s) == s
false
true
FStar.FiniteSet.Base.fsti
{ "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 remove_insert_fact : Prims.logical
[]
FStar.FiniteSet.Base.remove_insert_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 50, "end_line": 413, "start_col": 2, "start_line": 412 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 all_finite_set_facts = empty_set_contains_no_elements_fact /\ length_zero_fact /\ singleton_contains_argument_fact /\ singleton_contains_fact /\ singleton_cardinality_fact /\ insert_fact /\ insert_contains_argument_fact /\ insert_contains_fact /\ insert_member_cardinality_fact /\ insert_nonmember_cardinality_fact /\ union_contains_fact /\ union_contains_element_from_first_argument_fact /\ union_contains_element_from_second_argument_fact /\ union_of_disjoint_fact /\ intersection_contains_fact /\ union_idempotent_right_fact /\ union_idempotent_left_fact /\ intersection_idempotent_right_fact /\ intersection_idempotent_left_fact /\ intersection_cardinality_fact /\ difference_contains_fact /\ difference_doesnt_include_fact /\ difference_cardinality_fact /\ subset_fact /\ equal_fact /\ equal_extensionality_fact /\ disjoint_fact /\ insert_remove_fact /\ remove_insert_fact /\ set_as_list_cardinality_fact
let all_finite_set_facts =
false
null
false
empty_set_contains_no_elements_fact /\ length_zero_fact /\ singleton_contains_argument_fact /\ singleton_contains_fact /\ singleton_cardinality_fact /\ insert_fact /\ insert_contains_argument_fact /\ insert_contains_fact /\ insert_member_cardinality_fact /\ insert_nonmember_cardinality_fact /\ union_contains_fact /\ union_contains_element_from_first_argument_fact /\ union_contains_element_from_second_argument_fact /\ union_of_disjoint_fact /\ intersection_contains_fact /\ union_idempotent_right_fact /\ union_idempotent_left_fact /\ intersection_idempotent_right_fact /\ intersection_idempotent_left_fact /\ intersection_cardinality_fact /\ difference_contains_fact /\ difference_doesnt_include_fact /\ difference_cardinality_fact /\ subset_fact /\ equal_fact /\ equal_extensionality_fact /\ disjoint_fact /\ insert_remove_fact /\ remove_insert_fact /\ set_as_list_cardinality_fact
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_and", "FStar.FiniteSet.Base.empty_set_contains_no_elements_fact", "FStar.FiniteSet.Base.length_zero_fact", "FStar.FiniteSet.Base.singleton_contains_argument_fact", "FStar.FiniteSet.Base.singleton_contains_fact", "FStar.FiniteSet.Base.singleton_cardinality_fact", "FStar.FiniteSet.Base.insert_fact", "FStar.FiniteSet.Base.insert_contains_argument_fact", "FStar.FiniteSet.Base.insert_contains_fact", "FStar.FiniteSet.Base.insert_member_cardinality_fact", "FStar.FiniteSet.Base.insert_nonmember_cardinality_fact", "FStar.FiniteSet.Base.union_contains_fact", "FStar.FiniteSet.Base.union_contains_element_from_first_argument_fact", "FStar.FiniteSet.Base.union_contains_element_from_second_argument_fact", "FStar.FiniteSet.Base.union_of_disjoint_fact", "FStar.FiniteSet.Base.intersection_contains_fact", "FStar.FiniteSet.Base.union_idempotent_right_fact", "FStar.FiniteSet.Base.union_idempotent_left_fact", "FStar.FiniteSet.Base.intersection_idempotent_right_fact", "FStar.FiniteSet.Base.intersection_idempotent_left_fact", "FStar.FiniteSet.Base.intersection_cardinality_fact", "FStar.FiniteSet.Base.difference_contains_fact", "FStar.FiniteSet.Base.difference_doesnt_include_fact", "FStar.FiniteSet.Base.difference_cardinality_fact", "FStar.FiniteSet.Base.subset_fact", "FStar.FiniteSet.Base.equal_fact", "FStar.FiniteSet.Base.equal_extensionality_fact", "FStar.FiniteSet.Base.disjoint_fact", "FStar.FiniteSet.Base.insert_remove_fact", "FStar.FiniteSet.Base.remove_insert_fact", "FStar.FiniteSet.Base.set_as_list_cardinality_fact" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o])); let subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) /// We represent the following Dafny axiom with `equal_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } /// Set#Equal(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] <==> b[o])); let equal_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) /// We represent the following Dafny axiom with `equal_extensionality_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } // extensionality axiom for sets /// Set#Equal(a,b) ==> a == b); let equal_extensionality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 ==> s1 == s2 /// We represent the following Dafny axiom with `disjoint_fact`: /// /// axiom (forall<T> a: Set T, b: Set T :: { Set#Disjoint(a,b) } /// Set#Disjoint(a,b) <==> (forall o: T :: {a[o]} {b[o]} !a[o] || !b[o])); let disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern disjoint s1 s2} disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) /// We add a few more facts for the utility function `remove` and for `set_as_list`: let insert_remove_fact = forall (a: eqtype) (x: a) (s: set a).{:pattern insert x (remove x s)} mem x s = true ==> insert x (remove x s) == s let remove_insert_fact = forall (a: eqtype) (x: a) (s: set a).{:pattern remove x (insert x s)} mem x s = false ==> remove x (insert x s) == s let set_as_list_cardinality_fact = forall (a: eqtype) (s: set a).{:pattern FLT.length (set_as_list s)} FLT.length (set_as_list s) = cardinality s (** The predicate `all_finite_set_facts` collects all the Dafny finite-set axioms. One can bring all these facts into scope with `all_finite_set_facts_lemma ()`. **)
false
true
FStar.FiniteSet.Base.fsti
{ "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 all_finite_set_facts : Prims.logical
[]
FStar.FiniteSet.Base.all_finite_set_facts
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 33, "end_line": 454, "start_col": 4, "start_line": 425 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1
let singleton_cardinality_fact =
false
null
false
forall (a: eqtype) (r: a). {:pattern cardinality (singleton r)} cardinality (singleton r) = 1
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.singleton" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1);
false
true
FStar.FiniteSet.Base.fsti
{ "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 singleton_cardinality_fact : Prims.logical
[]
FStar.FiniteSet.Base.singleton_cardinality_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 94, "end_line": 198, "start_col": 2, "start_line": 198 }
Prims.Tot
val list_nonrepeating (#a: eqtype) (xs: list a) : bool
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl
val list_nonrepeating (#a: eqtype) (xs: list a) : bool let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool =
false
null
false
match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.eqtype", "Prims.list", "Prims.op_AmpAmp", "Prims.op_Negation", "FStar.List.Tot.Base.mem", "FStar.FiniteSet.Base.list_nonrepeating", "Prims.bool" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`:
false
false
FStar.FiniteSet.Base.fsti
{ "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 list_nonrepeating (#a: eqtype) (xs: list a) : bool
[ "recursion" ]
FStar.FiniteSet.Base.list_nonrepeating
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
xs: Prims.list a -> Prims.bool
{ "end_col": 59, "end_line": 60, "start_col": 2, "start_line": 58 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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 insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s
let insert_member_cardinality_fact =
false
null
false
forall (a: eqtype) (s: set a) (x: a). {:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.l_imp", "Prims.b2t", "FStar.FiniteSet.Base.mem", "Prims.op_Equality", "Prims.nat", "FStar.FiniteSet.Base.cardinality", "FStar.FiniteSet.Base.insert" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a));
false
true
FStar.FiniteSet.Base.fsti
{ "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 insert_member_cardinality_fact : Prims.logical
[]
FStar.FiniteSet.Base.insert_member_cardinality_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 56, "end_line": 234, "start_col": 2, "start_line": 233 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FLT" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": false, "full_module": "FStar.FiniteSet", "short_module": null }, { "abbrev": 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_as_list_cardinality_fact = forall (a: eqtype) (s: set a).{:pattern FLT.length (set_as_list s)} FLT.length (set_as_list s) = cardinality s
let set_as_list_cardinality_fact =
false
null
false
forall (a: eqtype) (s: set a). {:pattern FLT.length (set_as_list s)} FLT.length (set_as_list s) = cardinality s
{ "checked_file": "FStar.FiniteSet.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.FiniteSet.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eqtype", "FStar.FiniteSet.Base.set", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.List.Tot.Base.length", "FStar.FiniteSet.Base.set_as_list", "FStar.FiniteSet.Base.cardinality" ]
[]
(* Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling finite sets as they're modeled in Dafny. @summary Type and functions for modeling finite sets *) module FStar.FiniteSet.Base open FStar.FunctionalExtensionality module FLT = FStar.List.Tot val set (a: eqtype) : Type0 (** We translate each Dafny sequence function prefixed with `Set#` into an F* function. **) /// We represent the Dafny operator [] on sets with `mem`: val mem (#a: eqtype) (x: a) (s: set a) : bool /// We can convert a set to a list with `set_as_list`: let rec list_nonrepeating (#a: eqtype) (xs: list a) : bool = match xs with | [] -> true | hd :: tl -> not (FLT.mem hd tl) && list_nonrepeating tl val set_as_list (#a: eqtype) (s: set a) : GTot (xs: list a{list_nonrepeating xs /\ (forall x. FLT.mem x xs = mem x s)}) /// We represent the Dafny function `Set#Card` with `cardinality`: /// /// function Set#Card<T>(Set T): int; val cardinality (#a: eqtype) (s: set a) : GTot nat /// We represent the Dafny function `Set#Empty` with `empty`: /// /// function Set#Empty<T>(): Set T; val emptyset (#a: eqtype) : set a /// We represent the Dafny function `Set#UnionOne` with `insert`: /// /// function Set#UnionOne<T>(Set T, T): Set T; val insert (#a: eqtype) (x: a) (s: set a) : set a /// We represent the Dafny function `Set#Singleton` with `singleton`: /// /// function Set#Singleton<T>(T): Set T; val singleton (#a: eqtype) (x: a) : set a /// We represent the Dafny function `Set#Union` with `union`: /// /// function Set#Union<T>(Set T, Set T): Set T; val union (#a: eqtype) (s1: set a) (s2: set a) : (set a) /// We represent the Dafny function `Set#Intersection` with `intersection`: /// /// function Set#Intersection<T>(Set T, Set T): Set T; val intersection (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Difference` with `difference`: /// /// function Set#Difference<T>(Set T, Set T): Set T; val difference (#a: eqtype) (s1: set a) (s2: set a) : set a /// We represent the Dafny function `Set#Subset` with `subset`: /// /// function Set#Subset<T>(Set T, Set T): bool; val subset (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Equal` with `equal`: /// /// function Set#Equal<T>(Set T, Set T): bool; val equal (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny function `Set#Disjoint` with `disjoint`: /// /// function Set#Disjoint<T>(Set T, Set T): bool; val disjoint (#a: eqtype) (s1: set a) (s2: set a) : Type0 /// We represent the Dafny choice operator by `choose`: /// /// var x: T :| x in s; val choose (#a: eqtype) (s: set a{exists x. mem x s}) : GTot (x: a{mem x s}) /// We add the utility functions `remove` and `notin`: let remove (#a: eqtype) (x: a) (s: set a) : set a = difference s (singleton x) let notin (#a: eqtype) (x: a) (s: set a) : bool = not (mem x s) (** We translate each finite set axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from cardinality: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } 0 <= Set#Card(s)); /// We represent the following Dafny axiom with `empty_set_contains_no_elements_fact`: /// /// axiom (forall<T> o: T :: { Set#Empty()[o] } !Set#Empty()[o]); let empty_set_contains_no_elements_fact = forall (a: eqtype) (o: a).{:pattern mem o (emptyset)} not (mem o (emptyset #a)) /// We represent the following Dafny axiom with `length_zero_fact`: /// /// axiom (forall<T> s: Set T :: { Set#Card(s) } /// (Set#Card(s) == 0 <==> s == Set#Empty()) && /// (Set#Card(s) != 0 ==> (exists x: T :: s[x]))); let length_zero_fact = forall (a: eqtype) (s: set a).{:pattern cardinality s} (cardinality s = 0 <==> s == emptyset) /\ (cardinality s <> 0 <==> (exists x. mem x s)) /// We represent the following Dafny axiom with `singleton_contains_argument_fact`: /// /// axiom (forall<T> r: T :: { Set#Singleton(r) } Set#Singleton(r)[r]); let singleton_contains_argument_fact = forall (a: eqtype) (r: a).{:pattern singleton r} mem r (singleton r) /// We represent the following Dafny axiom with `singleton_contains_fact`: /// /// axiom (forall<T> r: T, o: T :: { Set#Singleton(r)[o] } Set#Singleton(r)[o] <==> r == o); let singleton_contains_fact = forall (a: eqtype) (r: a) (o: a).{:pattern mem o (singleton r)} mem o (singleton r) <==> r == o /// We represent the following Dafny axiom with `singleton_cardinality_fact`: /// /// axiom (forall<T> r: T :: { Set#Card(Set#Singleton(r)) } Set#Card(Set#Singleton(r)) == 1); let singleton_cardinality_fact = forall (a: eqtype) (r: a).{:pattern cardinality (singleton r)} cardinality (singleton r) = 1 /// We represent the following Dafny axiom with `insert_fact`: /// /// axiom (forall<T> a: Set T, x: T, o: T :: { Set#UnionOne(a,x)[o] } /// Set#UnionOne(a,x)[o] <==> o == x || a[o]); let insert_fact = forall (a: eqtype) (s: set a) (x: a) (o: a).{:pattern mem o (insert x s)} mem o (insert x s) <==> o == x \/ mem o s /// We represent the following Dafny axiom with `insert_contains_argument_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#UnionOne(a, x) } /// Set#UnionOne(a, x)[x]); let insert_contains_argument_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern insert x s} mem x (insert x s) /// We represent the following Dafny axiom with `insert_contains_fact`: /// /// axiom (forall<T> a: Set T, x: T, y: T :: { Set#UnionOne(a, x), a[y] } /// a[y] ==> Set#UnionOne(a, x)[y]); let insert_contains_fact = forall (a: eqtype) (s: set a) (x: a) (y: a).{:pattern insert x s; mem y s} mem y s ==> mem y (insert x s) /// We represent the following Dafny axiom with `insert_member_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a)); let insert_member_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} mem x s ==> cardinality (insert x s) = cardinality s /// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`: /// /// axiom (forall<T> a: Set T, x: T :: { Set#Card(Set#UnionOne(a, x)) } /// !a[x] ==> Set#Card(Set#UnionOne(a, x)) == Set#Card(a) + 1); let insert_nonmember_cardinality_fact = forall (a: eqtype) (s: set a) (x: a).{:pattern cardinality (insert x s)} not (mem x s) ==> cardinality (insert x s) = cardinality s + 1 /// We represent the following Dafny axiom with `union_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Union(a,b)[o] } /// Set#Union(a,b)[o] <==> a[o] || b[o]); let union_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (union s1 s2)} mem o (union s1 s2) <==> mem o s1 \/ mem o s2 /// We represent the following Dafny axiom with `union_contains_element_from_first_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// a[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_first_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s1} mem y s1 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_contains_element_from_second_argument_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Union(a, b), a[y] } /// b[y] ==> Set#Union(a, b)[y]); let union_contains_element_from_second_argument_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern union s1 s2; mem y s2} mem y s2 ==> mem y (union s1 s2) /// We represent the following Dafny axiom with `union_of_disjoint_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, b) } /// Set#Disjoint(a, b) ==> /// Set#Difference(Set#Union(a, b), a) == b && /// Set#Difference(Set#Union(a, b), b) == a); let union_of_disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 s2} disjoint s1 s2 ==> difference (union s1 s2) s1 == s2 /\ difference (union s1 s2) s2 == s1 /// We represent the following Dafny axiom with `intersection_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Intersection(a,b)[o] } /// Set#Intersection(a,b)[o] <==> a[o] && b[o]); let intersection_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (intersection s1 s2)} mem o (intersection s1 s2) <==> mem o s1 /\ mem o s2 /// We represent the following Dafny axiom with `union_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(Set#Union(a, b), b) } /// Set#Union(Set#Union(a, b), b) == Set#Union(a, b)); let union_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union (union s1 s2) s2} union (union s1 s2) s2 == union s1 s2 /// We represent the following Dafny axiom with `union_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Union(a, Set#Union(a, b)) } /// Set#Union(a, Set#Union(a, b)) == Set#Union(a, b)); let union_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern union s1 (union s1 s2)} union s1 (union s1 s2) == union s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_right_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(Set#Intersection(a, b), b) } /// Set#Intersection(Set#Intersection(a, b), b) == Set#Intersection(a, b)); let intersection_idempotent_right_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection (intersection s1 s2) s2} intersection (intersection s1 s2) s2 == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_idempotent_left_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Intersection(a, Set#Intersection(a, b)) } /// Set#Intersection(a, Set#Intersection(a, b)) == Set#Intersection(a, b)); let intersection_idempotent_left_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern intersection s1 (intersection s1 s2)} intersection s1 (intersection s1 s2) == intersection s1 s2 /// We represent the following Dafny axiom with `intersection_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: { Set#Card(Set#Union(a, b)) }{ Set#Card(Set#Intersection(a, b)) } /// Set#Card(Set#Union(a, b)) + Set#Card(Set#Intersection(a, b)) == Set#Card(a) + Set#Card(b)); let intersection_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (intersection s1 s2)} cardinality (union s1 s2) + cardinality (intersection s1 s2) = cardinality s1 + cardinality s2 /// We represent the following Dafny axiom with `difference_contains_fact`: /// /// axiom (forall<T> a: Set T, b: Set T, o: T :: { Set#Difference(a,b)[o] } /// Set#Difference(a,b)[o] <==> a[o] && !b[o]); let difference_contains_fact = forall (a: eqtype) (s1: set a) (s2: set a) (o: a).{:pattern mem o (difference s1 s2)} mem o (difference s1 s2) <==> mem o s1 /\ not (mem o s2) /// We represent the following Dafny axiom with `difference_doesnt_include_fact`: /// /// axiom (forall<T> a, b: Set T, y: T :: { Set#Difference(a, b), b[y] } /// b[y] ==> !Set#Difference(a, b)[y] ); let difference_doesnt_include_fact = forall (a: eqtype) (s1: set a) (s2: set a) (y: a).{:pattern difference s1 s2; mem y s2} mem y s2 ==> not (mem y (difference s1 s2)) /// We represent the following Dafny axiom with `difference_cardinality_fact`: /// /// axiom (forall<T> a, b: Set T :: /// { Set#Card(Set#Difference(a, b)) } /// Set#Card(Set#Difference(a, b)) + Set#Card(Set#Difference(b, a)) /// + Set#Card(Set#Intersection(a, b)) /// == Set#Card(Set#Union(a, b)) && /// Set#Card(Set#Difference(a, b)) == Set#Card(a) - Set#Card(Set#Intersection(a, b))); let difference_cardinality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern cardinality (difference s1 s2)} cardinality (difference s1 s2) + cardinality (difference s2 s1) + cardinality (intersection s1 s2) = cardinality (union s1 s2) /\ cardinality (difference s1 s2) = cardinality s1 - cardinality (intersection s1 s2) /// We represent the following Dafny axiom with `subset_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Subset(a,b) } /// Set#Subset(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] ==> b[o])); let subset_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern subset s1 s2} subset s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 ==> mem o s2) /// We represent the following Dafny axiom with `equal_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } /// Set#Equal(a,b) <==> (forall o: T :: {a[o]} {b[o]} a[o] <==> b[o])); let equal_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} mem o s1 <==> mem o s2) /// We represent the following Dafny axiom with `equal_extensionality_fact`: /// /// axiom(forall<T> a: Set T, b: Set T :: { Set#Equal(a,b) } // extensionality axiom for sets /// Set#Equal(a,b) ==> a == b); let equal_extensionality_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern equal s1 s2} equal s1 s2 ==> s1 == s2 /// We represent the following Dafny axiom with `disjoint_fact`: /// /// axiom (forall<T> a: Set T, b: Set T :: { Set#Disjoint(a,b) } /// Set#Disjoint(a,b) <==> (forall o: T :: {a[o]} {b[o]} !a[o] || !b[o])); let disjoint_fact = forall (a: eqtype) (s1: set a) (s2: set a).{:pattern disjoint s1 s2} disjoint s1 s2 <==> (forall o.{:pattern mem o s1 \/ mem o s2} not (mem o s1) \/ not (mem o s2)) /// We add a few more facts for the utility function `remove` and for `set_as_list`: let insert_remove_fact = forall (a: eqtype) (x: a) (s: set a).{:pattern insert x (remove x s)} mem x s = true ==> insert x (remove x s) == s let remove_insert_fact = forall (a: eqtype) (x: a) (s: set a).{:pattern remove x (insert x s)} mem x s = false ==> remove x (insert x s) == s
false
true
FStar.FiniteSet.Base.fsti
{ "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_as_list_cardinality_fact : Prims.logical
[]
FStar.FiniteSet.Base.set_as_list_cardinality_fact
{ "file_name": "ulib/FStar.FiniteSet.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 46, "end_line": 417, "start_col": 2, "start_line": 416 }
Prims.Tot
val struct_field' (l: struct_typ') : Tot eqtype
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } )
val struct_field' (l: struct_typ') : Tot eqtype let struct_field' (l: struct_typ') : Tot eqtype =
false
null
false
(s: string{List.Tot.mem s (List.Tot.map fst l)})
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ'", "Prims.string", "Prims.b2t", "FStar.List.Tot.Base.mem", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.tuple2", "FStar.Pointer.Base.typ", "FStar.Pervasives.Native.fst", "Prims.eqtype" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ')
false
true
FStar.Pointer.Base.fsti
{ "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 struct_field' (l: struct_typ') : Tot eqtype
[]
FStar.Pointer.Base.struct_field'
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ' -> Prims.eqtype
{ "end_col": 54, "end_line": 84, "start_col": 2, "start_line": 84 }
FStar.Pervasives.Lemma
val type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l)
val type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] =
false
null
true
assert_norm (type_of_typ (TStruct l) == struct l)
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "lemma" ]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.Pointer.Base.type_of_typ", "FStar.Pointer.Base.TStruct", "FStar.Pointer.Base.struct", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l)
false
false
FStar.Pointer.Base.fsti
{ "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 type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))]
[]
FStar.Pointer.Base.type_of_typ_struct
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ -> FStar.Pervasives.Lemma (ensures FStar.Pointer.Base.type_of_typ (FStar.Pointer.Base.TStruct l) == FStar.Pointer.Base.struct l ) [SMTPat (FStar.Pointer.Base.type_of_typ (FStar.Pointer.Base.TStruct l))]
{ "end_col": 51, "end_line": 282, "start_col": 2, "start_line": 282 }
Prims.Tot
val pointer (t: typ) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } )
val pointer (t: typ) : Tot Type0 let pointer (t: typ) : Tot Type0 =
false
null
false
(p: npointer t {g_is_null p == false})
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.typ", "FStar.Pointer.Base.npointer", "Prims.eq2", "Prims.bool", "FStar.Pointer.Base.g_is_null" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))]
false
true
FStar.Pointer.Base.fsti
{ "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 pointer (t: typ) : Tot Type0
[]
FStar.Pointer.Base.pointer
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Pointer.Base.typ -> Type0
{ "end_col": 76, "end_line": 184, "start_col": 35, "start_line": 184 }
Prims.Tot
val struct_field (l: struct_typ) : Tot eqtype
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields
val struct_field (l: struct_typ) : Tot eqtype let struct_field (l: struct_typ) : Tot eqtype =
false
null
false
struct_field' l.fields
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.struct_field'", "FStar.Pointer.Base.__proj__Mkstruct_typ__item__fields", "Prims.eqtype" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ)
false
true
FStar.Pointer.Base.fsti
{ "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 struct_field (l: struct_typ) : Tot eqtype
[]
FStar.Pointer.Base.struct_field
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ -> Prims.eqtype
{ "end_col": 24, "end_line": 89, "start_col": 2, "start_line": 89 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 union_field = struct_field
let union_field =
false
null
false
struct_field
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_field" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`).
false
true
FStar.Pointer.Base.fsti
{ "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 union_field : l: FStar.Pointer.Base.struct_typ -> Prims.eqtype
[]
FStar.Pointer.Base.union_field
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ -> Prims.eqtype
{ "end_col": 30, "end_line": 94, "start_col": 18, "start_line": 94 }
Prims.Tot
val type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x)
val type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) =
false
null
false
type_of_struct_field' l (fun (x: typ{x << l}) -> type_of_typ x)
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.type_of_struct_field'", "FStar.Pointer.Base.typ", "Prims.precedes", "FStar.Pointer.Base.type_of_typ", "FStar.Pointer.Base.struct_field" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ)
false
false
FStar.Pointer.Base.fsti
{ "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 type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0)
[]
FStar.Pointer.Base.type_of_struct_field
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ -> _: FStar.Pointer.Base.struct_field l -> Type0
{ "end_col": 64, "end_line": 275, "start_col": 2, "start_line": 275 }
Prims.Tot
val dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f
val dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string =
false
null
false
let (| f , _ |) = p in f
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ", "Prims.dtuple2", "FStar.Pointer.Base.struct_field", "FStar.Pointer.Base.type_of_struct_field", "Prims.string" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x))
false
false
FStar.Pointer.Base.fsti
{ "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 dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string
[]
FStar.Pointer.Base.dfst_struct_field
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.Pointer.Base.struct_typ -> p: Prims.dtuple2 (FStar.Pointer.Base.struct_field s) (fun x -> FStar.Pointer.Base.type_of_struct_field s x) -> Prims.string
{ "end_col": 3, "end_line": 300, "start_col": 1, "start_line": 298 }
Prims.Tot
val struct_literal (s: struct_typ) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x)
val struct_literal (s: struct_typ) : Tot Type0 let struct_literal (s: struct_typ) : Tot Type0 =
false
null
false
list (x: struct_field s & type_of_struct_field s x)
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ", "Prims.list", "Prims.dtuple2", "FStar.Pointer.Base.struct_field", "FStar.Pointer.Base.type_of_struct_field" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f
false
true
FStar.Pointer.Base.fsti
{ "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 struct_literal (s: struct_typ) : Tot Type0
[]
FStar.Pointer.Base.struct_literal
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.Pointer.Base.struct_typ -> Type0
{ "end_col": 100, "end_line": 302, "start_col": 49, "start_line": 302 }
FStar.Pervasives.Lemma
val type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] = assert_norm (type_of_typ (TUnion l) == union l)
val type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] let type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] =
false
null
true
assert_norm (type_of_typ (TUnion l) == union l)
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "lemma" ]
[ "FStar.Pointer.Base.union_typ", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.Pointer.Base.type_of_typ", "FStar.Pointer.Base.TUnion", "FStar.Pointer.Base.union", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim () val struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) : Tot (struct l) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = struct_create_fun s (fun_of_list s l) val struct_sel_struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) (fd: struct_field l) : Lemma (struct_sel (struct_create_fun l f) fd == f fd) [SMTPat (struct_sel (struct_create_fun l f) fd)] let type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l)
false
false
FStar.Pointer.Base.fsti
{ "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 type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))]
[]
FStar.Pointer.Base.type_of_typ_union
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.union_typ -> FStar.Pervasives.Lemma (ensures FStar.Pointer.Base.type_of_typ (FStar.Pointer.Base.TUnion l) == FStar.Pointer.Base.union l) [SMTPat (FStar.Pointer.Base.type_of_typ (FStar.Pointer.Base.TUnion l))]
{ "end_col": 49, "end_line": 357, "start_col": 2, "start_line": 357 }
Prims.GTot
val modifies_0 (h0 h1: HS.mem) : GTot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 modifies_0 (h0 h1: HS.mem) : GTot Type0 = modifies loc_none h0 h1
val modifies_0 (h0 h1: HS.mem) : GTot Type0 let modifies_0 (h0 h1: HS.mem) : GTot Type0 =
false
null
false
modifies loc_none h0 h1
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Pointer.Base.modifies", "FStar.Pointer.Base.loc_none" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim () val struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) : Tot (struct l) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = struct_create_fun s (fun_of_list s l) val struct_sel_struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) (fd: struct_field l) : Lemma (struct_sel (struct_create_fun l f) fd == f fd) [SMTPat (struct_sel (struct_create_fun l f) fd)] let type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] = assert_norm (type_of_typ (TUnion l) == union l) val union_get_key (#l: union_typ) (v: union l) : GTot (struct_field l) val union_get_value (#l: union_typ) (v: union l) (fd: struct_field l) : Pure (type_of_struct_field l fd) (requires (union_get_key v == fd)) (ensures (fun _ -> True)) val union_create (l: union_typ) (fd: struct_field l) (v: type_of_struct_field l fd) : Tot (union l) (*** Semantics of pointers *) (** Operations on pointers *) val equal (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Ghost bool (requires True) (ensures (fun b -> b == true <==> t1 == t2 /\ p1 == p2 )) val as_addr (#t: typ) (p: pointer t): GTot (x: nat { x > 0 } ) val unused_in (#value: typ) (p: pointer value) (h: HS.mem) : GTot Type0 val live (#value: typ) (h: HS.mem) (p: pointer value) : GTot Type0 val nlive (#value: typ) (h: HS.mem) (p: npointer value) : GTot Type0 val live_nlive (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (nlive h p <==> live h p) [SMTPat (nlive h p)] val g_is_null_nlive (#t: typ) (h: HS.mem) (p: npointer t) : Lemma (requires (g_is_null p)) (ensures (nlive h p)) [SMTPat (g_is_null p); SMTPat (nlive h p)] val live_not_unused_in (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (ensures (live h p /\ p `unused_in` h ==> False)) [SMTPat (live h p); SMTPat (p `unused_in` h)] val gread (#value: typ) (h: HS.mem) (p: pointer value) : GTot (type_of_typ value) val frameOf (#value: typ) (p: pointer value) : GTot HS.rid val live_region_frameOf (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (requires (live h p)) (ensures (HS.live_region h (frameOf p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf p))]; [SMTPat (live h p)] ]] val disjoint_roots_intro_pointer_vs_pointer (#value1 value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 =!= as_addr p2)) val disjoint_roots_intro_pointer_vs_reference (#value1: typ) (#value2: Type) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ p2 `HS.unused_in` h)) (ensures (frameOf p1 <> HS.frameOf p2 \/ as_addr p1 =!= HS.as_addr p2)) val disjoint_roots_intro_reference_vs_pointer (#value1: Type) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ p2 `unused_in` h)) (ensures (HS.frameOf p1 <> frameOf p2 \/ HS.as_addr p1 =!= as_addr p2)) val is_mm (#value: typ) (p: pointer value) : GTot bool (* // TODO: recover with addresses? val recall (#value: Type) (p: pointer value {is_eternal_region (frameOf p) && not (is_mm p)}) : HST.Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 p)) *) val gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gfield p fd) == as_addr p)) [SMTPat (as_addr (gfield p fd))] val unused_in_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gfield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gfield p fd) h)] val live_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gfield p fd) <==> live h p)) [SMTPat (live h (gfield p fd))] val gread_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (gread h (gfield p fd) == struct_sel (gread h p) fd)) [SMTPatOr [[SMTPat (gread h (gfield p fd))]; [SMTPat (struct_sel (gread h p) fd)]]] val frameOf_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gfield p fd) == frameOf p)) [SMTPat (frameOf (gfield p fd))] val is_mm_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gfield p fd) <==> is_mm p)) [SMTPat (is_mm (gfield p fd))] val gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gufield p fd) == as_addr p)) [SMTPat (as_addr (gufield p fd))] val unused_in_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gufield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gufield p fd) h)] val live_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gufield p fd) <==> live h p)) [SMTPat (live h (gufield p fd))] val gread_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (union_get_key (gread h p) == fd)) (ensures ( union_get_key (gread h p) == fd /\ gread h (gufield p fd) == union_get_value (gread h p) fd )) [SMTPatOr [[SMTPat (gread h (gufield p fd))]; [SMTPat (union_get_value (gread h p) fd)]]] val frameOf_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gufield p fd) == frameOf p)) [SMTPat (frameOf (gufield p fd))] val is_mm_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gufield p fd) <==> is_mm p)) [SMTPat (is_mm (gufield p fd))] val gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Ghost (pointer value) (requires (UInt32.v i < UInt32.v length)) (ensures (fun _ -> True)) val as_addr_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ as_addr (gcell p i) == as_addr p)) [SMTPat (as_addr (gcell p i))] val unused_in_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (unused_in (gcell p i) h <==> unused_in p h))) [SMTPat (unused_in (gcell p i) h)] val live_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (live h (gcell p i) <==> live h p))) [SMTPat (live h (gcell p i))] val gread_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gread h (gcell p i) == Seq.index (gread h p) (UInt32.v i))) [SMTPat (gread h (gcell p i))] val frameOf_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ frameOf (gcell p i) == frameOf p)) [SMTPat (frameOf (gcell p i))] val is_mm_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ is_mm (gcell p i) == is_mm p)) [SMTPat (is_mm (gcell p i))] val includes (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : GTot bool val includes_refl (#t: typ) (p: pointer t) : Lemma (ensures (includes p p)) [SMTPat (includes p p)] val includes_trans (#t1 #t2 #t3: typ) (p1: pointer t1) (p2: pointer t2) (p3: pointer t3) : Lemma (requires (includes p1 p2 /\ includes p2 p3)) (ensures (includes p1 p3)) val includes_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gfield p fd))) val includes_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gufield p fd))) val includes_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ includes p (gcell p i))) (** The readable permission. We choose to implement it only abstractly, instead of explicitly tracking the permission in the heap. *) val readable (#a: typ) (h: HS.mem) (b: pointer a) : GTot Type0 val readable_live (#a: typ) (h: HS.mem) (b: pointer a) : Lemma (requires (readable h b)) (ensures (live h b)) [SMTPatOr [ [SMTPat (readable h b)]; [SMTPat (live h b)]; ]] val readable_gfield (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires (readable h p)) (ensures (readable h (gfield p fd))) [SMTPat (readable h (gfield p fd))] val readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires ( forall (f: struct_field l) . readable h (gfield p f) )) (ensures (readable h p)) // [SMTPat (readable #(TStruct l) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints val readable_struct_forall_mem (#l: struct_typ) (p: pointer (TStruct l)) : Lemma (forall (h: HS.mem) . ( forall (f: struct_field l) . readable h (gfield p f) ) ==> readable h p ) val readable_struct_fields (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (s: list string) : GTot Type0 val readable_struct_fields_nil (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (readable_struct_fields h p []) [SMTPat (readable_struct_fields h p [])] val readable_struct_fields_cons (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (f: string) (q: list string) : Lemma (requires (readable_struct_fields h p q /\ (List.Tot.mem f (List.Tot.map fst l.fields) ==> (let f : struct_field l = f in readable h (gfield p f))))) (ensures (readable_struct_fields h p (f::q))) [SMTPat (readable_struct_fields h p (f::q))] val readable_struct_fields_readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires (readable_struct_fields h p (normalize_term (List.Tot.map fst l.fields)))) (ensures (readable h p)) val readable_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length /\ readable h p)) (ensures (UInt32.v i < UInt32.v length /\ readable h (gcell p i))) [SMTPat (readable h (gcell p i))] val readable_array (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) : Lemma (requires ( forall (i: UInt32.t) . UInt32.v i < UInt32.v length ==> readable h (gcell p i) )) (ensures (readable h p)) // [SMTPat (readable #(TArray length value) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints (* TODO: improve on the following interface *) val readable_gufield (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (readable h (gufield p fd) <==> (readable h p /\ union_get_key (gread h p) == fd))) [SMTPat (readable h (gufield p fd))] (** The active field of a union *) val is_active_union_field (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : GTot Type0 val is_active_union_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h p)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h (gufield p fd))) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_eq (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd1 fd2: struct_field l) : Lemma (requires (is_active_union_field h p fd1 /\ is_active_union_field h p fd2)) (ensures (fd1 == fd2)) [SMTPat (is_active_union_field h p fd1); SMTPat (is_active_union_field h p fd2)] val is_active_union_field_get_key (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (union_get_key (gread h p) == fd)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd /\ readable h (gufield p fd))) (ensures (readable h p)) [SMTPat (is_active_union_field h p fd); SMTPat (readable h (gufield p fd))] val is_active_union_field_includes_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) (#t': typ) (p' : pointer t') : Lemma (requires (includes (gufield p fd) p' /\ readable h p')) (ensures (is_active_union_field h p fd)) (* Equality predicate on struct contents, without quantifiers *) let equal_values #a h (b:pointer a) h' (b':pointer a) : GTot Type0 = (live h b ==> live h' b') /\ ( readable h b ==> ( readable h' b' /\ gread h b == gread h' b' )) (*** Semantics of buffers *) (** Operations on buffers *) val gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : GTot (buffer t) val singleton_buffer_of_pointer (#t: typ) (p: pointer t) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gsingleton_buffer_of_pointer p)) val gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : GTot (buffer t) val buffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gbuffer_of_array_pointer p)) val buffer_length (#t: typ) (b: buffer t) : GTot UInt32.t val buffer_length_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (requires True) (ensures (buffer_length (gsingleton_buffer_of_pointer p) == 1ul)) [SMTPat (buffer_length (gsingleton_buffer_of_pointer p))] val buffer_length_gbuffer_of_array_pointer (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_length (gbuffer_of_array_pointer p) == len)) [SMTPat (buffer_length (gbuffer_of_array_pointer p))] val buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_live_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_live h (gsingleton_buffer_of_pointer p) <==> live h p )) [SMTPat (buffer_live h (gsingleton_buffer_of_pointer p))] val buffer_live_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_live h (gbuffer_of_array_pointer p) <==> live h p)) [SMTPat (buffer_live h (gbuffer_of_array_pointer p))] val buffer_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : GTot Type0 val buffer_live_not_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : Lemma ((buffer_live h b /\ buffer_unused_in b h) ==> False) val buffer_unused_in_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_unused_in (gsingleton_buffer_of_pointer p) h <==> unused_in p h )) [SMTPat (buffer_unused_in (gsingleton_buffer_of_pointer p) h)] val buffer_unused_in_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_unused_in (gbuffer_of_array_pointer p) h <==> unused_in p h)) [SMTPat (buffer_unused_in (gbuffer_of_array_pointer p) h)] val frameOf_buffer (#t: typ) (b: buffer t) : GTot HS.rid val frameOf_buffer_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (frameOf_buffer (gsingleton_buffer_of_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gsingleton_buffer_of_pointer p))] val frameOf_buffer_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (frameOf_buffer (gbuffer_of_array_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gbuffer_of_array_pointer p))] val live_region_frameOf_buffer (#value: typ) (h: HS.mem) (p: buffer value) : Lemma (requires (buffer_live h p)) (ensures (HS.live_region h (frameOf_buffer p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf_buffer p))]; [SMTPat (buffer_live h p)] ]] val buffer_as_addr (#t: typ) (b: buffer t) : GTot (x: nat { x > 0 } ) val buffer_as_addr_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (buffer_as_addr (gsingleton_buffer_of_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gsingleton_buffer_of_pointer p))] val buffer_as_addr_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (buffer_as_addr (gbuffer_of_array_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gbuffer_of_array_pointer p))] val gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Ghost (buffer t) (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val frameOf_buffer_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ frameOf_buffer (gsub_buffer b i len) == frameOf_buffer b )) [SMTPat (frameOf_buffer (gsub_buffer b i len))] val buffer_as_addr_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_addr (gsub_buffer b i len) == buffer_as_addr b )) [SMTPat (buffer_as_addr (gsub_buffer b i len))] val sub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i len )) val offset_buffer (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i (UInt32.sub (buffer_length b) i))) val buffer_length_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_length (gsub_buffer b i len) == len)) [SMTPat (buffer_length (gsub_buffer b i len))] val buffer_live_gsub_buffer_equiv (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_live h (gsub_buffer b i len) <==> buffer_live h b))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_live_gsub_buffer_intro (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (buffer_live h b /\ UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b i len))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_unused_in_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_unused_in (gsub_buffer b i len) h <==> buffer_unused_in b h))) [SMTPat (buffer_unused_in (gsub_buffer b i len) h)] val gsub_buffer_gsub_buffer (#a: typ) (b: buffer a) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 )) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\ gsub_buffer (gsub_buffer b i1 len1) i2 len2 == gsub_buffer b FStar.UInt32.(i1 +^ i2) len2 )) [SMTPat (gsub_buffer (gsub_buffer b i1 len1) i2 len2)] val gsub_buffer_zero_buffer_length (#a: typ) (b: buffer a) : Lemma (ensures (gsub_buffer b 0ul (buffer_length b) == b)) [SMTPat (gsub_buffer b 0ul (buffer_length b))] val buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : GTot (Seq.seq (type_of_typ t)) val buffer_length_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires True) (ensures (Seq.length (buffer_as_seq h b) == UInt32.v (buffer_length b))) [SMTPat (Seq.length (buffer_as_seq h b))] val buffer_as_seq_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (requires True) (ensures (buffer_as_seq h (gsingleton_buffer_of_pointer p) == Seq.create 1 (gread h p))) [SMTPat (buffer_as_seq h (gsingleton_buffer_of_pointer p))] val buffer_as_seq_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray length t)) : Lemma (requires True) (ensures (buffer_as_seq h (gbuffer_of_array_pointer p) == gread h p)) [SMTPat (buffer_as_seq h (gbuffer_of_array_pointer p))] val buffer_as_seq_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_seq h (gsub_buffer b i len) == Seq.slice (buffer_as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))) [SMTPat (buffer_as_seq h (gsub_buffer b i len))] val gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Ghost (pointer t) (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val pointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (pointer t) (requires (fun h -> UInt32.v i < UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h p h' -> UInt32.v i < UInt32.v (buffer_length b) /\ h' == h /\ p == gpointer_of_buffer_cell b i)) val gpointer_of_buffer_cell_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) let gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)] = gpointer_of_buffer_cell_gsub_buffer b i1 len i2 val live_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) (h: HS.mem) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ (live h (gpointer_of_buffer_cell b i) <==> buffer_live h b) )) [SMTPat (live h (gpointer_of_buffer_cell b i))] val gpointer_of_buffer_cell_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < 1)) (ensures (UInt32.v i < 1 /\ gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i == p)) [SMTPat (gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i)] val gpointer_of_buffer_cell_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (p: pointer (TArray length t)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i == gcell p i)) [SMTPat (gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i)] val frameOf_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ frameOf (gpointer_of_buffer_cell b i) == frameOf_buffer b)) [SMTPat (frameOf (gpointer_of_buffer_cell b i))] val as_addr_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ as_addr (gpointer_of_buffer_cell b i) == buffer_as_addr b)) [SMTPat (as_addr (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) [SMTPat (gread h (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell' (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) val index_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) (i: nat) : Lemma (requires (i < UInt32.v (buffer_length b))) (ensures (i < UInt32.v (buffer_length b) /\ Seq.index (buffer_as_seq h b) i == gread h (gpointer_of_buffer_cell b (UInt32.uint_to_t i)))) [SMTPat (Seq.index (buffer_as_seq h b) i)] val gsingleton_buffer_of_pointer_gcell (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v len )) (ensures ( UInt32.v i < UInt32.v len /\ gsingleton_buffer_of_pointer (gcell p i) == gsub_buffer (gbuffer_of_array_pointer p) i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gcell p i))] val gsingleton_buffer_of_pointer_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i) == gsub_buffer b i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i))] (* The readable permission lifted to buffers. *) val buffer_readable (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_readable_buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires (buffer_readable h b)) (ensures (buffer_live h b)) [SMTPatOr [ [SMTPat (buffer_readable h b)]; [SMTPat (buffer_live h b)]; ]] val buffer_readable_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (ensures (buffer_readable h (gsingleton_buffer_of_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gsingleton_buffer_of_pointer p))] val buffer_readable_gbuffer_of_array_pointer (#len: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_readable h (gbuffer_of_array_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gbuffer_of_array_pointer p))] val buffer_readable_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h (gsub_buffer b i len))) [SMTPat (buffer_readable h (gsub_buffer b i len))] val readable_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ readable h (gpointer_of_buffer_cell b i))) [SMTPat (readable h (gpointer_of_buffer_cell b i))] val buffer_readable_intro (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (ensures (buffer_readable h b)) // [SMTPat (buffer_readable h b)] // TODO: dubious pattern, may trigger unreplayable hints val buffer_readable_elim (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_readable h b )) (ensures ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (*** The modifies clause *) val loc : Type u#0 val loc_none: loc val loc_union (s1 s2: loc) : GTot loc (** The following is useful to make Z3 cut matching loops with modifies_trans and modifies_refl *) val loc_union_idem (s: loc) : Lemma (loc_union s s == s) [SMTPat (loc_union s s)] val loc_pointer (#t: typ) (p: pointer t) : GTot loc val loc_buffer (#t: typ) (b: buffer t) : GTot loc val loc_addresses (r: HS.rid) (n: Set.set nat) : GTot loc val loc_regions (r: Set.set HS.rid) : GTot loc (* Inclusion of memory locations *) val loc_includes (s1 s2: loc) : GTot Type0 val loc_includes_refl (s: loc) : Lemma (loc_includes s s) [SMTPat (loc_includes s s)] val loc_includes_trans (s1 s2 s3: loc) : Lemma (requires (loc_includes s1 s2 /\ loc_includes s2 s3)) (ensures (loc_includes s1 s3)) val loc_includes_union_r (s s1 s2: loc) : Lemma (requires (loc_includes s s1 /\ loc_includes s s2)) (ensures (loc_includes s (loc_union s1 s2))) [SMTPat (loc_includes s (loc_union s1 s2))] val loc_includes_union_l (s1 s2 s: loc) : Lemma (requires (loc_includes s1 s \/ loc_includes s2 s)) (ensures (loc_includes (loc_union s1 s2) s)) [SMTPat (loc_includes (loc_union s1 s2) s)] val loc_includes_none (s: loc) : Lemma (loc_includes s loc_none) [SMTPat (loc_includes s loc_none)] val loc_includes_pointer_pointer (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Lemma (requires (includes p1 p2)) (ensures (loc_includes (loc_pointer p1) (loc_pointer p2))) [SMTPat (loc_includes (loc_pointer p1) (loc_pointer p2))] val loc_includes_gsingleton_buffer_of_pointer (l: loc) (#t: typ) (p: pointer t) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))] val loc_includes_gbuffer_of_array_pointer (l: loc) (#len: array_length_t) (#t: typ) (p: pointer (TArray len t)) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))] val loc_includes_gpointer_of_array_cell (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))] val loc_includes_gsub_buffer_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer (gsub_buffer b i len)))) [SMTPat (loc_includes l (loc_buffer (gsub_buffer b i len)))] val loc_includes_gsub_buffer_l (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1)) (ensures (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1 /\ loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))) [SMTPat (loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_includes_addresses_pointer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: pointer t) : Lemma (requires (frameOf p == r /\ Set.mem (as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_pointer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_pointer p))] val loc_includes_addresses_buffer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: buffer t) : Lemma (requires (frameOf_buffer p == r /\ Set.mem (buffer_as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_buffer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_buffer p))] val loc_includes_region_pointer (#t: typ) (s: Set.set HS.rid) (p: pointer t) : Lemma (requires (Set.mem (frameOf p) s)) (ensures (loc_includes (loc_regions s) (loc_pointer p))) [SMTPat (loc_includes (loc_regions s) (loc_pointer p))] val loc_includes_region_buffer (#t: typ) (s: Set.set HS.rid) (b: buffer t) : Lemma (requires (Set.mem (frameOf_buffer b) s)) (ensures (loc_includes (loc_regions s) (loc_buffer b))) [SMTPat (loc_includes (loc_regions s) (loc_buffer b))] val loc_includes_region_addresses (s: Set.set HS.rid) (r: HS.rid) (a: Set.set nat) : Lemma (requires (Set.mem r s)) (ensures (loc_includes (loc_regions s) (loc_addresses r a))) [SMTPat (loc_includes (loc_regions s) (loc_addresses r a))] val loc_includes_region_region (s1 s2: Set.set HS.rid) : Lemma (requires (Set.subset s2 s1)) (ensures (loc_includes (loc_regions s1) (loc_regions s2))) [SMTPat (loc_includes (loc_regions s1) (loc_regions s2))] val loc_includes_region_union_l (l: loc) (s1 s2: Set.set HS.rid) : Lemma (requires (loc_includes l (loc_regions (Set.intersect s2 (Set.complement s1))))) (ensures (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))) [SMTPat (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))] (* Disjointness of two memory locations *) val loc_disjoint (s1 s2: loc) : GTot Type0 val loc_disjoint_sym (s1 s2: loc) : Lemma (requires (loc_disjoint s1 s2)) (ensures (loc_disjoint s2 s1)) [SMTPat (loc_disjoint s1 s2)] val loc_disjoint_none_r (s: loc) : Lemma (ensures (loc_disjoint s loc_none)) [SMTPat (loc_disjoint s loc_none)] val loc_disjoint_union_r (s s1 s2: loc) : Lemma (requires (loc_disjoint s s1 /\ loc_disjoint s s2)) (ensures (loc_disjoint s (loc_union s1 s2))) [SMTPat (loc_disjoint s (loc_union s1 s2))] val loc_disjoint_root (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) val loc_disjoint_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd1 fd2: struct_field l) : Lemma (requires (fd1 <> fd2)) (ensures (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))) [SMTPat (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))] val loc_disjoint_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ UInt32.v i1 <> UInt32.v i2 )) (ensures ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)) )) [SMTPat (loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)))] val loc_disjoint_includes (p1 p2 p1' p2' : loc) : Lemma (requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2)) (ensures (loc_disjoint p1' p2')) (* TODO: The following is now wrong, should be replaced with readable val live_not_equal_disjoint (#t: typ) (h: HS.mem) (p1 p2: pointer t) : Lemma (requires (live h p1 /\ live h p2 /\ equal p1 p2 == false)) (ensures (disjoint p1 p2)) *) val live_unused_in_disjoint_strong (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) val live_unused_in_disjoint (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) [SMTPatOr [ [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (live h p1)]; [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (unused_in p2 h)]; [SMTPat (live h p1); SMTPat (unused_in p2 h)]; ]] val pointer_live_reference_unused_in_disjoint (#value1: typ) (#value2: Type0) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ HS.unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_addresses (HS.frameOf p2) (Set.singleton (HS.as_addr p2))))) [SMTPat (live h p1); SMTPat (HS.unused_in p2 h)] val reference_live_pointer_unused_in_disjoint (#value1: Type0) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_addresses (HS.frameOf p1) (Set.singleton (HS.as_addr p1))) (loc_pointer p2))) [SMTPat (HS.contains h p1); SMTPat (unused_in p2 h)] val loc_disjoint_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ ( UInt32.v i1 + UInt32.v len1 <= UInt32.v i2 \/ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 ))) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)) )) [SMTPat (loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_disjoint_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ ( UInt32.v i1 <> UInt32.v i2 ))) (ensures ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)) )) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)))] let loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))] = loc_disjoint_includes l (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i)) let loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)] = loc_disjoint_includes (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i)) l val loc_disjoint_addresses (r1 r2: HS.rid) (n1 n2: Set.set nat) : Lemma (requires (r1 <> r2 \/ Set.subset (Set.intersect n1 n2) Set.empty)) (ensures (loc_disjoint (loc_addresses r1 n1) (loc_addresses r2 n2))) [SMTPat (loc_disjoint (loc_addresses r1 n1) (loc_addresses r2 n2))] val loc_disjoint_pointer_addresses (#t: typ) (p: pointer t) (r: HS.rid) (n: Set.set nat) : Lemma (requires (r <> frameOf p \/ (~ (Set.mem (as_addr p) n)))) (ensures (loc_disjoint (loc_pointer p) (loc_addresses r n))) [SMTPat (loc_disjoint (loc_pointer p) (loc_addresses r n))] val loc_disjoint_buffer_addresses (#t: typ) (p: buffer t) (r: HH.rid) (n: Set.set nat) : Lemma (requires (r <> frameOf_buffer p \/ (~ (Set.mem (buffer_as_addr p) n)))) (ensures (loc_disjoint (loc_buffer p) (loc_addresses r n))) [SMTPat (loc_disjoint (loc_buffer p) (loc_addresses r n))] val loc_disjoint_regions (rs1 rs2: Set.set HS.rid) : Lemma (requires (Set.subset (Set.intersect rs1 rs2) Set.empty)) (ensures (loc_disjoint (loc_regions rs1) (loc_regions rs2))) [SMTPat (loc_disjoint (loc_regions rs1) (loc_regions rs2))] (** The modifies clause proper *) val modifies (s: loc) (h1 h2: HS.mem) : GTot Type0 val modifies_loc_regions_intro (rs: Set.set HS.rid) (h1 h2: HS.mem) : Lemma (requires (HS.modifies rs h1 h2)) (ensures (modifies (loc_regions rs) h1 h2)) val modifies_pointer_elim (s: loc) (h1 h2: HS.mem) (#a': typ) (p': pointer a') : Lemma (requires ( modifies s h1 h2 /\ live h1 p' /\ loc_disjoint (loc_pointer p') s )) (ensures ( equal_values h1 p' h2 p' )) [SMTPatOr [ [ SMTPat (modifies s h1 h2); SMTPat (gread h1 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (readable h1 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (live h1 p') ]; [ SMTPat (modifies s h1 h2); SMTPat (gread h2 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (readable h2 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (live h2 p') ] ] ] val modifies_buffer_elim (#t1: typ) (b: buffer t1) (p: loc) (h h': HS.mem) : Lemma (requires ( loc_disjoint (loc_buffer b) p /\ buffer_live h b /\ (UInt32.v (buffer_length b) == 0 ==> buffer_live h' b) /\ // necessary for liveness, because all buffers of size 0 are disjoint for any memory location, so we cannot talk about their liveness individually without referring to a larger nonempty buffer modifies p h h' )) (ensures ( buffer_live h' b /\ ( buffer_readable h b ==> ( buffer_readable h' b /\ buffer_as_seq h b == buffer_as_seq h' b )))) [SMTPatOr [ [ SMTPat (modifies p h h'); SMTPat (buffer_as_seq h b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_readable h b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_live h b) ]; [ SMTPat (modifies p h h'); SMTPat (buffer_as_seq h' b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_readable h' b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_live h' b) ] ] ] val modifies_reference_elim (#t: Type0) (b: HS.reference t) (p: loc) (h h': HS.mem) : Lemma (requires ( loc_disjoint (loc_addresses (HS.frameOf b) (Set.singleton (HS.as_addr b))) p /\ HS.contains h b /\ modifies p h h' )) (ensures ( HS.contains h' b /\ HS.sel h b == HS.sel h' b )) [SMTPatOr [ [ SMTPat (modifies p h h'); SMTPat (HS.sel h b) ] ; [ SMTPat (modifies p h h'); SMTPat (HS.contains h b) ]; [ SMTPat (modifies p h h'); SMTPat (HS.sel h' b) ] ; [ SMTPat (modifies p h h'); SMTPat (HS.contains h' b) ] ] ] val modifies_refl (s: loc) (h: HS.mem) : Lemma (modifies s h h) [SMTPat (modifies s h h)] val modifies_loc_includes (s1: loc) (h h': HS.mem) (s2: loc) : Lemma (requires (modifies s2 h h' /\ loc_includes s1 s2)) (ensures (modifies s1 h h')) [SMTPat (modifies s1 h h'); SMTPat (modifies s2 h h')] val modifies_trans (s12: loc) (h1 h2: HS.mem) (s23: loc) (h3: HS.mem) : Lemma (requires (modifies s12 h1 h2 /\ modifies s23 h2 h3)) (ensures (modifies (loc_union s12 s23) h1 h3)) [SMTPat (modifies s12 h1 h2); SMTPat (modifies s23 h2 h3)]
false
false
FStar.Pointer.Base.fsti
{ "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 modifies_0 (h0 h1: HS.mem) : GTot Type0
[]
FStar.Pointer.Base.modifies_0
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
{ "end_col": 25, "end_line": 2066, "start_col": 2, "start_line": 2066 }
Prims.GTot
val modifies_1 (#t: typ) (p: pointer t) (h0 h1: HS.mem) : GTot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 modifies_1 (#t: typ) (p: pointer t) (h0 h1: HS.mem) : GTot Type0 = modifies (loc_pointer p) h0 h1
val modifies_1 (#t: typ) (p: pointer t) (h0 h1: HS.mem) : GTot Type0 let modifies_1 (#t: typ) (p: pointer t) (h0 h1: HS.mem) : GTot Type0 =
false
null
false
modifies (loc_pointer p) h0 h1
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "sometrivial" ]
[ "FStar.Pointer.Base.typ", "FStar.Pointer.Base.pointer", "FStar.Monotonic.HyperStack.mem", "FStar.Pointer.Base.modifies", "FStar.Pointer.Base.loc_pointer" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim () val struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) : Tot (struct l) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = struct_create_fun s (fun_of_list s l) val struct_sel_struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) (fd: struct_field l) : Lemma (struct_sel (struct_create_fun l f) fd == f fd) [SMTPat (struct_sel (struct_create_fun l f) fd)] let type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] = assert_norm (type_of_typ (TUnion l) == union l) val union_get_key (#l: union_typ) (v: union l) : GTot (struct_field l) val union_get_value (#l: union_typ) (v: union l) (fd: struct_field l) : Pure (type_of_struct_field l fd) (requires (union_get_key v == fd)) (ensures (fun _ -> True)) val union_create (l: union_typ) (fd: struct_field l) (v: type_of_struct_field l fd) : Tot (union l) (*** Semantics of pointers *) (** Operations on pointers *) val equal (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Ghost bool (requires True) (ensures (fun b -> b == true <==> t1 == t2 /\ p1 == p2 )) val as_addr (#t: typ) (p: pointer t): GTot (x: nat { x > 0 } ) val unused_in (#value: typ) (p: pointer value) (h: HS.mem) : GTot Type0 val live (#value: typ) (h: HS.mem) (p: pointer value) : GTot Type0 val nlive (#value: typ) (h: HS.mem) (p: npointer value) : GTot Type0 val live_nlive (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (nlive h p <==> live h p) [SMTPat (nlive h p)] val g_is_null_nlive (#t: typ) (h: HS.mem) (p: npointer t) : Lemma (requires (g_is_null p)) (ensures (nlive h p)) [SMTPat (g_is_null p); SMTPat (nlive h p)] val live_not_unused_in (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (ensures (live h p /\ p `unused_in` h ==> False)) [SMTPat (live h p); SMTPat (p `unused_in` h)] val gread (#value: typ) (h: HS.mem) (p: pointer value) : GTot (type_of_typ value) val frameOf (#value: typ) (p: pointer value) : GTot HS.rid val live_region_frameOf (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (requires (live h p)) (ensures (HS.live_region h (frameOf p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf p))]; [SMTPat (live h p)] ]] val disjoint_roots_intro_pointer_vs_pointer (#value1 value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 =!= as_addr p2)) val disjoint_roots_intro_pointer_vs_reference (#value1: typ) (#value2: Type) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ p2 `HS.unused_in` h)) (ensures (frameOf p1 <> HS.frameOf p2 \/ as_addr p1 =!= HS.as_addr p2)) val disjoint_roots_intro_reference_vs_pointer (#value1: Type) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ p2 `unused_in` h)) (ensures (HS.frameOf p1 <> frameOf p2 \/ HS.as_addr p1 =!= as_addr p2)) val is_mm (#value: typ) (p: pointer value) : GTot bool (* // TODO: recover with addresses? val recall (#value: Type) (p: pointer value {is_eternal_region (frameOf p) && not (is_mm p)}) : HST.Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 p)) *) val gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gfield p fd) == as_addr p)) [SMTPat (as_addr (gfield p fd))] val unused_in_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gfield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gfield p fd) h)] val live_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gfield p fd) <==> live h p)) [SMTPat (live h (gfield p fd))] val gread_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (gread h (gfield p fd) == struct_sel (gread h p) fd)) [SMTPatOr [[SMTPat (gread h (gfield p fd))]; [SMTPat (struct_sel (gread h p) fd)]]] val frameOf_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gfield p fd) == frameOf p)) [SMTPat (frameOf (gfield p fd))] val is_mm_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gfield p fd) <==> is_mm p)) [SMTPat (is_mm (gfield p fd))] val gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gufield p fd) == as_addr p)) [SMTPat (as_addr (gufield p fd))] val unused_in_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gufield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gufield p fd) h)] val live_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gufield p fd) <==> live h p)) [SMTPat (live h (gufield p fd))] val gread_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (union_get_key (gread h p) == fd)) (ensures ( union_get_key (gread h p) == fd /\ gread h (gufield p fd) == union_get_value (gread h p) fd )) [SMTPatOr [[SMTPat (gread h (gufield p fd))]; [SMTPat (union_get_value (gread h p) fd)]]] val frameOf_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gufield p fd) == frameOf p)) [SMTPat (frameOf (gufield p fd))] val is_mm_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gufield p fd) <==> is_mm p)) [SMTPat (is_mm (gufield p fd))] val gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Ghost (pointer value) (requires (UInt32.v i < UInt32.v length)) (ensures (fun _ -> True)) val as_addr_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ as_addr (gcell p i) == as_addr p)) [SMTPat (as_addr (gcell p i))] val unused_in_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (unused_in (gcell p i) h <==> unused_in p h))) [SMTPat (unused_in (gcell p i) h)] val live_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (live h (gcell p i) <==> live h p))) [SMTPat (live h (gcell p i))] val gread_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gread h (gcell p i) == Seq.index (gread h p) (UInt32.v i))) [SMTPat (gread h (gcell p i))] val frameOf_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ frameOf (gcell p i) == frameOf p)) [SMTPat (frameOf (gcell p i))] val is_mm_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ is_mm (gcell p i) == is_mm p)) [SMTPat (is_mm (gcell p i))] val includes (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : GTot bool val includes_refl (#t: typ) (p: pointer t) : Lemma (ensures (includes p p)) [SMTPat (includes p p)] val includes_trans (#t1 #t2 #t3: typ) (p1: pointer t1) (p2: pointer t2) (p3: pointer t3) : Lemma (requires (includes p1 p2 /\ includes p2 p3)) (ensures (includes p1 p3)) val includes_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gfield p fd))) val includes_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gufield p fd))) val includes_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ includes p (gcell p i))) (** The readable permission. We choose to implement it only abstractly, instead of explicitly tracking the permission in the heap. *) val readable (#a: typ) (h: HS.mem) (b: pointer a) : GTot Type0 val readable_live (#a: typ) (h: HS.mem) (b: pointer a) : Lemma (requires (readable h b)) (ensures (live h b)) [SMTPatOr [ [SMTPat (readable h b)]; [SMTPat (live h b)]; ]] val readable_gfield (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires (readable h p)) (ensures (readable h (gfield p fd))) [SMTPat (readable h (gfield p fd))] val readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires ( forall (f: struct_field l) . readable h (gfield p f) )) (ensures (readable h p)) // [SMTPat (readable #(TStruct l) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints val readable_struct_forall_mem (#l: struct_typ) (p: pointer (TStruct l)) : Lemma (forall (h: HS.mem) . ( forall (f: struct_field l) . readable h (gfield p f) ) ==> readable h p ) val readable_struct_fields (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (s: list string) : GTot Type0 val readable_struct_fields_nil (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (readable_struct_fields h p []) [SMTPat (readable_struct_fields h p [])] val readable_struct_fields_cons (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (f: string) (q: list string) : Lemma (requires (readable_struct_fields h p q /\ (List.Tot.mem f (List.Tot.map fst l.fields) ==> (let f : struct_field l = f in readable h (gfield p f))))) (ensures (readable_struct_fields h p (f::q))) [SMTPat (readable_struct_fields h p (f::q))] val readable_struct_fields_readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires (readable_struct_fields h p (normalize_term (List.Tot.map fst l.fields)))) (ensures (readable h p)) val readable_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length /\ readable h p)) (ensures (UInt32.v i < UInt32.v length /\ readable h (gcell p i))) [SMTPat (readable h (gcell p i))] val readable_array (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) : Lemma (requires ( forall (i: UInt32.t) . UInt32.v i < UInt32.v length ==> readable h (gcell p i) )) (ensures (readable h p)) // [SMTPat (readable #(TArray length value) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints (* TODO: improve on the following interface *) val readable_gufield (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (readable h (gufield p fd) <==> (readable h p /\ union_get_key (gread h p) == fd))) [SMTPat (readable h (gufield p fd))] (** The active field of a union *) val is_active_union_field (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : GTot Type0 val is_active_union_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h p)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h (gufield p fd))) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_eq (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd1 fd2: struct_field l) : Lemma (requires (is_active_union_field h p fd1 /\ is_active_union_field h p fd2)) (ensures (fd1 == fd2)) [SMTPat (is_active_union_field h p fd1); SMTPat (is_active_union_field h p fd2)] val is_active_union_field_get_key (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (union_get_key (gread h p) == fd)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd /\ readable h (gufield p fd))) (ensures (readable h p)) [SMTPat (is_active_union_field h p fd); SMTPat (readable h (gufield p fd))] val is_active_union_field_includes_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) (#t': typ) (p' : pointer t') : Lemma (requires (includes (gufield p fd) p' /\ readable h p')) (ensures (is_active_union_field h p fd)) (* Equality predicate on struct contents, without quantifiers *) let equal_values #a h (b:pointer a) h' (b':pointer a) : GTot Type0 = (live h b ==> live h' b') /\ ( readable h b ==> ( readable h' b' /\ gread h b == gread h' b' )) (*** Semantics of buffers *) (** Operations on buffers *) val gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : GTot (buffer t) val singleton_buffer_of_pointer (#t: typ) (p: pointer t) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gsingleton_buffer_of_pointer p)) val gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : GTot (buffer t) val buffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gbuffer_of_array_pointer p)) val buffer_length (#t: typ) (b: buffer t) : GTot UInt32.t val buffer_length_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (requires True) (ensures (buffer_length (gsingleton_buffer_of_pointer p) == 1ul)) [SMTPat (buffer_length (gsingleton_buffer_of_pointer p))] val buffer_length_gbuffer_of_array_pointer (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_length (gbuffer_of_array_pointer p) == len)) [SMTPat (buffer_length (gbuffer_of_array_pointer p))] val buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_live_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_live h (gsingleton_buffer_of_pointer p) <==> live h p )) [SMTPat (buffer_live h (gsingleton_buffer_of_pointer p))] val buffer_live_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_live h (gbuffer_of_array_pointer p) <==> live h p)) [SMTPat (buffer_live h (gbuffer_of_array_pointer p))] val buffer_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : GTot Type0 val buffer_live_not_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : Lemma ((buffer_live h b /\ buffer_unused_in b h) ==> False) val buffer_unused_in_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_unused_in (gsingleton_buffer_of_pointer p) h <==> unused_in p h )) [SMTPat (buffer_unused_in (gsingleton_buffer_of_pointer p) h)] val buffer_unused_in_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_unused_in (gbuffer_of_array_pointer p) h <==> unused_in p h)) [SMTPat (buffer_unused_in (gbuffer_of_array_pointer p) h)] val frameOf_buffer (#t: typ) (b: buffer t) : GTot HS.rid val frameOf_buffer_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (frameOf_buffer (gsingleton_buffer_of_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gsingleton_buffer_of_pointer p))] val frameOf_buffer_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (frameOf_buffer (gbuffer_of_array_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gbuffer_of_array_pointer p))] val live_region_frameOf_buffer (#value: typ) (h: HS.mem) (p: buffer value) : Lemma (requires (buffer_live h p)) (ensures (HS.live_region h (frameOf_buffer p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf_buffer p))]; [SMTPat (buffer_live h p)] ]] val buffer_as_addr (#t: typ) (b: buffer t) : GTot (x: nat { x > 0 } ) val buffer_as_addr_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (buffer_as_addr (gsingleton_buffer_of_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gsingleton_buffer_of_pointer p))] val buffer_as_addr_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (buffer_as_addr (gbuffer_of_array_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gbuffer_of_array_pointer p))] val gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Ghost (buffer t) (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val frameOf_buffer_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ frameOf_buffer (gsub_buffer b i len) == frameOf_buffer b )) [SMTPat (frameOf_buffer (gsub_buffer b i len))] val buffer_as_addr_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_addr (gsub_buffer b i len) == buffer_as_addr b )) [SMTPat (buffer_as_addr (gsub_buffer b i len))] val sub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i len )) val offset_buffer (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i (UInt32.sub (buffer_length b) i))) val buffer_length_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_length (gsub_buffer b i len) == len)) [SMTPat (buffer_length (gsub_buffer b i len))] val buffer_live_gsub_buffer_equiv (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_live h (gsub_buffer b i len) <==> buffer_live h b))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_live_gsub_buffer_intro (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (buffer_live h b /\ UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b i len))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_unused_in_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_unused_in (gsub_buffer b i len) h <==> buffer_unused_in b h))) [SMTPat (buffer_unused_in (gsub_buffer b i len) h)] val gsub_buffer_gsub_buffer (#a: typ) (b: buffer a) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 )) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\ gsub_buffer (gsub_buffer b i1 len1) i2 len2 == gsub_buffer b FStar.UInt32.(i1 +^ i2) len2 )) [SMTPat (gsub_buffer (gsub_buffer b i1 len1) i2 len2)] val gsub_buffer_zero_buffer_length (#a: typ) (b: buffer a) : Lemma (ensures (gsub_buffer b 0ul (buffer_length b) == b)) [SMTPat (gsub_buffer b 0ul (buffer_length b))] val buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : GTot (Seq.seq (type_of_typ t)) val buffer_length_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires True) (ensures (Seq.length (buffer_as_seq h b) == UInt32.v (buffer_length b))) [SMTPat (Seq.length (buffer_as_seq h b))] val buffer_as_seq_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (requires True) (ensures (buffer_as_seq h (gsingleton_buffer_of_pointer p) == Seq.create 1 (gread h p))) [SMTPat (buffer_as_seq h (gsingleton_buffer_of_pointer p))] val buffer_as_seq_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray length t)) : Lemma (requires True) (ensures (buffer_as_seq h (gbuffer_of_array_pointer p) == gread h p)) [SMTPat (buffer_as_seq h (gbuffer_of_array_pointer p))] val buffer_as_seq_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_seq h (gsub_buffer b i len) == Seq.slice (buffer_as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))) [SMTPat (buffer_as_seq h (gsub_buffer b i len))] val gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Ghost (pointer t) (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val pointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (pointer t) (requires (fun h -> UInt32.v i < UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h p h' -> UInt32.v i < UInt32.v (buffer_length b) /\ h' == h /\ p == gpointer_of_buffer_cell b i)) val gpointer_of_buffer_cell_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) let gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)] = gpointer_of_buffer_cell_gsub_buffer b i1 len i2 val live_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) (h: HS.mem) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ (live h (gpointer_of_buffer_cell b i) <==> buffer_live h b) )) [SMTPat (live h (gpointer_of_buffer_cell b i))] val gpointer_of_buffer_cell_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < 1)) (ensures (UInt32.v i < 1 /\ gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i == p)) [SMTPat (gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i)] val gpointer_of_buffer_cell_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (p: pointer (TArray length t)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i == gcell p i)) [SMTPat (gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i)] val frameOf_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ frameOf (gpointer_of_buffer_cell b i) == frameOf_buffer b)) [SMTPat (frameOf (gpointer_of_buffer_cell b i))] val as_addr_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ as_addr (gpointer_of_buffer_cell b i) == buffer_as_addr b)) [SMTPat (as_addr (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) [SMTPat (gread h (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell' (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) val index_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) (i: nat) : Lemma (requires (i < UInt32.v (buffer_length b))) (ensures (i < UInt32.v (buffer_length b) /\ Seq.index (buffer_as_seq h b) i == gread h (gpointer_of_buffer_cell b (UInt32.uint_to_t i)))) [SMTPat (Seq.index (buffer_as_seq h b) i)] val gsingleton_buffer_of_pointer_gcell (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v len )) (ensures ( UInt32.v i < UInt32.v len /\ gsingleton_buffer_of_pointer (gcell p i) == gsub_buffer (gbuffer_of_array_pointer p) i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gcell p i))] val gsingleton_buffer_of_pointer_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i) == gsub_buffer b i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i))] (* The readable permission lifted to buffers. *) val buffer_readable (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_readable_buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires (buffer_readable h b)) (ensures (buffer_live h b)) [SMTPatOr [ [SMTPat (buffer_readable h b)]; [SMTPat (buffer_live h b)]; ]] val buffer_readable_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (ensures (buffer_readable h (gsingleton_buffer_of_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gsingleton_buffer_of_pointer p))] val buffer_readable_gbuffer_of_array_pointer (#len: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_readable h (gbuffer_of_array_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gbuffer_of_array_pointer p))] val buffer_readable_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h (gsub_buffer b i len))) [SMTPat (buffer_readable h (gsub_buffer b i len))] val readable_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ readable h (gpointer_of_buffer_cell b i))) [SMTPat (readable h (gpointer_of_buffer_cell b i))] val buffer_readable_intro (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (ensures (buffer_readable h b)) // [SMTPat (buffer_readable h b)] // TODO: dubious pattern, may trigger unreplayable hints val buffer_readable_elim (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_readable h b )) (ensures ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (*** The modifies clause *) val loc : Type u#0 val loc_none: loc val loc_union (s1 s2: loc) : GTot loc (** The following is useful to make Z3 cut matching loops with modifies_trans and modifies_refl *) val loc_union_idem (s: loc) : Lemma (loc_union s s == s) [SMTPat (loc_union s s)] val loc_pointer (#t: typ) (p: pointer t) : GTot loc val loc_buffer (#t: typ) (b: buffer t) : GTot loc val loc_addresses (r: HS.rid) (n: Set.set nat) : GTot loc val loc_regions (r: Set.set HS.rid) : GTot loc (* Inclusion of memory locations *) val loc_includes (s1 s2: loc) : GTot Type0 val loc_includes_refl (s: loc) : Lemma (loc_includes s s) [SMTPat (loc_includes s s)] val loc_includes_trans (s1 s2 s3: loc) : Lemma (requires (loc_includes s1 s2 /\ loc_includes s2 s3)) (ensures (loc_includes s1 s3)) val loc_includes_union_r (s s1 s2: loc) : Lemma (requires (loc_includes s s1 /\ loc_includes s s2)) (ensures (loc_includes s (loc_union s1 s2))) [SMTPat (loc_includes s (loc_union s1 s2))] val loc_includes_union_l (s1 s2 s: loc) : Lemma (requires (loc_includes s1 s \/ loc_includes s2 s)) (ensures (loc_includes (loc_union s1 s2) s)) [SMTPat (loc_includes (loc_union s1 s2) s)] val loc_includes_none (s: loc) : Lemma (loc_includes s loc_none) [SMTPat (loc_includes s loc_none)] val loc_includes_pointer_pointer (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Lemma (requires (includes p1 p2)) (ensures (loc_includes (loc_pointer p1) (loc_pointer p2))) [SMTPat (loc_includes (loc_pointer p1) (loc_pointer p2))] val loc_includes_gsingleton_buffer_of_pointer (l: loc) (#t: typ) (p: pointer t) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))] val loc_includes_gbuffer_of_array_pointer (l: loc) (#len: array_length_t) (#t: typ) (p: pointer (TArray len t)) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))] val loc_includes_gpointer_of_array_cell (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))] val loc_includes_gsub_buffer_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer (gsub_buffer b i len)))) [SMTPat (loc_includes l (loc_buffer (gsub_buffer b i len)))] val loc_includes_gsub_buffer_l (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1)) (ensures (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1 /\ loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))) [SMTPat (loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_includes_addresses_pointer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: pointer t) : Lemma (requires (frameOf p == r /\ Set.mem (as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_pointer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_pointer p))] val loc_includes_addresses_buffer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: buffer t) : Lemma (requires (frameOf_buffer p == r /\ Set.mem (buffer_as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_buffer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_buffer p))] val loc_includes_region_pointer (#t: typ) (s: Set.set HS.rid) (p: pointer t) : Lemma (requires (Set.mem (frameOf p) s)) (ensures (loc_includes (loc_regions s) (loc_pointer p))) [SMTPat (loc_includes (loc_regions s) (loc_pointer p))] val loc_includes_region_buffer (#t: typ) (s: Set.set HS.rid) (b: buffer t) : Lemma (requires (Set.mem (frameOf_buffer b) s)) (ensures (loc_includes (loc_regions s) (loc_buffer b))) [SMTPat (loc_includes (loc_regions s) (loc_buffer b))] val loc_includes_region_addresses (s: Set.set HS.rid) (r: HS.rid) (a: Set.set nat) : Lemma (requires (Set.mem r s)) (ensures (loc_includes (loc_regions s) (loc_addresses r a))) [SMTPat (loc_includes (loc_regions s) (loc_addresses r a))] val loc_includes_region_region (s1 s2: Set.set HS.rid) : Lemma (requires (Set.subset s2 s1)) (ensures (loc_includes (loc_regions s1) (loc_regions s2))) [SMTPat (loc_includes (loc_regions s1) (loc_regions s2))] val loc_includes_region_union_l (l: loc) (s1 s2: Set.set HS.rid) : Lemma (requires (loc_includes l (loc_regions (Set.intersect s2 (Set.complement s1))))) (ensures (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))) [SMTPat (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))] (* Disjointness of two memory locations *) val loc_disjoint (s1 s2: loc) : GTot Type0 val loc_disjoint_sym (s1 s2: loc) : Lemma (requires (loc_disjoint s1 s2)) (ensures (loc_disjoint s2 s1)) [SMTPat (loc_disjoint s1 s2)] val loc_disjoint_none_r (s: loc) : Lemma (ensures (loc_disjoint s loc_none)) [SMTPat (loc_disjoint s loc_none)] val loc_disjoint_union_r (s s1 s2: loc) : Lemma (requires (loc_disjoint s s1 /\ loc_disjoint s s2)) (ensures (loc_disjoint s (loc_union s1 s2))) [SMTPat (loc_disjoint s (loc_union s1 s2))] val loc_disjoint_root (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) val loc_disjoint_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd1 fd2: struct_field l) : Lemma (requires (fd1 <> fd2)) (ensures (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))) [SMTPat (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))] val loc_disjoint_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ UInt32.v i1 <> UInt32.v i2 )) (ensures ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)) )) [SMTPat (loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)))] val loc_disjoint_includes (p1 p2 p1' p2' : loc) : Lemma (requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2)) (ensures (loc_disjoint p1' p2')) (* TODO: The following is now wrong, should be replaced with readable val live_not_equal_disjoint (#t: typ) (h: HS.mem) (p1 p2: pointer t) : Lemma (requires (live h p1 /\ live h p2 /\ equal p1 p2 == false)) (ensures (disjoint p1 p2)) *) val live_unused_in_disjoint_strong (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) val live_unused_in_disjoint (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) [SMTPatOr [ [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (live h p1)]; [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (unused_in p2 h)]; [SMTPat (live h p1); SMTPat (unused_in p2 h)]; ]] val pointer_live_reference_unused_in_disjoint (#value1: typ) (#value2: Type0) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ HS.unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_addresses (HS.frameOf p2) (Set.singleton (HS.as_addr p2))))) [SMTPat (live h p1); SMTPat (HS.unused_in p2 h)] val reference_live_pointer_unused_in_disjoint (#value1: Type0) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_addresses (HS.frameOf p1) (Set.singleton (HS.as_addr p1))) (loc_pointer p2))) [SMTPat (HS.contains h p1); SMTPat (unused_in p2 h)] val loc_disjoint_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ ( UInt32.v i1 + UInt32.v len1 <= UInt32.v i2 \/ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 ))) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)) )) [SMTPat (loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_disjoint_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ ( UInt32.v i1 <> UInt32.v i2 ))) (ensures ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)) )) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)))] let loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))] = loc_disjoint_includes l (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i)) let loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)] = loc_disjoint_includes (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i)) l val loc_disjoint_addresses (r1 r2: HS.rid) (n1 n2: Set.set nat) : Lemma (requires (r1 <> r2 \/ Set.subset (Set.intersect n1 n2) Set.empty)) (ensures (loc_disjoint (loc_addresses r1 n1) (loc_addresses r2 n2))) [SMTPat (loc_disjoint (loc_addresses r1 n1) (loc_addresses r2 n2))] val loc_disjoint_pointer_addresses (#t: typ) (p: pointer t) (r: HS.rid) (n: Set.set nat) : Lemma (requires (r <> frameOf p \/ (~ (Set.mem (as_addr p) n)))) (ensures (loc_disjoint (loc_pointer p) (loc_addresses r n))) [SMTPat (loc_disjoint (loc_pointer p) (loc_addresses r n))] val loc_disjoint_buffer_addresses (#t: typ) (p: buffer t) (r: HH.rid) (n: Set.set nat) : Lemma (requires (r <> frameOf_buffer p \/ (~ (Set.mem (buffer_as_addr p) n)))) (ensures (loc_disjoint (loc_buffer p) (loc_addresses r n))) [SMTPat (loc_disjoint (loc_buffer p) (loc_addresses r n))] val loc_disjoint_regions (rs1 rs2: Set.set HS.rid) : Lemma (requires (Set.subset (Set.intersect rs1 rs2) Set.empty)) (ensures (loc_disjoint (loc_regions rs1) (loc_regions rs2))) [SMTPat (loc_disjoint (loc_regions rs1) (loc_regions rs2))] (** The modifies clause proper *) val modifies (s: loc) (h1 h2: HS.mem) : GTot Type0 val modifies_loc_regions_intro (rs: Set.set HS.rid) (h1 h2: HS.mem) : Lemma (requires (HS.modifies rs h1 h2)) (ensures (modifies (loc_regions rs) h1 h2)) val modifies_pointer_elim (s: loc) (h1 h2: HS.mem) (#a': typ) (p': pointer a') : Lemma (requires ( modifies s h1 h2 /\ live h1 p' /\ loc_disjoint (loc_pointer p') s )) (ensures ( equal_values h1 p' h2 p' )) [SMTPatOr [ [ SMTPat (modifies s h1 h2); SMTPat (gread h1 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (readable h1 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (live h1 p') ]; [ SMTPat (modifies s h1 h2); SMTPat (gread h2 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (readable h2 p') ] ; [ SMTPat (modifies s h1 h2); SMTPat (live h2 p') ] ] ] val modifies_buffer_elim (#t1: typ) (b: buffer t1) (p: loc) (h h': HS.mem) : Lemma (requires ( loc_disjoint (loc_buffer b) p /\ buffer_live h b /\ (UInt32.v (buffer_length b) == 0 ==> buffer_live h' b) /\ // necessary for liveness, because all buffers of size 0 are disjoint for any memory location, so we cannot talk about their liveness individually without referring to a larger nonempty buffer modifies p h h' )) (ensures ( buffer_live h' b /\ ( buffer_readable h b ==> ( buffer_readable h' b /\ buffer_as_seq h b == buffer_as_seq h' b )))) [SMTPatOr [ [ SMTPat (modifies p h h'); SMTPat (buffer_as_seq h b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_readable h b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_live h b) ]; [ SMTPat (modifies p h h'); SMTPat (buffer_as_seq h' b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_readable h' b) ] ; [ SMTPat (modifies p h h'); SMTPat (buffer_live h' b) ] ] ] val modifies_reference_elim (#t: Type0) (b: HS.reference t) (p: loc) (h h': HS.mem) : Lemma (requires ( loc_disjoint (loc_addresses (HS.frameOf b) (Set.singleton (HS.as_addr b))) p /\ HS.contains h b /\ modifies p h h' )) (ensures ( HS.contains h' b /\ HS.sel h b == HS.sel h' b )) [SMTPatOr [ [ SMTPat (modifies p h h'); SMTPat (HS.sel h b) ] ; [ SMTPat (modifies p h h'); SMTPat (HS.contains h b) ]; [ SMTPat (modifies p h h'); SMTPat (HS.sel h' b) ] ; [ SMTPat (modifies p h h'); SMTPat (HS.contains h' b) ] ] ] val modifies_refl (s: loc) (h: HS.mem) : Lemma (modifies s h h) [SMTPat (modifies s h h)] val modifies_loc_includes (s1: loc) (h h': HS.mem) (s2: loc) : Lemma (requires (modifies s2 h h' /\ loc_includes s1 s2)) (ensures (modifies s1 h h')) [SMTPat (modifies s1 h h'); SMTPat (modifies s2 h h')] val modifies_trans (s12: loc) (h1 h2: HS.mem) (s23: loc) (h3: HS.mem) : Lemma (requires (modifies s12 h1 h2 /\ modifies s23 h2 h3)) (ensures (modifies (loc_union s12 s23) h1 h3)) [SMTPat (modifies s12 h1 h2); SMTPat (modifies s23 h2 h3)] let modifies_0 (h0 h1: HS.mem) : GTot Type0 = modifies loc_none h0 h1
false
false
FStar.Pointer.Base.fsti
{ "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 modifies_1 (#t: typ) (p: pointer t) (h0 h1: HS.mem) : GTot Type0
[]
FStar.Pointer.Base.modifies_1
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: FStar.Pointer.Base.pointer t -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
{ "end_col": 32, "end_line": 2069, "start_col": 2, "start_line": 2069 }
Prims.Tot
val typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ{t << l})
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f
val typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ{t << l}) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ{t << l}) =
false
null
false
typ_of_struct_field l f
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.union_typ", "FStar.Pointer.Base.union_field", "FStar.Pointer.Base.typ_of_struct_field", "FStar.Pointer.Base.typ", "Prims.precedes" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l)
false
false
FStar.Pointer.Base.fsti
{ "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 typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ{t << l})
[]
FStar.Pointer.Base.typ_of_union_field
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.union_typ -> f: FStar.Pointer.Base.union_field l -> t: FStar.Pointer.Base.typ{t << l}
{ "end_col": 25, "end_line": 122, "start_col": 2, "start_line": 122 }
Prims.Tot
val typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ{t << l})
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y
val typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ{t << l}) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ{t << l}) =
false
null
false
List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ'", "FStar.Pointer.Base.struct_field'", "Prims.unit", "FStar.List.Tot.Properties.assoc_precedes", "Prims.string", "FStar.Pointer.Base.typ", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.List.Tot.Base.assoc", "FStar.List.Tot.Properties.assoc_mem", "Prims.precedes" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l)
false
false
FStar.Pointer.Base.fsti
{ "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 typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ{t << l})
[]
FStar.Pointer.Base.typ_of_struct_field'
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ' -> f: FStar.Pointer.Base.struct_field' l -> t: FStar.Pointer.Base.typ{t << l}
{ "end_col": 3, "end_line": 107, "start_col": 2, "start_line": 104 }
Prims.Tot
val typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ{t << l})
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f
val typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ{t << l}) let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ{t << l}) =
false
null
false
typ_of_struct_field' l.fields f
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.struct_field", "FStar.Pointer.Base.typ_of_struct_field'", "FStar.Pointer.Base.__proj__Mkstruct_typ__item__fields", "FStar.Pointer.Base.typ", "Prims.precedes" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l)
false
false
FStar.Pointer.Base.fsti
{ "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 typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ{t << l})
[]
FStar.Pointer.Base.typ_of_struct_field
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ -> f: FStar.Pointer.Base.struct_field l -> t: FStar.Pointer.Base.typ{t << l}
{ "end_col": 33, "end_line": 113, "start_col": 2, "start_line": 113 }
Prims.Tot
val type_of_struct_field'' (l: struct_typ') (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field' l) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y
val type_of_struct_field'' (l: struct_typ') (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field' l) : Tot Type0 let type_of_struct_field'' (l: struct_typ') (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field' l) : Tot Type0 =
false
null
false
List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ'", "FStar.Pointer.Base.typ", "Prims.precedes", "FStar.Pointer.Base.struct_field'", "Prims.unit", "FStar.List.Tot.Properties.assoc_precedes", "Prims.string", "FStar.Pointer.Base.typ_of_struct_field'", "FStar.List.Tot.Properties.assoc_mem" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l)
false
false
FStar.Pointer.Base.fsti
{ "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 type_of_struct_field'' (l: struct_typ') (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field' l) : Tot Type0
[]
FStar.Pointer.Base.type_of_struct_field''
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ' -> type_of_typ: (t: FStar.Pointer.Base.typ{t << l} -> Type0) -> f: FStar.Pointer.Base.struct_field' l -> Type0
{ "end_col": 15, "end_line": 229, "start_col": 2, "start_line": 226 }
Prims.Tot
val type_of_struct_field' (l: struct_typ) (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field l) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f
val type_of_struct_field' (l: struct_typ) (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field l) : Tot Type0 let type_of_struct_field' (l: struct_typ) (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field l) : Tot Type0 =
false
null
false
type_of_struct_field'' l.fields type_of_typ f
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.typ", "Prims.precedes", "FStar.Pointer.Base.struct_field", "FStar.Pointer.Base.type_of_struct_field''", "FStar.Pointer.Base.__proj__Mkstruct_typ__item__fields" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l)
false
false
FStar.Pointer.Base.fsti
{ "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 type_of_struct_field' (l: struct_typ) (type_of_typ: (t: typ{t << l} -> Tot Type0)) (f: struct_field l) : Tot Type0
[]
FStar.Pointer.Base.type_of_struct_field'
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ -> type_of_typ: (t: FStar.Pointer.Base.typ{t << l} -> Type0) -> f: FStar.Pointer.Base.struct_field l -> Type0
{ "end_col": 47, "end_line": 240, "start_col": 2, "start_line": 240 }
Prims.Tot
val type_of_base_typ (t: base_typ) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit
val type_of_base_typ (t: base_typ) : Tot Type0 let type_of_base_typ (t: base_typ) : Tot Type0 =
false
null
false
match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.base_typ", "Prims.nat", "FStar.UInt8.t", "FStar.UInt16.t", "FStar.UInt32.t", "FStar.UInt64.t", "Prims.int", "FStar.Int8.t", "FStar.Int16.t", "FStar.Int32.t", "FStar.Int64.t", "FStar.Char.char", "Prims.bool", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ)
false
true
FStar.Pointer.Base.fsti
{ "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 type_of_base_typ (t: base_typ) : Tot Type0
[]
FStar.Pointer.Base.type_of_base_typ
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Pointer.Base.base_typ -> Type0
{ "end_col": 17, "end_line": 213, "start_col": 2, "start_line": 200 }
Prims.Tot
val struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l)
val struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool =
false
null
false
List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l)
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.struct_literal", "Prims.op_Equality", "Prims.list", "Prims.string", "FStar.List.Tot.Base.sortWith", "FStar.String.compare", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.tuple2", "FStar.Pointer.Base.typ", "FStar.Pervasives.Native.fst", "FStar.Pointer.Base.__proj__Mkstruct_typ__item__fields", "Prims.dtuple2", "FStar.Pointer.Base.struct_field", "FStar.Pointer.Base.type_of_struct_field", "FStar.Pointer.Base.dfst_struct_field", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x)
false
false
FStar.Pointer.Base.fsti
{ "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 struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool
[]
FStar.Pointer.Base.struct_literal_wf
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.Pointer.Base.struct_typ -> l: FStar.Pointer.Base.struct_literal s -> Prims.bool
{ "end_col": 42, "end_line": 307, "start_col": 2, "start_line": 305 }
Prims.Tot
val type_of_typ (t: typ) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t
val type_of_typ (t: typ) : Tot Type0 let rec type_of_typ (t: typ) : Tot Type0 =
false
null
false
match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "total" ]
[ "FStar.Pointer.Base.typ", "FStar.Pointer.Base.base_typ", "FStar.Pointer.Base.type_of_base_typ", "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.struct", "FStar.Pointer.Base.union", "FStar.Pointer.Base.array_length_t", "FStar.Pointer.Base.array", "FStar.Pointer.Base.type_of_typ", "FStar.Pointer.Base.pointer", "FStar.Pointer.Base.npointer", "FStar.Pointer.Base.buffer" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ)
false
true
FStar.Pointer.Base.fsti
{ "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 type_of_typ (t: typ) : Tot Type0
[ "recursion" ]
FStar.Pointer.Base.type_of_typ
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Pointer.Base.typ -> Type0
{ "end_col": 12, "end_line": 262, "start_col": 2, "start_line": 249 }
Prims.Pure
val struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = struct_create_fun s (fun_of_list s l)
val struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) =
false
null
false
struct_create_fun s (fun_of_list s l)
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.struct_literal", "FStar.Pointer.Base.struct_create_fun", "FStar.Pointer.Base.fun_of_list", "FStar.Pointer.Base.struct", "Prims.eq2", "Prims.bool", "FStar.Pervasives.normalize_term", "FStar.Pointer.Base.struct_literal_wf", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim () val struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) : Tot (struct l) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true))
false
false
FStar.Pointer.Base.fsti
{ "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 struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True))
[]
FStar.Pointer.Base.struct_create
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.Pointer.Base.struct_typ -> l: FStar.Pointer.Base.struct_literal s -> Prims.Pure (FStar.Pointer.Base.struct s)
{ "end_col": 39, "end_line": 342, "start_col": 2, "start_line": 342 }
FStar.Pervasives.Lemma
val typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l)
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end
val typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) =
false
null
true
let (f', _) :: l' = l in if f = f' then () else let f:string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "lemma", "" ]
[ "FStar.Pointer.Base.struct_typ'", "FStar.Pointer.Base.struct_field'", "Prims.string", "FStar.Pointer.Base.typ", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.op_Equality", "Prims.bool", "FStar.Pointer.Base.typ_depth_typ_of_struct_field", "Prims.unit", "FStar.List.Tot.Properties.assoc_mem", "Prims._assert", "Prims.b2t", "FStar.List.Tot.Base.mem", "FStar.List.Tot.Base.map", "FStar.Pervasives.Native.fst", "Prims.l_True", "Prims.squash", "Prims.op_LessThanOrEqual", "FStar.Pointer.Base.typ_depth", "FStar.Pointer.Base.typ_of_struct_field'", "FStar.Pointer.Base.struct_typ_depth", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l))
false
false
FStar.Pointer.Base.fsti
{ "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 typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l)
[ "recursion" ]
FStar.Pointer.Base.typ_depth_typ_of_struct_field
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.struct_typ' -> f: FStar.Pointer.Base.struct_field' l -> FStar.Pervasives.Lemma (ensures FStar.Pointer.Base.typ_depth (FStar.Pointer.Base.typ_of_struct_field' l f) <= FStar.Pointer.Base.struct_typ_depth l) (decreases l)
{ "end_col": 5, "end_line": 157, "start_col": 1, "start_line": 149 }
Prims.Pure
val fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim ()
val fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) =
false
null
false
let f':string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _ , v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim ()
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[]
[ "FStar.Pointer.Base.struct_typ", "FStar.Pointer.Base.struct_literal", "FStar.Pointer.Base.struct_field", "FStar.List.Tot.Base.find", "Prims.dtuple2", "FStar.Pointer.Base.type_of_struct_field", "Prims.b2t", "FStar.Pervasives.Native.option", "FStar.Pervasives.false_elim", "Prims.unit", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.None", "FStar.List.Tot.Base.memP", "Prims.bool", "FStar.Classical.move_requires", "FStar.List.Tot.Properties.find_none", "FStar.List.Tot.Properties.memP_map_elim", "Prims.string", "FStar.Pointer.Base.dfst_struct_field", "FStar.List.Tot.Properties.mem_memP", "FStar.List.Tot.Base.map", "FStar.List.Tot.Properties.mem_count", "FStar.Pervasives.Native.tuple2", "FStar.Pointer.Base.typ", "FStar.Pervasives.Native.fst", "FStar.Pointer.Base.__proj__Mkstruct_typ__item__fields", "FStar.List.Tot.Properties.sortWith_permutation", "FStar.String.compare", "Prims.op_Equality", "FStar.Pervasives.normalize_term", "FStar.Pointer.Base.struct_literal_wf", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true))
false
false
FStar.Pointer.Base.fsti
{ "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 fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True))
[]
FStar.Pointer.Base.fun_of_list
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.Pointer.Base.struct_typ -> l: FStar.Pointer.Base.struct_literal s -> f: FStar.Pointer.Base.struct_field s -> Prims.Pure (FStar.Pointer.Base.type_of_struct_field s f)
{ "end_col": 17, "end_line": 332, "start_col": 1, "start_line": 316 }
FStar.Pervasives.Lemma
val loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))] = loc_disjoint_includes l (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i))
val loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))] let loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))] =
false
null
true
loc_disjoint_includes l (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i))
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "lemma" ]
[ "FStar.Pointer.Base.loc", "FStar.Pointer.Base.typ", "FStar.Pointer.Base.buffer", "FStar.UInt32.t", "FStar.Pointer.Base.loc_disjoint_includes", "FStar.Pointer.Base.loc_buffer", "FStar.Pointer.Base.loc_pointer", "FStar.Pointer.Base.gpointer_of_buffer_cell", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.Pointer.Base.buffer_length", "FStar.Pointer.Base.loc_disjoint", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim () val struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) : Tot (struct l) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = struct_create_fun s (fun_of_list s l) val struct_sel_struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) (fd: struct_field l) : Lemma (struct_sel (struct_create_fun l f) fd == f fd) [SMTPat (struct_sel (struct_create_fun l f) fd)] let type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] = assert_norm (type_of_typ (TUnion l) == union l) val union_get_key (#l: union_typ) (v: union l) : GTot (struct_field l) val union_get_value (#l: union_typ) (v: union l) (fd: struct_field l) : Pure (type_of_struct_field l fd) (requires (union_get_key v == fd)) (ensures (fun _ -> True)) val union_create (l: union_typ) (fd: struct_field l) (v: type_of_struct_field l fd) : Tot (union l) (*** Semantics of pointers *) (** Operations on pointers *) val equal (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Ghost bool (requires True) (ensures (fun b -> b == true <==> t1 == t2 /\ p1 == p2 )) val as_addr (#t: typ) (p: pointer t): GTot (x: nat { x > 0 } ) val unused_in (#value: typ) (p: pointer value) (h: HS.mem) : GTot Type0 val live (#value: typ) (h: HS.mem) (p: pointer value) : GTot Type0 val nlive (#value: typ) (h: HS.mem) (p: npointer value) : GTot Type0 val live_nlive (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (nlive h p <==> live h p) [SMTPat (nlive h p)] val g_is_null_nlive (#t: typ) (h: HS.mem) (p: npointer t) : Lemma (requires (g_is_null p)) (ensures (nlive h p)) [SMTPat (g_is_null p); SMTPat (nlive h p)] val live_not_unused_in (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (ensures (live h p /\ p `unused_in` h ==> False)) [SMTPat (live h p); SMTPat (p `unused_in` h)] val gread (#value: typ) (h: HS.mem) (p: pointer value) : GTot (type_of_typ value) val frameOf (#value: typ) (p: pointer value) : GTot HS.rid val live_region_frameOf (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (requires (live h p)) (ensures (HS.live_region h (frameOf p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf p))]; [SMTPat (live h p)] ]] val disjoint_roots_intro_pointer_vs_pointer (#value1 value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 =!= as_addr p2)) val disjoint_roots_intro_pointer_vs_reference (#value1: typ) (#value2: Type) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ p2 `HS.unused_in` h)) (ensures (frameOf p1 <> HS.frameOf p2 \/ as_addr p1 =!= HS.as_addr p2)) val disjoint_roots_intro_reference_vs_pointer (#value1: Type) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ p2 `unused_in` h)) (ensures (HS.frameOf p1 <> frameOf p2 \/ HS.as_addr p1 =!= as_addr p2)) val is_mm (#value: typ) (p: pointer value) : GTot bool (* // TODO: recover with addresses? val recall (#value: Type) (p: pointer value {is_eternal_region (frameOf p) && not (is_mm p)}) : HST.Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 p)) *) val gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gfield p fd) == as_addr p)) [SMTPat (as_addr (gfield p fd))] val unused_in_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gfield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gfield p fd) h)] val live_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gfield p fd) <==> live h p)) [SMTPat (live h (gfield p fd))] val gread_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (gread h (gfield p fd) == struct_sel (gread h p) fd)) [SMTPatOr [[SMTPat (gread h (gfield p fd))]; [SMTPat (struct_sel (gread h p) fd)]]] val frameOf_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gfield p fd) == frameOf p)) [SMTPat (frameOf (gfield p fd))] val is_mm_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gfield p fd) <==> is_mm p)) [SMTPat (is_mm (gfield p fd))] val gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gufield p fd) == as_addr p)) [SMTPat (as_addr (gufield p fd))] val unused_in_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gufield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gufield p fd) h)] val live_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gufield p fd) <==> live h p)) [SMTPat (live h (gufield p fd))] val gread_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (union_get_key (gread h p) == fd)) (ensures ( union_get_key (gread h p) == fd /\ gread h (gufield p fd) == union_get_value (gread h p) fd )) [SMTPatOr [[SMTPat (gread h (gufield p fd))]; [SMTPat (union_get_value (gread h p) fd)]]] val frameOf_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gufield p fd) == frameOf p)) [SMTPat (frameOf (gufield p fd))] val is_mm_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gufield p fd) <==> is_mm p)) [SMTPat (is_mm (gufield p fd))] val gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Ghost (pointer value) (requires (UInt32.v i < UInt32.v length)) (ensures (fun _ -> True)) val as_addr_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ as_addr (gcell p i) == as_addr p)) [SMTPat (as_addr (gcell p i))] val unused_in_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (unused_in (gcell p i) h <==> unused_in p h))) [SMTPat (unused_in (gcell p i) h)] val live_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (live h (gcell p i) <==> live h p))) [SMTPat (live h (gcell p i))] val gread_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gread h (gcell p i) == Seq.index (gread h p) (UInt32.v i))) [SMTPat (gread h (gcell p i))] val frameOf_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ frameOf (gcell p i) == frameOf p)) [SMTPat (frameOf (gcell p i))] val is_mm_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ is_mm (gcell p i) == is_mm p)) [SMTPat (is_mm (gcell p i))] val includes (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : GTot bool val includes_refl (#t: typ) (p: pointer t) : Lemma (ensures (includes p p)) [SMTPat (includes p p)] val includes_trans (#t1 #t2 #t3: typ) (p1: pointer t1) (p2: pointer t2) (p3: pointer t3) : Lemma (requires (includes p1 p2 /\ includes p2 p3)) (ensures (includes p1 p3)) val includes_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gfield p fd))) val includes_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gufield p fd))) val includes_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ includes p (gcell p i))) (** The readable permission. We choose to implement it only abstractly, instead of explicitly tracking the permission in the heap. *) val readable (#a: typ) (h: HS.mem) (b: pointer a) : GTot Type0 val readable_live (#a: typ) (h: HS.mem) (b: pointer a) : Lemma (requires (readable h b)) (ensures (live h b)) [SMTPatOr [ [SMTPat (readable h b)]; [SMTPat (live h b)]; ]] val readable_gfield (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires (readable h p)) (ensures (readable h (gfield p fd))) [SMTPat (readable h (gfield p fd))] val readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires ( forall (f: struct_field l) . readable h (gfield p f) )) (ensures (readable h p)) // [SMTPat (readable #(TStruct l) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints val readable_struct_forall_mem (#l: struct_typ) (p: pointer (TStruct l)) : Lemma (forall (h: HS.mem) . ( forall (f: struct_field l) . readable h (gfield p f) ) ==> readable h p ) val readable_struct_fields (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (s: list string) : GTot Type0 val readable_struct_fields_nil (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (readable_struct_fields h p []) [SMTPat (readable_struct_fields h p [])] val readable_struct_fields_cons (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (f: string) (q: list string) : Lemma (requires (readable_struct_fields h p q /\ (List.Tot.mem f (List.Tot.map fst l.fields) ==> (let f : struct_field l = f in readable h (gfield p f))))) (ensures (readable_struct_fields h p (f::q))) [SMTPat (readable_struct_fields h p (f::q))] val readable_struct_fields_readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires (readable_struct_fields h p (normalize_term (List.Tot.map fst l.fields)))) (ensures (readable h p)) val readable_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length /\ readable h p)) (ensures (UInt32.v i < UInt32.v length /\ readable h (gcell p i))) [SMTPat (readable h (gcell p i))] val readable_array (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) : Lemma (requires ( forall (i: UInt32.t) . UInt32.v i < UInt32.v length ==> readable h (gcell p i) )) (ensures (readable h p)) // [SMTPat (readable #(TArray length value) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints (* TODO: improve on the following interface *) val readable_gufield (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (readable h (gufield p fd) <==> (readable h p /\ union_get_key (gread h p) == fd))) [SMTPat (readable h (gufield p fd))] (** The active field of a union *) val is_active_union_field (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : GTot Type0 val is_active_union_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h p)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h (gufield p fd))) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_eq (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd1 fd2: struct_field l) : Lemma (requires (is_active_union_field h p fd1 /\ is_active_union_field h p fd2)) (ensures (fd1 == fd2)) [SMTPat (is_active_union_field h p fd1); SMTPat (is_active_union_field h p fd2)] val is_active_union_field_get_key (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (union_get_key (gread h p) == fd)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd /\ readable h (gufield p fd))) (ensures (readable h p)) [SMTPat (is_active_union_field h p fd); SMTPat (readable h (gufield p fd))] val is_active_union_field_includes_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) (#t': typ) (p' : pointer t') : Lemma (requires (includes (gufield p fd) p' /\ readable h p')) (ensures (is_active_union_field h p fd)) (* Equality predicate on struct contents, without quantifiers *) let equal_values #a h (b:pointer a) h' (b':pointer a) : GTot Type0 = (live h b ==> live h' b') /\ ( readable h b ==> ( readable h' b' /\ gread h b == gread h' b' )) (*** Semantics of buffers *) (** Operations on buffers *) val gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : GTot (buffer t) val singleton_buffer_of_pointer (#t: typ) (p: pointer t) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gsingleton_buffer_of_pointer p)) val gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : GTot (buffer t) val buffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gbuffer_of_array_pointer p)) val buffer_length (#t: typ) (b: buffer t) : GTot UInt32.t val buffer_length_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (requires True) (ensures (buffer_length (gsingleton_buffer_of_pointer p) == 1ul)) [SMTPat (buffer_length (gsingleton_buffer_of_pointer p))] val buffer_length_gbuffer_of_array_pointer (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_length (gbuffer_of_array_pointer p) == len)) [SMTPat (buffer_length (gbuffer_of_array_pointer p))] val buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_live_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_live h (gsingleton_buffer_of_pointer p) <==> live h p )) [SMTPat (buffer_live h (gsingleton_buffer_of_pointer p))] val buffer_live_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_live h (gbuffer_of_array_pointer p) <==> live h p)) [SMTPat (buffer_live h (gbuffer_of_array_pointer p))] val buffer_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : GTot Type0 val buffer_live_not_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : Lemma ((buffer_live h b /\ buffer_unused_in b h) ==> False) val buffer_unused_in_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_unused_in (gsingleton_buffer_of_pointer p) h <==> unused_in p h )) [SMTPat (buffer_unused_in (gsingleton_buffer_of_pointer p) h)] val buffer_unused_in_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_unused_in (gbuffer_of_array_pointer p) h <==> unused_in p h)) [SMTPat (buffer_unused_in (gbuffer_of_array_pointer p) h)] val frameOf_buffer (#t: typ) (b: buffer t) : GTot HS.rid val frameOf_buffer_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (frameOf_buffer (gsingleton_buffer_of_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gsingleton_buffer_of_pointer p))] val frameOf_buffer_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (frameOf_buffer (gbuffer_of_array_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gbuffer_of_array_pointer p))] val live_region_frameOf_buffer (#value: typ) (h: HS.mem) (p: buffer value) : Lemma (requires (buffer_live h p)) (ensures (HS.live_region h (frameOf_buffer p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf_buffer p))]; [SMTPat (buffer_live h p)] ]] val buffer_as_addr (#t: typ) (b: buffer t) : GTot (x: nat { x > 0 } ) val buffer_as_addr_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (buffer_as_addr (gsingleton_buffer_of_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gsingleton_buffer_of_pointer p))] val buffer_as_addr_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (buffer_as_addr (gbuffer_of_array_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gbuffer_of_array_pointer p))] val gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Ghost (buffer t) (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val frameOf_buffer_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ frameOf_buffer (gsub_buffer b i len) == frameOf_buffer b )) [SMTPat (frameOf_buffer (gsub_buffer b i len))] val buffer_as_addr_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_addr (gsub_buffer b i len) == buffer_as_addr b )) [SMTPat (buffer_as_addr (gsub_buffer b i len))] val sub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i len )) val offset_buffer (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i (UInt32.sub (buffer_length b) i))) val buffer_length_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_length (gsub_buffer b i len) == len)) [SMTPat (buffer_length (gsub_buffer b i len))] val buffer_live_gsub_buffer_equiv (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_live h (gsub_buffer b i len) <==> buffer_live h b))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_live_gsub_buffer_intro (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (buffer_live h b /\ UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b i len))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_unused_in_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_unused_in (gsub_buffer b i len) h <==> buffer_unused_in b h))) [SMTPat (buffer_unused_in (gsub_buffer b i len) h)] val gsub_buffer_gsub_buffer (#a: typ) (b: buffer a) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 )) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\ gsub_buffer (gsub_buffer b i1 len1) i2 len2 == gsub_buffer b FStar.UInt32.(i1 +^ i2) len2 )) [SMTPat (gsub_buffer (gsub_buffer b i1 len1) i2 len2)] val gsub_buffer_zero_buffer_length (#a: typ) (b: buffer a) : Lemma (ensures (gsub_buffer b 0ul (buffer_length b) == b)) [SMTPat (gsub_buffer b 0ul (buffer_length b))] val buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : GTot (Seq.seq (type_of_typ t)) val buffer_length_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires True) (ensures (Seq.length (buffer_as_seq h b) == UInt32.v (buffer_length b))) [SMTPat (Seq.length (buffer_as_seq h b))] val buffer_as_seq_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (requires True) (ensures (buffer_as_seq h (gsingleton_buffer_of_pointer p) == Seq.create 1 (gread h p))) [SMTPat (buffer_as_seq h (gsingleton_buffer_of_pointer p))] val buffer_as_seq_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray length t)) : Lemma (requires True) (ensures (buffer_as_seq h (gbuffer_of_array_pointer p) == gread h p)) [SMTPat (buffer_as_seq h (gbuffer_of_array_pointer p))] val buffer_as_seq_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_seq h (gsub_buffer b i len) == Seq.slice (buffer_as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))) [SMTPat (buffer_as_seq h (gsub_buffer b i len))] val gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Ghost (pointer t) (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val pointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (pointer t) (requires (fun h -> UInt32.v i < UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h p h' -> UInt32.v i < UInt32.v (buffer_length b) /\ h' == h /\ p == gpointer_of_buffer_cell b i)) val gpointer_of_buffer_cell_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) let gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)] = gpointer_of_buffer_cell_gsub_buffer b i1 len i2 val live_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) (h: HS.mem) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ (live h (gpointer_of_buffer_cell b i) <==> buffer_live h b) )) [SMTPat (live h (gpointer_of_buffer_cell b i))] val gpointer_of_buffer_cell_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < 1)) (ensures (UInt32.v i < 1 /\ gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i == p)) [SMTPat (gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i)] val gpointer_of_buffer_cell_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (p: pointer (TArray length t)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i == gcell p i)) [SMTPat (gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i)] val frameOf_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ frameOf (gpointer_of_buffer_cell b i) == frameOf_buffer b)) [SMTPat (frameOf (gpointer_of_buffer_cell b i))] val as_addr_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ as_addr (gpointer_of_buffer_cell b i) == buffer_as_addr b)) [SMTPat (as_addr (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) [SMTPat (gread h (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell' (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) val index_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) (i: nat) : Lemma (requires (i < UInt32.v (buffer_length b))) (ensures (i < UInt32.v (buffer_length b) /\ Seq.index (buffer_as_seq h b) i == gread h (gpointer_of_buffer_cell b (UInt32.uint_to_t i)))) [SMTPat (Seq.index (buffer_as_seq h b) i)] val gsingleton_buffer_of_pointer_gcell (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v len )) (ensures ( UInt32.v i < UInt32.v len /\ gsingleton_buffer_of_pointer (gcell p i) == gsub_buffer (gbuffer_of_array_pointer p) i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gcell p i))] val gsingleton_buffer_of_pointer_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i) == gsub_buffer b i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i))] (* The readable permission lifted to buffers. *) val buffer_readable (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_readable_buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires (buffer_readable h b)) (ensures (buffer_live h b)) [SMTPatOr [ [SMTPat (buffer_readable h b)]; [SMTPat (buffer_live h b)]; ]] val buffer_readable_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (ensures (buffer_readable h (gsingleton_buffer_of_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gsingleton_buffer_of_pointer p))] val buffer_readable_gbuffer_of_array_pointer (#len: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_readable h (gbuffer_of_array_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gbuffer_of_array_pointer p))] val buffer_readable_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h (gsub_buffer b i len))) [SMTPat (buffer_readable h (gsub_buffer b i len))] val readable_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ readable h (gpointer_of_buffer_cell b i))) [SMTPat (readable h (gpointer_of_buffer_cell b i))] val buffer_readable_intro (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (ensures (buffer_readable h b)) // [SMTPat (buffer_readable h b)] // TODO: dubious pattern, may trigger unreplayable hints val buffer_readable_elim (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_readable h b )) (ensures ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (*** The modifies clause *) val loc : Type u#0 val loc_none: loc val loc_union (s1 s2: loc) : GTot loc (** The following is useful to make Z3 cut matching loops with modifies_trans and modifies_refl *) val loc_union_idem (s: loc) : Lemma (loc_union s s == s) [SMTPat (loc_union s s)] val loc_pointer (#t: typ) (p: pointer t) : GTot loc val loc_buffer (#t: typ) (b: buffer t) : GTot loc val loc_addresses (r: HS.rid) (n: Set.set nat) : GTot loc val loc_regions (r: Set.set HS.rid) : GTot loc (* Inclusion of memory locations *) val loc_includes (s1 s2: loc) : GTot Type0 val loc_includes_refl (s: loc) : Lemma (loc_includes s s) [SMTPat (loc_includes s s)] val loc_includes_trans (s1 s2 s3: loc) : Lemma (requires (loc_includes s1 s2 /\ loc_includes s2 s3)) (ensures (loc_includes s1 s3)) val loc_includes_union_r (s s1 s2: loc) : Lemma (requires (loc_includes s s1 /\ loc_includes s s2)) (ensures (loc_includes s (loc_union s1 s2))) [SMTPat (loc_includes s (loc_union s1 s2))] val loc_includes_union_l (s1 s2 s: loc) : Lemma (requires (loc_includes s1 s \/ loc_includes s2 s)) (ensures (loc_includes (loc_union s1 s2) s)) [SMTPat (loc_includes (loc_union s1 s2) s)] val loc_includes_none (s: loc) : Lemma (loc_includes s loc_none) [SMTPat (loc_includes s loc_none)] val loc_includes_pointer_pointer (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Lemma (requires (includes p1 p2)) (ensures (loc_includes (loc_pointer p1) (loc_pointer p2))) [SMTPat (loc_includes (loc_pointer p1) (loc_pointer p2))] val loc_includes_gsingleton_buffer_of_pointer (l: loc) (#t: typ) (p: pointer t) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))] val loc_includes_gbuffer_of_array_pointer (l: loc) (#len: array_length_t) (#t: typ) (p: pointer (TArray len t)) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))] val loc_includes_gpointer_of_array_cell (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))] val loc_includes_gsub_buffer_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer (gsub_buffer b i len)))) [SMTPat (loc_includes l (loc_buffer (gsub_buffer b i len)))] val loc_includes_gsub_buffer_l (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1)) (ensures (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1 /\ loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))) [SMTPat (loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_includes_addresses_pointer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: pointer t) : Lemma (requires (frameOf p == r /\ Set.mem (as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_pointer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_pointer p))] val loc_includes_addresses_buffer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: buffer t) : Lemma (requires (frameOf_buffer p == r /\ Set.mem (buffer_as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_buffer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_buffer p))] val loc_includes_region_pointer (#t: typ) (s: Set.set HS.rid) (p: pointer t) : Lemma (requires (Set.mem (frameOf p) s)) (ensures (loc_includes (loc_regions s) (loc_pointer p))) [SMTPat (loc_includes (loc_regions s) (loc_pointer p))] val loc_includes_region_buffer (#t: typ) (s: Set.set HS.rid) (b: buffer t) : Lemma (requires (Set.mem (frameOf_buffer b) s)) (ensures (loc_includes (loc_regions s) (loc_buffer b))) [SMTPat (loc_includes (loc_regions s) (loc_buffer b))] val loc_includes_region_addresses (s: Set.set HS.rid) (r: HS.rid) (a: Set.set nat) : Lemma (requires (Set.mem r s)) (ensures (loc_includes (loc_regions s) (loc_addresses r a))) [SMTPat (loc_includes (loc_regions s) (loc_addresses r a))] val loc_includes_region_region (s1 s2: Set.set HS.rid) : Lemma (requires (Set.subset s2 s1)) (ensures (loc_includes (loc_regions s1) (loc_regions s2))) [SMTPat (loc_includes (loc_regions s1) (loc_regions s2))] val loc_includes_region_union_l (l: loc) (s1 s2: Set.set HS.rid) : Lemma (requires (loc_includes l (loc_regions (Set.intersect s2 (Set.complement s1))))) (ensures (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))) [SMTPat (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))] (* Disjointness of two memory locations *) val loc_disjoint (s1 s2: loc) : GTot Type0 val loc_disjoint_sym (s1 s2: loc) : Lemma (requires (loc_disjoint s1 s2)) (ensures (loc_disjoint s2 s1)) [SMTPat (loc_disjoint s1 s2)] val loc_disjoint_none_r (s: loc) : Lemma (ensures (loc_disjoint s loc_none)) [SMTPat (loc_disjoint s loc_none)] val loc_disjoint_union_r (s s1 s2: loc) : Lemma (requires (loc_disjoint s s1 /\ loc_disjoint s s2)) (ensures (loc_disjoint s (loc_union s1 s2))) [SMTPat (loc_disjoint s (loc_union s1 s2))] val loc_disjoint_root (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) val loc_disjoint_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd1 fd2: struct_field l) : Lemma (requires (fd1 <> fd2)) (ensures (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))) [SMTPat (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))] val loc_disjoint_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ UInt32.v i1 <> UInt32.v i2 )) (ensures ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)) )) [SMTPat (loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)))] val loc_disjoint_includes (p1 p2 p1' p2' : loc) : Lemma (requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2)) (ensures (loc_disjoint p1' p2')) (* TODO: The following is now wrong, should be replaced with readable val live_not_equal_disjoint (#t: typ) (h: HS.mem) (p1 p2: pointer t) : Lemma (requires (live h p1 /\ live h p2 /\ equal p1 p2 == false)) (ensures (disjoint p1 p2)) *) val live_unused_in_disjoint_strong (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) val live_unused_in_disjoint (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) [SMTPatOr [ [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (live h p1)]; [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (unused_in p2 h)]; [SMTPat (live h p1); SMTPat (unused_in p2 h)]; ]] val pointer_live_reference_unused_in_disjoint (#value1: typ) (#value2: Type0) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ HS.unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_addresses (HS.frameOf p2) (Set.singleton (HS.as_addr p2))))) [SMTPat (live h p1); SMTPat (HS.unused_in p2 h)] val reference_live_pointer_unused_in_disjoint (#value1: Type0) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_addresses (HS.frameOf p1) (Set.singleton (HS.as_addr p1))) (loc_pointer p2))) [SMTPat (HS.contains h p1); SMTPat (unused_in p2 h)] val loc_disjoint_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ ( UInt32.v i1 + UInt32.v len1 <= UInt32.v i2 \/ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 ))) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)) )) [SMTPat (loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_disjoint_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ ( UInt32.v i1 <> UInt32.v i2 ))) (ensures ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)) )) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)))] let loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i))))
false
false
FStar.Pointer.Base.fsti
{ "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 loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))]
[]
FStar.Pointer.Base.loc_disjoint_gpointer_of_buffer_cell_r
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.loc -> b: FStar.Pointer.Base.buffer t -> i: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires FStar.UInt32.v i < FStar.UInt32.v (FStar.Pointer.Base.buffer_length b) /\ FStar.Pointer.Base.loc_disjoint l (FStar.Pointer.Base.loc_buffer b)) (ensures FStar.UInt32.v i < FStar.UInt32.v (FStar.Pointer.Base.buffer_length b) /\ FStar.Pointer.Base.loc_disjoint l (FStar.Pointer.Base.loc_pointer (FStar.Pointer.Base.gpointer_of_buffer_cell b i))) [ SMTPat (FStar.Pointer.Base.loc_disjoint l (FStar.Pointer.Base.loc_pointer (FStar.Pointer.Base.gpointer_of_buffer_cell b i))) ]
{ "end_col": 86, "end_line": 1905, "start_col": 2, "start_line": 1905 }
FStar.Pervasives.Lemma
val loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)] = loc_disjoint_includes (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i)) l
val loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)] let loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)] =
false
null
true
loc_disjoint_includes (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i)) l
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "lemma" ]
[ "FStar.Pointer.Base.loc", "FStar.Pointer.Base.typ", "FStar.Pointer.Base.buffer", "FStar.UInt32.t", "FStar.Pointer.Base.loc_disjoint_includes", "FStar.Pointer.Base.loc_buffer", "FStar.Pointer.Base.loc_pointer", "FStar.Pointer.Base.gpointer_of_buffer_cell", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.Pointer.Base.buffer_length", "FStar.Pointer.Base.loc_disjoint", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim () val struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) : Tot (struct l) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = struct_create_fun s (fun_of_list s l) val struct_sel_struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) (fd: struct_field l) : Lemma (struct_sel (struct_create_fun l f) fd == f fd) [SMTPat (struct_sel (struct_create_fun l f) fd)] let type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] = assert_norm (type_of_typ (TUnion l) == union l) val union_get_key (#l: union_typ) (v: union l) : GTot (struct_field l) val union_get_value (#l: union_typ) (v: union l) (fd: struct_field l) : Pure (type_of_struct_field l fd) (requires (union_get_key v == fd)) (ensures (fun _ -> True)) val union_create (l: union_typ) (fd: struct_field l) (v: type_of_struct_field l fd) : Tot (union l) (*** Semantics of pointers *) (** Operations on pointers *) val equal (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Ghost bool (requires True) (ensures (fun b -> b == true <==> t1 == t2 /\ p1 == p2 )) val as_addr (#t: typ) (p: pointer t): GTot (x: nat { x > 0 } ) val unused_in (#value: typ) (p: pointer value) (h: HS.mem) : GTot Type0 val live (#value: typ) (h: HS.mem) (p: pointer value) : GTot Type0 val nlive (#value: typ) (h: HS.mem) (p: npointer value) : GTot Type0 val live_nlive (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (nlive h p <==> live h p) [SMTPat (nlive h p)] val g_is_null_nlive (#t: typ) (h: HS.mem) (p: npointer t) : Lemma (requires (g_is_null p)) (ensures (nlive h p)) [SMTPat (g_is_null p); SMTPat (nlive h p)] val live_not_unused_in (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (ensures (live h p /\ p `unused_in` h ==> False)) [SMTPat (live h p); SMTPat (p `unused_in` h)] val gread (#value: typ) (h: HS.mem) (p: pointer value) : GTot (type_of_typ value) val frameOf (#value: typ) (p: pointer value) : GTot HS.rid val live_region_frameOf (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (requires (live h p)) (ensures (HS.live_region h (frameOf p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf p))]; [SMTPat (live h p)] ]] val disjoint_roots_intro_pointer_vs_pointer (#value1 value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 =!= as_addr p2)) val disjoint_roots_intro_pointer_vs_reference (#value1: typ) (#value2: Type) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ p2 `HS.unused_in` h)) (ensures (frameOf p1 <> HS.frameOf p2 \/ as_addr p1 =!= HS.as_addr p2)) val disjoint_roots_intro_reference_vs_pointer (#value1: Type) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ p2 `unused_in` h)) (ensures (HS.frameOf p1 <> frameOf p2 \/ HS.as_addr p1 =!= as_addr p2)) val is_mm (#value: typ) (p: pointer value) : GTot bool (* // TODO: recover with addresses? val recall (#value: Type) (p: pointer value {is_eternal_region (frameOf p) && not (is_mm p)}) : HST.Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 p)) *) val gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gfield p fd) == as_addr p)) [SMTPat (as_addr (gfield p fd))] val unused_in_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gfield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gfield p fd) h)] val live_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gfield p fd) <==> live h p)) [SMTPat (live h (gfield p fd))] val gread_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (gread h (gfield p fd) == struct_sel (gread h p) fd)) [SMTPatOr [[SMTPat (gread h (gfield p fd))]; [SMTPat (struct_sel (gread h p) fd)]]] val frameOf_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gfield p fd) == frameOf p)) [SMTPat (frameOf (gfield p fd))] val is_mm_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gfield p fd) <==> is_mm p)) [SMTPat (is_mm (gfield p fd))] val gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gufield p fd) == as_addr p)) [SMTPat (as_addr (gufield p fd))] val unused_in_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gufield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gufield p fd) h)] val live_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gufield p fd) <==> live h p)) [SMTPat (live h (gufield p fd))] val gread_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (union_get_key (gread h p) == fd)) (ensures ( union_get_key (gread h p) == fd /\ gread h (gufield p fd) == union_get_value (gread h p) fd )) [SMTPatOr [[SMTPat (gread h (gufield p fd))]; [SMTPat (union_get_value (gread h p) fd)]]] val frameOf_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gufield p fd) == frameOf p)) [SMTPat (frameOf (gufield p fd))] val is_mm_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gufield p fd) <==> is_mm p)) [SMTPat (is_mm (gufield p fd))] val gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Ghost (pointer value) (requires (UInt32.v i < UInt32.v length)) (ensures (fun _ -> True)) val as_addr_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ as_addr (gcell p i) == as_addr p)) [SMTPat (as_addr (gcell p i))] val unused_in_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (unused_in (gcell p i) h <==> unused_in p h))) [SMTPat (unused_in (gcell p i) h)] val live_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (live h (gcell p i) <==> live h p))) [SMTPat (live h (gcell p i))] val gread_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gread h (gcell p i) == Seq.index (gread h p) (UInt32.v i))) [SMTPat (gread h (gcell p i))] val frameOf_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ frameOf (gcell p i) == frameOf p)) [SMTPat (frameOf (gcell p i))] val is_mm_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ is_mm (gcell p i) == is_mm p)) [SMTPat (is_mm (gcell p i))] val includes (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : GTot bool val includes_refl (#t: typ) (p: pointer t) : Lemma (ensures (includes p p)) [SMTPat (includes p p)] val includes_trans (#t1 #t2 #t3: typ) (p1: pointer t1) (p2: pointer t2) (p3: pointer t3) : Lemma (requires (includes p1 p2 /\ includes p2 p3)) (ensures (includes p1 p3)) val includes_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gfield p fd))) val includes_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gufield p fd))) val includes_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ includes p (gcell p i))) (** The readable permission. We choose to implement it only abstractly, instead of explicitly tracking the permission in the heap. *) val readable (#a: typ) (h: HS.mem) (b: pointer a) : GTot Type0 val readable_live (#a: typ) (h: HS.mem) (b: pointer a) : Lemma (requires (readable h b)) (ensures (live h b)) [SMTPatOr [ [SMTPat (readable h b)]; [SMTPat (live h b)]; ]] val readable_gfield (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires (readable h p)) (ensures (readable h (gfield p fd))) [SMTPat (readable h (gfield p fd))] val readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires ( forall (f: struct_field l) . readable h (gfield p f) )) (ensures (readable h p)) // [SMTPat (readable #(TStruct l) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints val readable_struct_forall_mem (#l: struct_typ) (p: pointer (TStruct l)) : Lemma (forall (h: HS.mem) . ( forall (f: struct_field l) . readable h (gfield p f) ) ==> readable h p ) val readable_struct_fields (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (s: list string) : GTot Type0 val readable_struct_fields_nil (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (readable_struct_fields h p []) [SMTPat (readable_struct_fields h p [])] val readable_struct_fields_cons (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (f: string) (q: list string) : Lemma (requires (readable_struct_fields h p q /\ (List.Tot.mem f (List.Tot.map fst l.fields) ==> (let f : struct_field l = f in readable h (gfield p f))))) (ensures (readable_struct_fields h p (f::q))) [SMTPat (readable_struct_fields h p (f::q))] val readable_struct_fields_readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires (readable_struct_fields h p (normalize_term (List.Tot.map fst l.fields)))) (ensures (readable h p)) val readable_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length /\ readable h p)) (ensures (UInt32.v i < UInt32.v length /\ readable h (gcell p i))) [SMTPat (readable h (gcell p i))] val readable_array (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) : Lemma (requires ( forall (i: UInt32.t) . UInt32.v i < UInt32.v length ==> readable h (gcell p i) )) (ensures (readable h p)) // [SMTPat (readable #(TArray length value) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints (* TODO: improve on the following interface *) val readable_gufield (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (readable h (gufield p fd) <==> (readable h p /\ union_get_key (gread h p) == fd))) [SMTPat (readable h (gufield p fd))] (** The active field of a union *) val is_active_union_field (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : GTot Type0 val is_active_union_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h p)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h (gufield p fd))) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_eq (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd1 fd2: struct_field l) : Lemma (requires (is_active_union_field h p fd1 /\ is_active_union_field h p fd2)) (ensures (fd1 == fd2)) [SMTPat (is_active_union_field h p fd1); SMTPat (is_active_union_field h p fd2)] val is_active_union_field_get_key (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (union_get_key (gread h p) == fd)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd /\ readable h (gufield p fd))) (ensures (readable h p)) [SMTPat (is_active_union_field h p fd); SMTPat (readable h (gufield p fd))] val is_active_union_field_includes_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) (#t': typ) (p' : pointer t') : Lemma (requires (includes (gufield p fd) p' /\ readable h p')) (ensures (is_active_union_field h p fd)) (* Equality predicate on struct contents, without quantifiers *) let equal_values #a h (b:pointer a) h' (b':pointer a) : GTot Type0 = (live h b ==> live h' b') /\ ( readable h b ==> ( readable h' b' /\ gread h b == gread h' b' )) (*** Semantics of buffers *) (** Operations on buffers *) val gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : GTot (buffer t) val singleton_buffer_of_pointer (#t: typ) (p: pointer t) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gsingleton_buffer_of_pointer p)) val gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : GTot (buffer t) val buffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gbuffer_of_array_pointer p)) val buffer_length (#t: typ) (b: buffer t) : GTot UInt32.t val buffer_length_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (requires True) (ensures (buffer_length (gsingleton_buffer_of_pointer p) == 1ul)) [SMTPat (buffer_length (gsingleton_buffer_of_pointer p))] val buffer_length_gbuffer_of_array_pointer (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_length (gbuffer_of_array_pointer p) == len)) [SMTPat (buffer_length (gbuffer_of_array_pointer p))] val buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_live_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_live h (gsingleton_buffer_of_pointer p) <==> live h p )) [SMTPat (buffer_live h (gsingleton_buffer_of_pointer p))] val buffer_live_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_live h (gbuffer_of_array_pointer p) <==> live h p)) [SMTPat (buffer_live h (gbuffer_of_array_pointer p))] val buffer_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : GTot Type0 val buffer_live_not_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : Lemma ((buffer_live h b /\ buffer_unused_in b h) ==> False) val buffer_unused_in_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_unused_in (gsingleton_buffer_of_pointer p) h <==> unused_in p h )) [SMTPat (buffer_unused_in (gsingleton_buffer_of_pointer p) h)] val buffer_unused_in_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_unused_in (gbuffer_of_array_pointer p) h <==> unused_in p h)) [SMTPat (buffer_unused_in (gbuffer_of_array_pointer p) h)] val frameOf_buffer (#t: typ) (b: buffer t) : GTot HS.rid val frameOf_buffer_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (frameOf_buffer (gsingleton_buffer_of_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gsingleton_buffer_of_pointer p))] val frameOf_buffer_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (frameOf_buffer (gbuffer_of_array_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gbuffer_of_array_pointer p))] val live_region_frameOf_buffer (#value: typ) (h: HS.mem) (p: buffer value) : Lemma (requires (buffer_live h p)) (ensures (HS.live_region h (frameOf_buffer p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf_buffer p))]; [SMTPat (buffer_live h p)] ]] val buffer_as_addr (#t: typ) (b: buffer t) : GTot (x: nat { x > 0 } ) val buffer_as_addr_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (buffer_as_addr (gsingleton_buffer_of_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gsingleton_buffer_of_pointer p))] val buffer_as_addr_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (buffer_as_addr (gbuffer_of_array_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gbuffer_of_array_pointer p))] val gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Ghost (buffer t) (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val frameOf_buffer_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ frameOf_buffer (gsub_buffer b i len) == frameOf_buffer b )) [SMTPat (frameOf_buffer (gsub_buffer b i len))] val buffer_as_addr_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_addr (gsub_buffer b i len) == buffer_as_addr b )) [SMTPat (buffer_as_addr (gsub_buffer b i len))] val sub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i len )) val offset_buffer (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i (UInt32.sub (buffer_length b) i))) val buffer_length_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_length (gsub_buffer b i len) == len)) [SMTPat (buffer_length (gsub_buffer b i len))] val buffer_live_gsub_buffer_equiv (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_live h (gsub_buffer b i len) <==> buffer_live h b))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_live_gsub_buffer_intro (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (buffer_live h b /\ UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b i len))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_unused_in_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_unused_in (gsub_buffer b i len) h <==> buffer_unused_in b h))) [SMTPat (buffer_unused_in (gsub_buffer b i len) h)] val gsub_buffer_gsub_buffer (#a: typ) (b: buffer a) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 )) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\ gsub_buffer (gsub_buffer b i1 len1) i2 len2 == gsub_buffer b FStar.UInt32.(i1 +^ i2) len2 )) [SMTPat (gsub_buffer (gsub_buffer b i1 len1) i2 len2)] val gsub_buffer_zero_buffer_length (#a: typ) (b: buffer a) : Lemma (ensures (gsub_buffer b 0ul (buffer_length b) == b)) [SMTPat (gsub_buffer b 0ul (buffer_length b))] val buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : GTot (Seq.seq (type_of_typ t)) val buffer_length_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires True) (ensures (Seq.length (buffer_as_seq h b) == UInt32.v (buffer_length b))) [SMTPat (Seq.length (buffer_as_seq h b))] val buffer_as_seq_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (requires True) (ensures (buffer_as_seq h (gsingleton_buffer_of_pointer p) == Seq.create 1 (gread h p))) [SMTPat (buffer_as_seq h (gsingleton_buffer_of_pointer p))] val buffer_as_seq_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray length t)) : Lemma (requires True) (ensures (buffer_as_seq h (gbuffer_of_array_pointer p) == gread h p)) [SMTPat (buffer_as_seq h (gbuffer_of_array_pointer p))] val buffer_as_seq_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_seq h (gsub_buffer b i len) == Seq.slice (buffer_as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))) [SMTPat (buffer_as_seq h (gsub_buffer b i len))] val gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Ghost (pointer t) (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val pointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (pointer t) (requires (fun h -> UInt32.v i < UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h p h' -> UInt32.v i < UInt32.v (buffer_length b) /\ h' == h /\ p == gpointer_of_buffer_cell b i)) val gpointer_of_buffer_cell_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) let gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)] = gpointer_of_buffer_cell_gsub_buffer b i1 len i2 val live_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) (h: HS.mem) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ (live h (gpointer_of_buffer_cell b i) <==> buffer_live h b) )) [SMTPat (live h (gpointer_of_buffer_cell b i))] val gpointer_of_buffer_cell_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < 1)) (ensures (UInt32.v i < 1 /\ gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i == p)) [SMTPat (gpointer_of_buffer_cell (gsingleton_buffer_of_pointer p) i)] val gpointer_of_buffer_cell_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (p: pointer (TArray length t)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i == gcell p i)) [SMTPat (gpointer_of_buffer_cell (gbuffer_of_array_pointer p) i)] val frameOf_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ frameOf (gpointer_of_buffer_cell b i) == frameOf_buffer b)) [SMTPat (frameOf (gpointer_of_buffer_cell b i))] val as_addr_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ as_addr (gpointer_of_buffer_cell b i) == buffer_as_addr b)) [SMTPat (as_addr (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) [SMTPat (gread h (gpointer_of_buffer_cell b i))] val gread_gpointer_of_buffer_cell' (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ gread h (gpointer_of_buffer_cell b i) == Seq.index (buffer_as_seq h b) (UInt32.v i))) val index_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) (i: nat) : Lemma (requires (i < UInt32.v (buffer_length b))) (ensures (i < UInt32.v (buffer_length b) /\ Seq.index (buffer_as_seq h b) i == gread h (gpointer_of_buffer_cell b (UInt32.uint_to_t i)))) [SMTPat (Seq.index (buffer_as_seq h b) i)] val gsingleton_buffer_of_pointer_gcell (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v len )) (ensures ( UInt32.v i < UInt32.v len /\ gsingleton_buffer_of_pointer (gcell p i) == gsub_buffer (gbuffer_of_array_pointer p) i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gcell p i))] val gsingleton_buffer_of_pointer_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires ( UInt32.v i < UInt32.v (buffer_length b) )) (ensures ( UInt32.v i < UInt32.v (buffer_length b) /\ gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i) == gsub_buffer b i 1ul )) [SMTPat (gsingleton_buffer_of_pointer (gpointer_of_buffer_cell b i))] (* The readable permission lifted to buffers. *) val buffer_readable (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_readable_buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires (buffer_readable h b)) (ensures (buffer_live h b)) [SMTPatOr [ [SMTPat (buffer_readable h b)]; [SMTPat (buffer_live h b)]; ]] val buffer_readable_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (ensures (buffer_readable h (gsingleton_buffer_of_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gsingleton_buffer_of_pointer p))] val buffer_readable_gbuffer_of_array_pointer (#len: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_readable h (gbuffer_of_array_pointer p) <==> readable h p)) [SMTPat (buffer_readable h (gbuffer_of_array_pointer p))] val buffer_readable_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_readable h (gsub_buffer b i len))) [SMTPat (buffer_readable h (gsub_buffer b i len))] val readable_gpointer_of_buffer_cell (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ buffer_readable h b)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ readable h (gpointer_of_buffer_cell b i))) [SMTPat (readable h (gpointer_of_buffer_cell b i))] val buffer_readable_intro (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (ensures (buffer_readable h b)) // [SMTPat (buffer_readable h b)] // TODO: dubious pattern, may trigger unreplayable hints val buffer_readable_elim (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires ( buffer_readable h b )) (ensures ( buffer_live h b /\ ( forall (i: UInt32.t) . UInt32.v i < UInt32.v (buffer_length b) ==> readable h (gpointer_of_buffer_cell b i) ))) (*** The modifies clause *) val loc : Type u#0 val loc_none: loc val loc_union (s1 s2: loc) : GTot loc (** The following is useful to make Z3 cut matching loops with modifies_trans and modifies_refl *) val loc_union_idem (s: loc) : Lemma (loc_union s s == s) [SMTPat (loc_union s s)] val loc_pointer (#t: typ) (p: pointer t) : GTot loc val loc_buffer (#t: typ) (b: buffer t) : GTot loc val loc_addresses (r: HS.rid) (n: Set.set nat) : GTot loc val loc_regions (r: Set.set HS.rid) : GTot loc (* Inclusion of memory locations *) val loc_includes (s1 s2: loc) : GTot Type0 val loc_includes_refl (s: loc) : Lemma (loc_includes s s) [SMTPat (loc_includes s s)] val loc_includes_trans (s1 s2 s3: loc) : Lemma (requires (loc_includes s1 s2 /\ loc_includes s2 s3)) (ensures (loc_includes s1 s3)) val loc_includes_union_r (s s1 s2: loc) : Lemma (requires (loc_includes s s1 /\ loc_includes s s2)) (ensures (loc_includes s (loc_union s1 s2))) [SMTPat (loc_includes s (loc_union s1 s2))] val loc_includes_union_l (s1 s2 s: loc) : Lemma (requires (loc_includes s1 s \/ loc_includes s2 s)) (ensures (loc_includes (loc_union s1 s2) s)) [SMTPat (loc_includes (loc_union s1 s2) s)] val loc_includes_none (s: loc) : Lemma (loc_includes s loc_none) [SMTPat (loc_includes s loc_none)] val loc_includes_pointer_pointer (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Lemma (requires (includes p1 p2)) (ensures (loc_includes (loc_pointer p1) (loc_pointer p2))) [SMTPat (loc_includes (loc_pointer p1) (loc_pointer p2))] val loc_includes_gsingleton_buffer_of_pointer (l: loc) (#t: typ) (p: pointer t) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gsingleton_buffer_of_pointer p)))] val loc_includes_gbuffer_of_array_pointer (l: loc) (#len: array_length_t) (#t: typ) (p: pointer (TArray len t)) : Lemma (requires (loc_includes l (loc_pointer p))) (ensures (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))) [SMTPat (loc_includes l (loc_buffer (gbuffer_of_array_pointer p)))] val loc_includes_gpointer_of_array_cell (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_includes l (loc_pointer (gpointer_of_buffer_cell b i)))] val loc_includes_gsub_buffer_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ loc_includes l (loc_buffer (gsub_buffer b i len)))) [SMTPat (loc_includes l (loc_buffer (gsub_buffer b i len)))] val loc_includes_gsub_buffer_l (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1)) (ensures (UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1 /\ loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))) [SMTPat (loc_includes (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_includes_addresses_pointer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: pointer t) : Lemma (requires (frameOf p == r /\ Set.mem (as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_pointer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_pointer p))] val loc_includes_addresses_buffer (#t: typ) (r: HS.rid) (s: Set.set nat) (p: buffer t) : Lemma (requires (frameOf_buffer p == r /\ Set.mem (buffer_as_addr p) s)) (ensures (loc_includes (loc_addresses r s) (loc_buffer p))) [SMTPat (loc_includes (loc_addresses r s) (loc_buffer p))] val loc_includes_region_pointer (#t: typ) (s: Set.set HS.rid) (p: pointer t) : Lemma (requires (Set.mem (frameOf p) s)) (ensures (loc_includes (loc_regions s) (loc_pointer p))) [SMTPat (loc_includes (loc_regions s) (loc_pointer p))] val loc_includes_region_buffer (#t: typ) (s: Set.set HS.rid) (b: buffer t) : Lemma (requires (Set.mem (frameOf_buffer b) s)) (ensures (loc_includes (loc_regions s) (loc_buffer b))) [SMTPat (loc_includes (loc_regions s) (loc_buffer b))] val loc_includes_region_addresses (s: Set.set HS.rid) (r: HS.rid) (a: Set.set nat) : Lemma (requires (Set.mem r s)) (ensures (loc_includes (loc_regions s) (loc_addresses r a))) [SMTPat (loc_includes (loc_regions s) (loc_addresses r a))] val loc_includes_region_region (s1 s2: Set.set HS.rid) : Lemma (requires (Set.subset s2 s1)) (ensures (loc_includes (loc_regions s1) (loc_regions s2))) [SMTPat (loc_includes (loc_regions s1) (loc_regions s2))] val loc_includes_region_union_l (l: loc) (s1 s2: Set.set HS.rid) : Lemma (requires (loc_includes l (loc_regions (Set.intersect s2 (Set.complement s1))))) (ensures (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))) [SMTPat (loc_includes (loc_union (loc_regions s1) l) (loc_regions s2))] (* Disjointness of two memory locations *) val loc_disjoint (s1 s2: loc) : GTot Type0 val loc_disjoint_sym (s1 s2: loc) : Lemma (requires (loc_disjoint s1 s2)) (ensures (loc_disjoint s2 s1)) [SMTPat (loc_disjoint s1 s2)] val loc_disjoint_none_r (s: loc) : Lemma (ensures (loc_disjoint s loc_none)) [SMTPat (loc_disjoint s loc_none)] val loc_disjoint_union_r (s s1 s2: loc) : Lemma (requires (loc_disjoint s s1 /\ loc_disjoint s s2)) (ensures (loc_disjoint s (loc_union s1 s2))) [SMTPat (loc_disjoint s (loc_union s1 s2))] val loc_disjoint_root (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) val loc_disjoint_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd1 fd2: struct_field l) : Lemma (requires (fd1 <> fd2)) (ensures (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))) [SMTPat (loc_disjoint (loc_pointer (gfield p fd1)) (loc_pointer (gfield p fd2)))] val loc_disjoint_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ UInt32.v i1 <> UInt32.v i2 )) (ensures ( UInt32.v i1 < UInt32.v length /\ UInt32.v i2 < UInt32.v length /\ loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)) )) [SMTPat (loc_disjoint (loc_pointer (gcell p i1)) (loc_pointer (gcell p i2)))] val loc_disjoint_includes (p1 p2 p1' p2' : loc) : Lemma (requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2)) (ensures (loc_disjoint p1' p2')) (* TODO: The following is now wrong, should be replaced with readable val live_not_equal_disjoint (#t: typ) (h: HS.mem) (p1 p2: pointer t) : Lemma (requires (live h p1 /\ live h p2 /\ equal p1 p2 == false)) (ensures (disjoint p1 p2)) *) val live_unused_in_disjoint_strong (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 <> as_addr p2)) val live_unused_in_disjoint (#value1: typ) (#value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_pointer p2))) [SMTPatOr [ [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (live h p1)]; [SMTPat (loc_disjoint (loc_pointer p1) (loc_pointer p2)); SMTPat (unused_in p2 h)]; [SMTPat (live h p1); SMTPat (unused_in p2 h)]; ]] val pointer_live_reference_unused_in_disjoint (#value1: typ) (#value2: Type0) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ HS.unused_in p2 h)) (ensures (loc_disjoint (loc_pointer p1) (loc_addresses (HS.frameOf p2) (Set.singleton (HS.as_addr p2))))) [SMTPat (live h p1); SMTPat (HS.unused_in p2 h)] val reference_live_pointer_unused_in_disjoint (#value1: Type0) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ unused_in p2 h)) (ensures (loc_disjoint (loc_addresses (HS.frameOf p1) (Set.singleton (HS.as_addr p1))) (loc_pointer p2))) [SMTPat (HS.contains h p1); SMTPat (unused_in p2 h)] val loc_disjoint_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ ( UInt32.v i1 + UInt32.v len1 <= UInt32.v i2 \/ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 ))) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)) )) [SMTPat (loc_disjoint (loc_buffer (gsub_buffer b i1 len1)) (loc_buffer (gsub_buffer b i2 len2)))] val loc_disjoint_gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i1: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ ( UInt32.v i1 <> UInt32.v i2 ))) (ensures ( UInt32.v i1 < UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)) )) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i1)) (loc_pointer (gpointer_of_buffer_cell b i2)))] let loc_disjoint_gpointer_of_buffer_cell_r (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_buffer b))) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))) [SMTPat (loc_disjoint l (loc_pointer (gpointer_of_buffer_cell b i)))] = loc_disjoint_includes l (loc_buffer b) l (loc_pointer (gpointer_of_buffer_cell b i)) let loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l))
false
false
FStar.Pointer.Base.fsti
{ "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 loc_disjoint_gpointer_of_buffer_cell_l (l: loc) (#t: typ) (b: buffer t) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_buffer b) l)) (ensures (UInt32.v i < UInt32.v (buffer_length b) /\ loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)) [SMTPat (loc_disjoint (loc_pointer (gpointer_of_buffer_cell b i)) l)]
[]
FStar.Pointer.Base.loc_disjoint_gpointer_of_buffer_cell_l
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: FStar.Pointer.Base.loc -> b: FStar.Pointer.Base.buffer t -> i: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires FStar.UInt32.v i < FStar.UInt32.v (FStar.Pointer.Base.buffer_length b) /\ FStar.Pointer.Base.loc_disjoint (FStar.Pointer.Base.loc_buffer b) l) (ensures FStar.UInt32.v i < FStar.UInt32.v (FStar.Pointer.Base.buffer_length b) /\ FStar.Pointer.Base.loc_disjoint (FStar.Pointer.Base.loc_pointer (FStar.Pointer.Base.gpointer_of_buffer_cell b i)) l) [ SMTPat (FStar.Pointer.Base.loc_disjoint (FStar.Pointer.Base.loc_pointer (FStar.Pointer.Base.gpointer_of_buffer_cell b i)) l) ]
{ "end_col": 86, "end_line": 1916, "start_col": 2, "start_line": 1916 }
FStar.Pervasives.Lemma
val gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1 len i2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len)) (ensures (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2))) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)]
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST // for := , !", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HH" }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pointer", "short_module": null }, { "abbrev": 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 gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)] = gpointer_of_buffer_cell_gsub_buffer b i1 len i2
val gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1 len i2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len)) (ensures (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2))) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)] let gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1 len i2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len)) (ensures (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2))) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)] =
false
null
true
gpointer_of_buffer_cell_gsub_buffer b i1 len i2
{ "checked_file": "FStar.Pointer.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.ModifiesGen.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Pointer.Base.fsti" }
[ "lemma" ]
[ "FStar.Pointer.Base.typ", "FStar.Pointer.Base.buffer", "FStar.UInt32.t", "FStar.Pointer.Base.gpointer_of_buffer_cell_gsub_buffer", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.UInt32.v", "FStar.Pointer.Base.buffer_length", "Prims.op_LessThan", "Prims.squash", "Prims.eq2", "FStar.Pointer.Base.pointer", "FStar.Pointer.Base.gpointer_of_buffer_cell", "FStar.Pointer.Base.gsub_buffer", "FStar.UInt32.op_Plus_Hat", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Pointer.Base module HH = FStar.HyperStack module HS = FStar.HyperStack module HST = FStar.HyperStack.ST open FStar.HyperStack.ST // for := , ! (*** Definitions *) (** Type codes *) type base_typ = | TUInt | TUInt8 | TUInt16 | TUInt32 | TUInt64 | TInt | TInt8 | TInt16 | TInt32 | TInt64 | TChar | TBool | TUnit // C11, Sect. 6.2.5 al. 20: arrays must be nonempty type array_length_t = (length: UInt32.t { UInt32.v length > 0 } ) type typ = | TBase: (b: base_typ) -> typ | TStruct: (l: struct_typ) -> typ | TUnion: (l: union_typ) -> typ | TArray: (length: array_length_t ) -> (t: typ) -> typ | TPointer: (t: typ) -> typ | TNPointer: (t: typ) -> typ | TBuffer: (t: typ) -> typ and struct_typ' = (l: list (string * typ) { Cons? l /\ // C11, 6.2.5 al. 20: structs and unions must have at least one field List.Tot.noRepeats (List.Tot.map fst l) }) and struct_typ = { name: string; fields: struct_typ' ; } and union_typ = struct_typ (** `struct_field l` is the type of fields of `TStruct l` (i.e. a refinement of `string`). *) let struct_field' (l: struct_typ') : Tot eqtype = (s: string { List.Tot.mem s (List.Tot.map fst l) } ) let struct_field (l: struct_typ) : Tot eqtype = struct_field' l.fields (** `union_field l` is the type of fields of `TUnion l` (i.e. a refinement of `string`). *) let union_field = struct_field (** `typ_of_struct_field l f` is the type of data associated with field `f` in `TStruct l` (i.e. a refinement of `typ`). *) let typ_of_struct_field' (l: struct_typ') (f: struct_field' l) : Tot (t: typ {t << l}) = List.Tot.assoc_mem f l; let y = Some?.v (List.Tot.assoc f l) in List.Tot.assoc_precedes f l y; y let typ_of_struct_field (l: struct_typ) (f: struct_field l) : Tot (t: typ {t << l}) = typ_of_struct_field' l.fields f (** `typ_of_union_field l f` is the type of data associated with field `f` in `TUnion l` (i.e. a refinement of `typ`). *) let typ_of_union_field (l: union_typ) (f: union_field l) : Tot (t: typ {t << l}) = typ_of_struct_field l f let rec typ_depth (t: typ) : GTot nat = match t with | TArray _ t -> 1 + typ_depth t | TUnion l | TStruct l -> 1 + struct_typ_depth l.fields | _ -> 0 and struct_typ_depth (l: list (string * typ)) : GTot nat = match l with | [] -> 0 | h :: l -> let (_, t) = h in // matching like this prevents needing two units of ifuel let n1 = typ_depth t in let n2 = struct_typ_depth l in if n1 > n2 then n1 else n2 let rec typ_depth_typ_of_struct_field (l: struct_typ') (f: struct_field' l) : Lemma (ensures (typ_depth (typ_of_struct_field' l f) <= struct_typ_depth l)) (decreases l) = let ((f', _) :: l') = l in if f = f' then () else begin let f: string = f in assert (List.Tot.mem f (List.Tot.map fst l')); List.Tot.assoc_mem f l'; typ_depth_typ_of_struct_field l' f end (** Pointers to data of type t. This defines two main types: - `npointer (t: typ)`, a pointer that may be "NULL"; - `pointer (t: typ)`, a pointer that cannot be "NULL" (defined as a refinement of `npointer`). `nullptr #t` (of type `npointer t`) represents the "NULL" value. *) val npointer (t: typ) : Tot Type0 (** The null pointer *) val nullptr (#t: typ): Tot (npointer t) val g_is_null (#t: typ) (p: npointer t) : GTot bool val g_is_null_intro (t: typ) : Lemma (g_is_null (nullptr #t) == true) [SMTPat (g_is_null (nullptr #t))] // concrete, for subtyping let pointer (t: typ) : Tot Type0 = (p: npointer t { g_is_null p == false } ) (** Buffers *) val buffer (t: typ): Tot Type0 (** Interpretation of type codes. Defines functions mapping from type codes (`typ`) to their interpretation as FStar types. For example, `type_of_typ (TBase TUInt8)` is `FStar.UInt8.t`. *) (** Interpretation of base types. *) let type_of_base_typ (t: base_typ) : Tot Type0 = match t with | TUInt -> nat | TUInt8 -> FStar.UInt8.t | TUInt16 -> FStar.UInt16.t | TUInt32 -> FStar.UInt32.t | TUInt64 -> FStar.UInt64.t | TInt -> int | TInt8 -> FStar.Int8.t | TInt16 -> FStar.Int16.t | TInt32 -> FStar.Int32.t | TInt64 -> FStar.Int64.t | TChar -> FStar.Char.char | TBool -> bool | TUnit -> unit (** Interpretation of arrays of elements of (interpreted) type `t`. *) type array (length: array_length_t) (t: Type) = (s: Seq.seq t {Seq.length s == UInt32.v length}) let type_of_struct_field'' (l: struct_typ') (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field' l) : Tot Type0 = List.Tot.assoc_mem f l; let y = typ_of_struct_field' l f in List.Tot.assoc_precedes f l y; type_of_typ y [@@ unifier_hint_injective] let type_of_struct_field' (l: struct_typ) (type_of_typ: ( (t: typ { t << l } ) -> Tot Type0 )) (f: struct_field l) : Tot Type0 = type_of_struct_field'' l.fields type_of_typ f val struct (l: struct_typ) : Tot Type0 val union (l: union_typ) : Tot Type0 (* Interprets a type code (`typ`) as a FStar type (`Type0`). *) let rec type_of_typ (t: typ) : Tot Type0 = match t with | TBase b -> type_of_base_typ b | TStruct l -> struct l | TUnion l -> union l | TArray length t -> array length (type_of_typ t) | TPointer t -> pointer t | TNPointer t -> npointer t | TBuffer t -> buffer t let type_of_typ_array (len: array_length_t) (t: typ) : Lemma (type_of_typ (TArray len t) == array len (type_of_typ t)) [SMTPat (type_of_typ (TArray len t))] = () let type_of_struct_field (l: struct_typ) : Tot (struct_field l -> Tot Type0) = type_of_struct_field' l (fun (x:typ{x << l}) -> type_of_typ x) let type_of_typ_struct (l: struct_typ) : Lemma (type_of_typ (TStruct l) == struct l) [SMTPat (type_of_typ (TStruct l))] = assert_norm (type_of_typ (TStruct l) == struct l) let type_of_typ_type_of_struct_field (l: struct_typ) (f: struct_field l) : Lemma (type_of_typ (typ_of_struct_field l f) == type_of_struct_field l f) [SMTPat (type_of_typ (typ_of_struct_field l f))] = () val struct_sel (#l: struct_typ) (s: struct l) (f: struct_field l) : Tot (type_of_struct_field l f) let dfst_struct_field (s: struct_typ) (p: (x: struct_field s & type_of_struct_field s x)) : Tot string = let (| f, _ |) = p in f let struct_literal (s: struct_typ) : Tot Type0 = list (x: struct_field s & type_of_struct_field s x) let struct_literal_wf (s: struct_typ) (l: struct_literal s) : Tot bool = List.Tot.sortWith FStar.String.compare (List.Tot.map fst s.fields) = List.Tot.sortWith FStar.String.compare (List.Tot.map (dfst_struct_field s) l) let fun_of_list (s: struct_typ) (l: struct_literal s) (f: struct_field s) : Pure (type_of_struct_field s f) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = let f' : string = f in let phi (p: (x: struct_field s & type_of_struct_field s x)) : Tot bool = dfst_struct_field s p = f' in match List.Tot.find phi l with | Some p -> let (| _, v |) = p in v | _ -> List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map fst s.fields); List.Tot.sortWith_permutation FStar.String.compare (List.Tot.map (dfst_struct_field s) l); List.Tot.mem_memP f' (List.Tot.map fst s.fields); List.Tot.mem_count (List.Tot.map fst s.fields) f'; List.Tot.mem_count (List.Tot.map (dfst_struct_field s) l) f'; List.Tot.mem_memP f' (List.Tot.map (dfst_struct_field s) l); List.Tot.memP_map_elim (dfst_struct_field s) f' l; Classical.forall_intro (Classical.move_requires (List.Tot.find_none phi l)); false_elim () val struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) : Tot (struct l) let struct_create (s: struct_typ) (l: struct_literal s) : Pure (struct s) (requires (normalize_term (struct_literal_wf s l) == true)) (ensures (fun _ -> True)) = struct_create_fun s (fun_of_list s l) val struct_sel_struct_create_fun (l: struct_typ) (f: ((fd: struct_field l) -> Tot (type_of_struct_field l fd))) (fd: struct_field l) : Lemma (struct_sel (struct_create_fun l f) fd == f fd) [SMTPat (struct_sel (struct_create_fun l f) fd)] let type_of_typ_union (l: union_typ) : Lemma (type_of_typ (TUnion l) == union l) [SMTPat (type_of_typ (TUnion l))] = assert_norm (type_of_typ (TUnion l) == union l) val union_get_key (#l: union_typ) (v: union l) : GTot (struct_field l) val union_get_value (#l: union_typ) (v: union l) (fd: struct_field l) : Pure (type_of_struct_field l fd) (requires (union_get_key v == fd)) (ensures (fun _ -> True)) val union_create (l: union_typ) (fd: struct_field l) (v: type_of_struct_field l fd) : Tot (union l) (*** Semantics of pointers *) (** Operations on pointers *) val equal (#t1 #t2: typ) (p1: pointer t1) (p2: pointer t2) : Ghost bool (requires True) (ensures (fun b -> b == true <==> t1 == t2 /\ p1 == p2 )) val as_addr (#t: typ) (p: pointer t): GTot (x: nat { x > 0 } ) val unused_in (#value: typ) (p: pointer value) (h: HS.mem) : GTot Type0 val live (#value: typ) (h: HS.mem) (p: pointer value) : GTot Type0 val nlive (#value: typ) (h: HS.mem) (p: npointer value) : GTot Type0 val live_nlive (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (nlive h p <==> live h p) [SMTPat (nlive h p)] val g_is_null_nlive (#t: typ) (h: HS.mem) (p: npointer t) : Lemma (requires (g_is_null p)) (ensures (nlive h p)) [SMTPat (g_is_null p); SMTPat (nlive h p)] val live_not_unused_in (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (ensures (live h p /\ p `unused_in` h ==> False)) [SMTPat (live h p); SMTPat (p `unused_in` h)] val gread (#value: typ) (h: HS.mem) (p: pointer value) : GTot (type_of_typ value) val frameOf (#value: typ) (p: pointer value) : GTot HS.rid val live_region_frameOf (#value: typ) (h: HS.mem) (p: pointer value) : Lemma (requires (live h p)) (ensures (HS.live_region h (frameOf p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf p))]; [SMTPat (live h p)] ]] val disjoint_roots_intro_pointer_vs_pointer (#value1 value2: typ) (h: HS.mem) (p1: pointer value1) (p2: pointer value2) : Lemma (requires (live h p1 /\ unused_in p2 h)) (ensures (frameOf p1 <> frameOf p2 \/ as_addr p1 =!= as_addr p2)) val disjoint_roots_intro_pointer_vs_reference (#value1: typ) (#value2: Type) (h: HS.mem) (p1: pointer value1) (p2: HS.reference value2) : Lemma (requires (live h p1 /\ p2 `HS.unused_in` h)) (ensures (frameOf p1 <> HS.frameOf p2 \/ as_addr p1 =!= HS.as_addr p2)) val disjoint_roots_intro_reference_vs_pointer (#value1: Type) (#value2: typ) (h: HS.mem) (p1: HS.reference value1) (p2: pointer value2) : Lemma (requires (HS.contains h p1 /\ p2 `unused_in` h)) (ensures (HS.frameOf p1 <> frameOf p2 \/ HS.as_addr p1 =!= as_addr p2)) val is_mm (#value: typ) (p: pointer value) : GTot bool (* // TODO: recover with addresses? val recall (#value: Type) (p: pointer value {is_eternal_region (frameOf p) && not (is_mm p)}) : HST.Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 p)) *) val gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gfield p fd) == as_addr p)) [SMTPat (as_addr (gfield p fd))] val unused_in_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gfield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gfield p fd) h)] val live_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gfield p fd) <==> live h p)) [SMTPat (live h (gfield p fd))] val gread_gfield (h: HS.mem) (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (gread h (gfield p fd) == struct_sel (gread h p) fd)) [SMTPatOr [[SMTPat (gread h (gfield p fd))]; [SMTPat (struct_sel (gread h p) fd)]]] val frameOf_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gfield p fd) == frameOf p)) [SMTPat (frameOf (gfield p fd))] val is_mm_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gfield p fd) <==> is_mm p)) [SMTPat (is_mm (gfield p fd))] val gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : GTot (pointer (typ_of_struct_field l fd)) val as_addr_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (as_addr (gufield p fd) == as_addr p)) [SMTPat (as_addr (gufield p fd))] val unused_in_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) (h: HS.mem) : Lemma (requires True) (ensures (unused_in (gufield p fd) h <==> unused_in p h)) [SMTPat (unused_in (gufield p fd) h)] val live_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (live h (gufield p fd) <==> live h p)) [SMTPat (live h (gufield p fd))] val gread_gufield (h: HS.mem) (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (union_get_key (gread h p) == fd)) (ensures ( union_get_key (gread h p) == fd /\ gread h (gufield p fd) == union_get_value (gread h p) fd )) [SMTPatOr [[SMTPat (gread h (gufield p fd))]; [SMTPat (union_get_value (gread h p) fd)]]] val frameOf_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (frameOf (gufield p fd) == frameOf p)) [SMTPat (frameOf (gufield p fd))] val is_mm_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (is_mm (gufield p fd) <==> is_mm p)) [SMTPat (is_mm (gufield p fd))] val gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Ghost (pointer value) (requires (UInt32.v i < UInt32.v length)) (ensures (fun _ -> True)) val as_addr_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ as_addr (gcell p i) == as_addr p)) [SMTPat (as_addr (gcell p i))] val unused_in_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (unused_in (gcell p i) h <==> unused_in p h))) [SMTPat (unused_in (gcell p i) h)] val live_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ (live h (gcell p i) <==> live h p))) [SMTPat (live h (gcell p i))] val gread_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ gread h (gcell p i) == Seq.index (gread h p) (UInt32.v i))) [SMTPat (gread h (gcell p i))] val frameOf_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ frameOf (gcell p i) == frameOf p)) [SMTPat (frameOf (gcell p i))] val is_mm_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ is_mm (gcell p i) == is_mm p)) [SMTPat (is_mm (gcell p i))] val includes (#value1: typ) (#value2: typ) (p1: pointer value1) (p2: pointer value2) : GTot bool val includes_refl (#t: typ) (p: pointer t) : Lemma (ensures (includes p p)) [SMTPat (includes p p)] val includes_trans (#t1 #t2 #t3: typ) (p1: pointer t1) (p2: pointer t2) (p3: pointer t3) : Lemma (requires (includes p1 p2 /\ includes p2 p3)) (ensures (includes p1 p3)) val includes_gfield (#l: struct_typ) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gfield p fd))) val includes_gufield (#l: union_typ) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (includes p (gufield p fd))) val includes_gcell (#length: array_length_t) (#value: typ) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length)) (ensures (UInt32.v i < UInt32.v length /\ includes p (gcell p i))) (** The readable permission. We choose to implement it only abstractly, instead of explicitly tracking the permission in the heap. *) val readable (#a: typ) (h: HS.mem) (b: pointer a) : GTot Type0 val readable_live (#a: typ) (h: HS.mem) (b: pointer a) : Lemma (requires (readable h b)) (ensures (live h b)) [SMTPatOr [ [SMTPat (readable h b)]; [SMTPat (live h b)]; ]] val readable_gfield (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (fd: struct_field l) : Lemma (requires (readable h p)) (ensures (readable h (gfield p fd))) [SMTPat (readable h (gfield p fd))] val readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires ( forall (f: struct_field l) . readable h (gfield p f) )) (ensures (readable h p)) // [SMTPat (readable #(TStruct l) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints val readable_struct_forall_mem (#l: struct_typ) (p: pointer (TStruct l)) : Lemma (forall (h: HS.mem) . ( forall (f: struct_field l) . readable h (gfield p f) ) ==> readable h p ) val readable_struct_fields (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (s: list string) : GTot Type0 val readable_struct_fields_nil (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (readable_struct_fields h p []) [SMTPat (readable_struct_fields h p [])] val readable_struct_fields_cons (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) (f: string) (q: list string) : Lemma (requires (readable_struct_fields h p q /\ (List.Tot.mem f (List.Tot.map fst l.fields) ==> (let f : struct_field l = f in readable h (gfield p f))))) (ensures (readable_struct_fields h p (f::q))) [SMTPat (readable_struct_fields h p (f::q))] val readable_struct_fields_readable_struct (#l: struct_typ) (h: HS.mem) (p: pointer (TStruct l)) : Lemma (requires (readable_struct_fields h p (normalize_term (List.Tot.map fst l.fields)))) (ensures (readable h p)) val readable_gcell (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) (i: UInt32.t) : Lemma (requires (UInt32.v i < UInt32.v length /\ readable h p)) (ensures (UInt32.v i < UInt32.v length /\ readable h (gcell p i))) [SMTPat (readable h (gcell p i))] val readable_array (#length: array_length_t) (#value: typ) (h: HS.mem) (p: pointer (TArray length value)) : Lemma (requires ( forall (i: UInt32.t) . UInt32.v i < UInt32.v length ==> readable h (gcell p i) )) (ensures (readable h p)) // [SMTPat (readable #(TArray length value) h p)] // TODO: dubious pattern, will probably trigger unreplayable hints (* TODO: improve on the following interface *) val readable_gufield (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires True) (ensures (readable h (gufield p fd) <==> (readable h p /\ union_get_key (gread h p) == fd))) [SMTPat (readable h (gufield p fd))] (** The active field of a union *) val is_active_union_field (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : GTot Type0 val is_active_union_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h p)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_live (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (live h (gufield p fd))) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_eq (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd1 fd2: struct_field l) : Lemma (requires (is_active_union_field h p fd1 /\ is_active_union_field h p fd2)) (ensures (fd1 == fd2)) [SMTPat (is_active_union_field h p fd1); SMTPat (is_active_union_field h p fd2)] val is_active_union_field_get_key (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd)) (ensures (union_get_key (gread h p) == fd)) [SMTPat (is_active_union_field h p fd)] val is_active_union_field_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) : Lemma (requires (is_active_union_field h p fd /\ readable h (gufield p fd))) (ensures (readable h p)) [SMTPat (is_active_union_field h p fd); SMTPat (readable h (gufield p fd))] val is_active_union_field_includes_readable (#l: union_typ) (h: HS.mem) (p: pointer (TUnion l)) (fd: struct_field l) (#t': typ) (p' : pointer t') : Lemma (requires (includes (gufield p fd) p' /\ readable h p')) (ensures (is_active_union_field h p fd)) (* Equality predicate on struct contents, without quantifiers *) let equal_values #a h (b:pointer a) h' (b':pointer a) : GTot Type0 = (live h b ==> live h' b') /\ ( readable h b ==> ( readable h' b' /\ gread h b == gread h' b' )) (*** Semantics of buffers *) (** Operations on buffers *) val gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : GTot (buffer t) val singleton_buffer_of_pointer (#t: typ) (p: pointer t) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gsingleton_buffer_of_pointer p)) val gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : GTot (buffer t) val buffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : HST.Stack (buffer t) (requires (fun h -> live h p)) (ensures (fun h b h' -> h' == h /\ b == gbuffer_of_array_pointer p)) val buffer_length (#t: typ) (b: buffer t) : GTot UInt32.t val buffer_length_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (requires True) (ensures (buffer_length (gsingleton_buffer_of_pointer p) == 1ul)) [SMTPat (buffer_length (gsingleton_buffer_of_pointer p))] val buffer_length_gbuffer_of_array_pointer (#t: typ) (#len: array_length_t) (p: pointer (TArray len t)) : Lemma (requires True) (ensures (buffer_length (gbuffer_of_array_pointer p) == len)) [SMTPat (buffer_length (gbuffer_of_array_pointer p))] val buffer_live (#t: typ) (h: HS.mem) (b: buffer t) : GTot Type0 val buffer_live_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_live h (gsingleton_buffer_of_pointer p) <==> live h p )) [SMTPat (buffer_live h (gsingleton_buffer_of_pointer p))] val buffer_live_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_live h (gbuffer_of_array_pointer p) <==> live h p)) [SMTPat (buffer_live h (gbuffer_of_array_pointer p))] val buffer_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : GTot Type0 val buffer_live_not_unused_in (#t: typ) (b: buffer t) (h: HS.mem) : Lemma ((buffer_live h b /\ buffer_unused_in b h) ==> False) val buffer_unused_in_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) (h: HS.mem) : Lemma (ensures (buffer_unused_in (gsingleton_buffer_of_pointer p) h <==> unused_in p h )) [SMTPat (buffer_unused_in (gsingleton_buffer_of_pointer p) h)] val buffer_unused_in_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) (h: HS.mem) : Lemma (requires True) (ensures (buffer_unused_in (gbuffer_of_array_pointer p) h <==> unused_in p h)) [SMTPat (buffer_unused_in (gbuffer_of_array_pointer p) h)] val frameOf_buffer (#t: typ) (b: buffer t) : GTot HS.rid val frameOf_buffer_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (frameOf_buffer (gsingleton_buffer_of_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gsingleton_buffer_of_pointer p))] val frameOf_buffer_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (frameOf_buffer (gbuffer_of_array_pointer p) == frameOf p)) [SMTPat (frameOf_buffer (gbuffer_of_array_pointer p))] val live_region_frameOf_buffer (#value: typ) (h: HS.mem) (p: buffer value) : Lemma (requires (buffer_live h p)) (ensures (HS.live_region h (frameOf_buffer p))) [SMTPatOr [ [SMTPat (HS.live_region h (frameOf_buffer p))]; [SMTPat (buffer_live h p)] ]] val buffer_as_addr (#t: typ) (b: buffer t) : GTot (x: nat { x > 0 } ) val buffer_as_addr_gsingleton_buffer_of_pointer (#t: typ) (p: pointer t) : Lemma (ensures (buffer_as_addr (gsingleton_buffer_of_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gsingleton_buffer_of_pointer p))] val buffer_as_addr_gbuffer_of_array_pointer (#t: typ) (#length: array_length_t) (p: pointer (TArray length t)) : Lemma (ensures (buffer_as_addr (gbuffer_of_array_pointer p) == as_addr p)) [SMTPat (buffer_as_addr (gbuffer_of_array_pointer p))] val gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Ghost (buffer t) (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val frameOf_buffer_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ frameOf_buffer (gsub_buffer b i len) == frameOf_buffer b )) [SMTPat (frameOf_buffer (gsub_buffer b i len))] val buffer_as_addr_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures ( UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_addr (gsub_buffer b i len) == buffer_as_addr b )) [SMTPat (buffer_as_addr (gsub_buffer b i len))] val sub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i len )) val offset_buffer (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (buffer t) (requires (fun h -> UInt32.v i <= UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h b' h' -> UInt32.v i <= UInt32.v (buffer_length b) /\ h' == h /\ b' == gsub_buffer b i (UInt32.sub (buffer_length b) i))) val buffer_length_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_length (gsub_buffer b i len) == len)) [SMTPat (buffer_length (gsub_buffer b i len))] val buffer_live_gsub_buffer_equiv (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_live h (gsub_buffer b i len) <==> buffer_live h b))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_live_gsub_buffer_intro (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (buffer_live h b /\ UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_live h (gsub_buffer b i len))) [SMTPat (buffer_live h (gsub_buffer b i len))] val buffer_unused_in_gsub_buffer (#t: typ) (b: buffer t) (i: UInt32.t) (len: UInt32.t) (h: HS.mem) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ (buffer_unused_in (gsub_buffer b i len) h <==> buffer_unused_in b h))) [SMTPat (buffer_unused_in (gsub_buffer b i len) h)] val gsub_buffer_gsub_buffer (#a: typ) (b: buffer a) (i1: UInt32.t) (len1: UInt32.t) (i2: UInt32.t) (len2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 )) (ensures ( UInt32.v i1 + UInt32.v len1 <= UInt32.v (buffer_length b) /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\ gsub_buffer (gsub_buffer b i1 len1) i2 len2 == gsub_buffer b FStar.UInt32.(i1 +^ i2) len2 )) [SMTPat (gsub_buffer (gsub_buffer b i1 len1) i2 len2)] val gsub_buffer_zero_buffer_length (#a: typ) (b: buffer a) : Lemma (ensures (gsub_buffer b 0ul (buffer_length b) == b)) [SMTPat (gsub_buffer b 0ul (buffer_length b))] val buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : GTot (Seq.seq (type_of_typ t)) val buffer_length_buffer_as_seq (#t: typ) (h: HS.mem) (b: buffer t) : Lemma (requires True) (ensures (Seq.length (buffer_as_seq h b) == UInt32.v (buffer_length b))) [SMTPat (Seq.length (buffer_as_seq h b))] val buffer_as_seq_gsingleton_buffer_of_pointer (#t: typ) (h: HS.mem) (p: pointer t) : Lemma (requires True) (ensures (buffer_as_seq h (gsingleton_buffer_of_pointer p) == Seq.create 1 (gread h p))) [SMTPat (buffer_as_seq h (gsingleton_buffer_of_pointer p))] val buffer_as_seq_gbuffer_of_array_pointer (#length: array_length_t) (#t: typ) (h: HS.mem) (p: pointer (TArray length t)) : Lemma (requires True) (ensures (buffer_as_seq h (gbuffer_of_array_pointer p) == gread h p)) [SMTPat (buffer_as_seq h (gbuffer_of_array_pointer p))] val buffer_as_seq_gsub_buffer (#t: typ) (h: HS.mem) (b: buffer t) (i: UInt32.t) (len: UInt32.t) : Lemma (requires (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b))) (ensures (UInt32.v i + UInt32.v len <= UInt32.v (buffer_length b) /\ buffer_as_seq h (gsub_buffer b i len) == Seq.slice (buffer_as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))) [SMTPat (buffer_as_seq h (gsub_buffer b i len))] val gpointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : Ghost (pointer t) (requires (UInt32.v i < UInt32.v (buffer_length b))) (ensures (fun _ -> True)) val pointer_of_buffer_cell (#t: typ) (b: buffer t) (i: UInt32.t) : HST.Stack (pointer t) (requires (fun h -> UInt32.v i < UInt32.v (buffer_length b) /\ buffer_live h b)) (ensures (fun h p h' -> UInt32.v i < UInt32.v (buffer_length b) /\ h' == h /\ p == gpointer_of_buffer_cell b i)) val gpointer_of_buffer_cell_gsub_buffer (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) )) let gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1: UInt32.t) (len: UInt32.t) (i2: UInt32.t) : Lemma (requires ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len )) (ensures ( UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2) ))
false
false
FStar.Pointer.Base.fsti
{ "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 gpointer_of_buffer_cell_gsub_buffer' (#t: typ) (b: buffer t) (i1 len i2: UInt32.t) : Lemma (requires (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len)) (ensures (UInt32.v i1 + UInt32.v len <= UInt32.v (buffer_length b) /\ UInt32.v i2 < UInt32.v len /\ gpointer_of_buffer_cell (gsub_buffer b i1 len) i2 == gpointer_of_buffer_cell b FStar.UInt32.(i1 +^ i2))) [SMTPat (gpointer_of_buffer_cell (gsub_buffer b i1 len) i2)]
[]
FStar.Pointer.Base.gpointer_of_buffer_cell_gsub_buffer'
{ "file_name": "ulib/legacy/FStar.Pointer.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: FStar.Pointer.Base.buffer t -> i1: FStar.UInt32.t -> len: FStar.UInt32.t -> i2: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires FStar.UInt32.v i1 + FStar.UInt32.v len <= FStar.UInt32.v (FStar.Pointer.Base.buffer_length b) /\ FStar.UInt32.v i2 < FStar.UInt32.v len) (ensures FStar.UInt32.v i1 + FStar.UInt32.v len <= FStar.UInt32.v (FStar.Pointer.Base.buffer_length b) /\ FStar.UInt32.v i2 < FStar.UInt32.v len /\ FStar.Pointer.Base.gpointer_of_buffer_cell (FStar.Pointer.Base.gsub_buffer b i1 len) i2 == FStar.Pointer.Base.gpointer_of_buffer_cell b (i1 +^ i2)) [ SMTPat (FStar.Pointer.Base.gpointer_of_buffer_cell (FStar.Pointer.Base.gsub_buffer b i1 len) i2) ]
{ "end_col": 49, "end_line": 1329, "start_col": 2, "start_line": 1329 }
FStar.HyperStack.ST.Stack
val test_string (t: test_t) (testname inputstring: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true)
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Printf", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "LowParse.TestLib", "short_module": null }, { "abbrev": false, "full_module": "LowParse.TestLib", "short_module": null }, { "abbrev": 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 test_string (t:test_t) (testname:string) (inputstring:string): Stack unit (fun _ -> true) (fun _ _ _ -> true) = push_frame(); let input = bytes_of_hex inputstring in test_bytes t testname input; pop_frame()
val test_string (t: test_t) (testname inputstring: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true) let test_string (t: test_t) (testname inputstring: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true) =
true
null
false
push_frame (); let input = bytes_of_hex inputstring in test_bytes t testname input; pop_frame ()
{ "checked_file": "LowParse.TestLib.SLow.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.IO.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.TestLib.SLow.fst" }
[]
[ "LowParse.TestLib.SLow.test_t", "Prims.string", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "LowParse.TestLib.SLow.test_bytes", "FStar.Bytes.bytes", "FStar.Bytes.bytes_of_hex", "FStar.HyperStack.ST.push_frame", "FStar.Monotonic.HyperStack.mem", "Prims.b2t" ]
[]
module LowParse.TestLib.SLow open FStar.HyperStack.ST open FStar.Bytes open FStar.HyperStack.IO open FStar.Printf module U32 = FStar.UInt32 #reset-options "--using_facts_from '* -LowParse'" #reset-options "--z3cliopt smt.arith.nl=false" (** The type of a unit test. It takes an input Bytes, parses it, and returns a newly formatted Bytes. Or it returns None if there is a fail to parse. *) type test_t = (input:FStar.Bytes.bytes) -> Stack (option (FStar.Bytes.bytes * U32.t)) (fun _ -> true) (fun _ _ _ -> true) assume val load_file: (filename:string) -> Tot FStar.Bytes.bytes (** Test one parser+formatter pair against an in-memory buffer of Bytes *) let test_bytes (t:test_t) (testname:string) (input:FStar.Bytes.bytes): Stack unit (fun _ -> true) (fun _ _ _ -> true) = push_frame(); print_string (sprintf "==== Testing Bytes %s ====\n" testname); let result = t input in (match result with | Some (formattedresult, offset) -> ( if U32.gt offset (len input) then ( print_string "Invalid length return - it is longer than the input buffer!" ) else ( let inputslice = FStar.Bytes.slice input 0ul offset in if formattedresult = inputslice then print_string "Formatted data matches original input data\n" else ( print_string "FAIL: formatted data does not match original input data\n" ) ) ) | _ -> print_string "Failed to parse\n" ); print_string (sprintf "==== Finished %s ====\n" testname); pop_frame() (** Test one parser+formatter pair against a string of hex bytes, as Bytes *)
false
false
LowParse.TestLib.SLow.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_string (t: test_t) (testname inputstring: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true)
[]
LowParse.TestLib.SLow.test_string
{ "file_name": "src/lowparse/LowParse.TestLib.SLow.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
t: LowParse.TestLib.SLow.test_t -> testname: Prims.string -> inputstring: Prims.string -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 48, "start_col": 2, "start_line": 45 }
FStar.HyperStack.ST.Stack
val test_file (t: test_t) (filename: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true)
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Printf", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "LowParse.TestLib", "short_module": null }, { "abbrev": false, "full_module": "LowParse.TestLib", "short_module": null }, { "abbrev": 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 test_file (t:test_t) (filename:string): Stack unit (fun _ -> true) (fun _ _ _ -> true) = push_frame(); let input = load_file filename in test_bytes t filename input; pop_frame()
val test_file (t: test_t) (filename: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true) let test_file (t: test_t) (filename: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true) =
true
null
false
push_frame (); let input = load_file filename in test_bytes t filename input; pop_frame ()
{ "checked_file": "LowParse.TestLib.SLow.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.IO.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.TestLib.SLow.fst" }
[]
[ "LowParse.TestLib.SLow.test_t", "Prims.string", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "LowParse.TestLib.SLow.test_bytes", "FStar.Bytes.bytes", "LowParse.TestLib.SLow.load_file", "FStar.HyperStack.ST.push_frame", "FStar.Monotonic.HyperStack.mem", "Prims.b2t" ]
[]
module LowParse.TestLib.SLow open FStar.HyperStack.ST open FStar.Bytes open FStar.HyperStack.IO open FStar.Printf module U32 = FStar.UInt32 #reset-options "--using_facts_from '* -LowParse'" #reset-options "--z3cliopt smt.arith.nl=false" (** The type of a unit test. It takes an input Bytes, parses it, and returns a newly formatted Bytes. Or it returns None if there is a fail to parse. *) type test_t = (input:FStar.Bytes.bytes) -> Stack (option (FStar.Bytes.bytes * U32.t)) (fun _ -> true) (fun _ _ _ -> true) assume val load_file: (filename:string) -> Tot FStar.Bytes.bytes (** Test one parser+formatter pair against an in-memory buffer of Bytes *) let test_bytes (t:test_t) (testname:string) (input:FStar.Bytes.bytes): Stack unit (fun _ -> true) (fun _ _ _ -> true) = push_frame(); print_string (sprintf "==== Testing Bytes %s ====\n" testname); let result = t input in (match result with | Some (formattedresult, offset) -> ( if U32.gt offset (len input) then ( print_string "Invalid length return - it is longer than the input buffer!" ) else ( let inputslice = FStar.Bytes.slice input 0ul offset in if formattedresult = inputslice then print_string "Formatted data matches original input data\n" else ( print_string "FAIL: formatted data does not match original input data\n" ) ) ) | _ -> print_string "Failed to parse\n" ); print_string (sprintf "==== Finished %s ====\n" testname); pop_frame() (** Test one parser+formatter pair against a string of hex bytes, as Bytes *) let test_string (t:test_t) (testname:string) (inputstring:string): Stack unit (fun _ -> true) (fun _ _ _ -> true) = push_frame(); let input = bytes_of_hex inputstring in test_bytes t testname input; pop_frame() (** Test one parser+formatter pair against a disk file, as Bytes *)
false
false
LowParse.TestLib.SLow.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_file (t: test_t) (filename: string) : Stack unit (fun _ -> true) (fun _ _ _ -> true)
[]
LowParse.TestLib.SLow.test_file
{ "file_name": "src/lowparse/LowParse.TestLib.SLow.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
t: LowParse.TestLib.SLow.test_t -> filename: Prims.string -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 55, "start_col": 2, "start_line": 52 }
FStar.HyperStack.ST.Stack
val test_bytes (t: test_t) (testname: string) (input: FStar.Bytes.bytes) : Stack unit (fun _ -> true) (fun _ _ _ -> true)
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Printf", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.IO", "short_module": null }, { "abbrev": false, "full_module": "FStar.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "LowParse.TestLib", "short_module": null }, { "abbrev": false, "full_module": "LowParse.TestLib", "short_module": null }, { "abbrev": 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 test_bytes (t:test_t) (testname:string) (input:FStar.Bytes.bytes): Stack unit (fun _ -> true) (fun _ _ _ -> true) = push_frame(); print_string (sprintf "==== Testing Bytes %s ====\n" testname); let result = t input in (match result with | Some (formattedresult, offset) -> ( if U32.gt offset (len input) then ( print_string "Invalid length return - it is longer than the input buffer!" ) else ( let inputslice = FStar.Bytes.slice input 0ul offset in if formattedresult = inputslice then print_string "Formatted data matches original input data\n" else ( print_string "FAIL: formatted data does not match original input data\n" ) ) ) | _ -> print_string "Failed to parse\n" ); print_string (sprintf "==== Finished %s ====\n" testname); pop_frame()
val test_bytes (t: test_t) (testname: string) (input: FStar.Bytes.bytes) : Stack unit (fun _ -> true) (fun _ _ _ -> true) let test_bytes (t: test_t) (testname: string) (input: FStar.Bytes.bytes) : Stack unit (fun _ -> true) (fun _ _ _ -> true) =
true
null
false
push_frame (); print_string (sprintf "==== Testing Bytes %s ====\n" testname); let result = t input in (match result with | Some (formattedresult, offset) -> (if U32.gt offset (len input) then (print_string "Invalid length return - it is longer than the input buffer!") else (let inputslice = FStar.Bytes.slice input 0ul offset in if formattedresult = inputslice then print_string "Formatted data matches original input data\n" else (print_string "FAIL: formatted data does not match original input data\n"))) | _ -> print_string "Failed to parse\n"); print_string (sprintf "==== Finished %s ====\n" testname); pop_frame ()
{ "checked_file": "LowParse.TestLib.SLow.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.IO.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.TestLib.SLow.fst" }
[]
[ "LowParse.TestLib.SLow.test_t", "Prims.string", "FStar.Bytes.bytes", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "FStar.HyperStack.IO.print_string", "FStar.Printf.sprintf", "FStar.UInt32.t", "FStar.UInt32.gt", "FStar.Bytes.len", "Prims.bool", "Prims.op_Equality", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.UInt8.t", "FStar.Bytes.reveal", "FStar.Seq.Base.slice", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "FStar.Bytes.slice", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.HyperStack.ST.push_frame", "FStar.Monotonic.HyperStack.mem", "Prims.b2t" ]
[]
module LowParse.TestLib.SLow open FStar.HyperStack.ST open FStar.Bytes open FStar.HyperStack.IO open FStar.Printf module U32 = FStar.UInt32 #reset-options "--using_facts_from '* -LowParse'" #reset-options "--z3cliopt smt.arith.nl=false" (** The type of a unit test. It takes an input Bytes, parses it, and returns a newly formatted Bytes. Or it returns None if there is a fail to parse. *) type test_t = (input:FStar.Bytes.bytes) -> Stack (option (FStar.Bytes.bytes * U32.t)) (fun _ -> true) (fun _ _ _ -> true) assume val load_file: (filename:string) -> Tot FStar.Bytes.bytes (** Test one parser+formatter pair against an in-memory buffer of Bytes *)
false
false
LowParse.TestLib.SLow.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_bytes (t: test_t) (testname: string) (input: FStar.Bytes.bytes) : Stack unit (fun _ -> true) (fun _ _ _ -> true)
[]
LowParse.TestLib.SLow.test_bytes
{ "file_name": "src/lowparse/LowParse.TestLib.SLow.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
t: LowParse.TestLib.SLow.test_t -> testname: Prims.string -> input: FStar.Bytes.bytes -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 41, "start_col": 2, "start_line": 22 }
Prims.Tot
val parse_u64_kind:parser_kind
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_u64_kind : parser_kind = total_constant_size_parser_kind 8
val parse_u64_kind:parser_kind let parse_u64_kind:parser_kind =
false
null
false
total_constant_size_parser_kind 8
{ "checked_file": "LowParse.Spec.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Int.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.total_constant_size_parser_kind" ]
[]
module LowParse.Spec.Int include LowParse.Spec.Base module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 inline_for_extraction let parse_u8_kind : parser_kind = total_constant_size_parser_kind 1 val tot_parse_u8: tot_parser parse_u8_kind U8.t let parse_u8: parser parse_u8_kind U8.t = tot_parse_u8 val parse_u8_spec (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in U8.v v == E.be_to_n (Seq.slice b 0 1) ))) val parse_u8_spec' (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in v == Seq.index b 0 ))) val serialize_u8 : serializer parse_u8 val serialize_u8_spec (x: U8.t) : Lemma (serialize serialize_u8 x `Seq.equal` Seq.create 1 x) let serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x) = serialize_u8_spec x inline_for_extraction let parse_u16_kind : parser_kind = total_constant_size_parser_kind 2 val parse_u16: parser parse_u16_kind U16.t val parse_u16_spec (b: bytes) : Lemma (requires (Seq.length b >= 2)) (ensures ( let pp = parse parse_u16 b in Some? pp /\ ( let (Some (v, consumed)) = pp in U16.v v == E.be_to_n (Seq.slice b 0 2) ))) val serialize_u16 : serializer parse_u16 inline_for_extraction let parse_u32_kind : parser_kind = total_constant_size_parser_kind 4 val parse_u32: parser parse_u32_kind U32.t val parse_u32_spec (b: bytes) : Lemma (requires (Seq.length b >= 4)) (ensures ( let pp = parse parse_u32 b in Some? pp /\ ( let (Some (v, consumed)) = pp in U32.v v == E.be_to_n (Seq.slice b 0 4) ))) val serialize_u32 : serializer parse_u32 inline_for_extraction
false
true
LowParse.Spec.Int.fsti
{ "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_u64_kind:parser_kind
[]
LowParse.Spec.Int.parse_u64_kind
{ "file_name": "src/lowparse/LowParse.Spec.Int.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.parser_kind
{ "end_col": 35, "end_line": 95, "start_col": 2, "start_line": 95 }
Prims.Tot
val parse_u32_kind:parser_kind
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_u32_kind : parser_kind = total_constant_size_parser_kind 4
val parse_u32_kind:parser_kind let parse_u32_kind:parser_kind =
false
null
false
total_constant_size_parser_kind 4
{ "checked_file": "LowParse.Spec.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Int.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.total_constant_size_parser_kind" ]
[]
module LowParse.Spec.Int include LowParse.Spec.Base module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 inline_for_extraction let parse_u8_kind : parser_kind = total_constant_size_parser_kind 1 val tot_parse_u8: tot_parser parse_u8_kind U8.t let parse_u8: parser parse_u8_kind U8.t = tot_parse_u8 val parse_u8_spec (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in U8.v v == E.be_to_n (Seq.slice b 0 1) ))) val parse_u8_spec' (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in v == Seq.index b 0 ))) val serialize_u8 : serializer parse_u8 val serialize_u8_spec (x: U8.t) : Lemma (serialize serialize_u8 x `Seq.equal` Seq.create 1 x) let serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x) = serialize_u8_spec x inline_for_extraction let parse_u16_kind : parser_kind = total_constant_size_parser_kind 2 val parse_u16: parser parse_u16_kind U16.t val parse_u16_spec (b: bytes) : Lemma (requires (Seq.length b >= 2)) (ensures ( let pp = parse parse_u16 b in Some? pp /\ ( let (Some (v, consumed)) = pp in U16.v v == E.be_to_n (Seq.slice b 0 2) ))) val serialize_u16 : serializer parse_u16 inline_for_extraction
false
true
LowParse.Spec.Int.fsti
{ "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_u32_kind:parser_kind
[]
LowParse.Spec.Int.parse_u32_kind
{ "file_name": "src/lowparse/LowParse.Spec.Int.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.parser_kind
{ "end_col": 35, "end_line": 76, "start_col": 2, "start_line": 76 }
Prims.Tot
val parse_u8:parser parse_u8_kind U8.t
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_u8: parser parse_u8_kind U8.t = tot_parse_u8
val parse_u8:parser parse_u8_kind U8.t let parse_u8:parser parse_u8_kind U8.t =
false
null
false
tot_parse_u8
{ "checked_file": "LowParse.Spec.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Int.fsti" }
[ "total" ]
[ "LowParse.Spec.Int.tot_parse_u8" ]
[]
module LowParse.Spec.Int include LowParse.Spec.Base module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 inline_for_extraction let parse_u8_kind : parser_kind = total_constant_size_parser_kind 1 val tot_parse_u8: tot_parser parse_u8_kind U8.t
false
true
LowParse.Spec.Int.fsti
{ "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_u8:parser parse_u8_kind U8.t
[]
LowParse.Spec.Int.parse_u8
{ "file_name": "src/lowparse/LowParse.Spec.Int.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.parser LowParse.Spec.Int.parse_u8_kind FStar.UInt8.t
{ "end_col": 54, "end_line": 16, "start_col": 42, "start_line": 16 }
Prims.Tot
val parse_u16_kind:parser_kind
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_u16_kind : parser_kind = total_constant_size_parser_kind 2
val parse_u16_kind:parser_kind let parse_u16_kind:parser_kind =
false
null
false
total_constant_size_parser_kind 2
{ "checked_file": "LowParse.Spec.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Int.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.total_constant_size_parser_kind" ]
[]
module LowParse.Spec.Int include LowParse.Spec.Base module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 inline_for_extraction let parse_u8_kind : parser_kind = total_constant_size_parser_kind 1 val tot_parse_u8: tot_parser parse_u8_kind U8.t let parse_u8: parser parse_u8_kind U8.t = tot_parse_u8 val parse_u8_spec (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in U8.v v == E.be_to_n (Seq.slice b 0 1) ))) val parse_u8_spec' (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in v == Seq.index b 0 ))) val serialize_u8 : serializer parse_u8 val serialize_u8_spec (x: U8.t) : Lemma (serialize serialize_u8 x `Seq.equal` Seq.create 1 x) let serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x) = serialize_u8_spec x inline_for_extraction
false
true
LowParse.Spec.Int.fsti
{ "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_u16_kind:parser_kind
[]
LowParse.Spec.Int.parse_u16_kind
{ "file_name": "src/lowparse/LowParse.Spec.Int.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.parser_kind
{ "end_col": 35, "end_line": 57, "start_col": 2, "start_line": 57 }
Prims.Tot
val parse_u8_kind:parser_kind
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_u8_kind : parser_kind = total_constant_size_parser_kind 1
val parse_u8_kind:parser_kind let parse_u8_kind:parser_kind =
false
null
false
total_constant_size_parser_kind 1
{ "checked_file": "LowParse.Spec.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Int.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.total_constant_size_parser_kind" ]
[]
module LowParse.Spec.Int include LowParse.Spec.Base module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64
false
true
LowParse.Spec.Int.fsti
{ "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_u8_kind:parser_kind
[]
LowParse.Spec.Int.parse_u8_kind
{ "file_name": "src/lowparse/LowParse.Spec.Int.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.parser_kind
{ "end_col": 67, "end_line": 12, "start_col": 34, "start_line": 12 }
FStar.Pervasives.Lemma
val serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x)
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x) = serialize_u8_spec x
val serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x) let serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x) =
false
null
true
serialize_u8_spec x
{ "checked_file": "LowParse.Spec.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Int.fsti" }
[ "lemma" ]
[ "FStar.UInt8.t", "LowParse.Spec.Int.serialize_u8_spec", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "FStar.Seq.Base.index", "LowParse.Bytes.bytes", "LowParse.Spec.Base.serialize", "LowParse.Spec.Int.parse_u8_kind", "LowParse.Spec.Int.parse_u8", "LowParse.Spec.Int.serialize_u8", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Spec.Int include LowParse.Spec.Base module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 inline_for_extraction let parse_u8_kind : parser_kind = total_constant_size_parser_kind 1 val tot_parse_u8: tot_parser parse_u8_kind U8.t let parse_u8: parser parse_u8_kind U8.t = tot_parse_u8 val parse_u8_spec (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in U8.v v == E.be_to_n (Seq.slice b 0 1) ))) val parse_u8_spec' (b: bytes) : Lemma (requires (Seq.length b >= 1)) (ensures ( let pp = parse parse_u8 b in Some? pp /\ ( let (Some (v, consumed)) = pp in v == Seq.index b 0 ))) val serialize_u8 : serializer parse_u8 val serialize_u8_spec (x: U8.t) : Lemma (serialize serialize_u8 x `Seq.equal` Seq.create 1 x) let serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\
false
false
LowParse.Spec.Int.fsti
{ "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 serialize_u8_spec' (x: U8.t) : Lemma (let s = serialize serialize_u8 x in Seq.length s == 1 /\ Seq.index s 0 == x)
[]
LowParse.Spec.Int.serialize_u8_spec'
{ "file_name": "src/lowparse/LowParse.Spec.Int.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
x: FStar.UInt8.t -> FStar.Pervasives.Lemma (ensures (let s = LowParse.Spec.Base.serialize LowParse.Spec.Int.serialize_u8 x in FStar.Seq.Base.length s == 1 /\ FStar.Seq.Base.index s 0 == x))
{ "end_col": 21, "end_line": 53, "start_col": 2, "start_line": 53 }
FStar.Tactics.Effect.Tac
val terms_to_string (t: list term) : T.Tac string
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": 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 terms_to_string (t:list term) : T.Tac string = String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t)
val terms_to_string (t: list term) : T.Tac string let terms_to_string (t: list term) : T.Tac string =
true
null
false
String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t)
{ "checked_file": "Pulse.Checker.Exists.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Exists.fst" }
[]
[ "Prims.list", "Pulse.Syntax.Base.term", "FStar.String.concat", "Prims.string", "FStar.Tactics.Util.map", "Pulse.Syntax.Printer.term_to_string" ]
[]
module Pulse.Checker.Exists open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module FV = Pulse.Typing.FV module Metatheory = Pulse.Typing.Metatheory let vprop_as_list_typing (#g:env) (#p:term) (t:tot_typing g p tm_vprop) (x:term { List.Tot.memP x (vprop_as_list p) }) : tot_typing g x tm_vprop = assume false; t let terms_to_string (t:list term)
false
false
Pulse.Checker.Exists.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 terms_to_string (t: list term) : T.Tac string
[]
Pulse.Checker.Exists.terms_to_string
{ "file_name": "lib/steel/pulse/Pulse.Checker.Exists.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac Prims.string
{ "end_col": 68, "end_line": 25, "start_col": 4, "start_line": 25 }
FStar.Tactics.Effect.Tac
val check_intro_exists (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { intro_exists_witness_singleton st }) (vprop_typing: option (tot_typing g (intro_exists_vprop st) tm_vprop)) : T.Tac (checker_result_t g pre post_hint)
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": 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 check_intro_exists (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { intro_exists_witness_singleton st }) (vprop_typing: option (tot_typing g (intro_exists_vprop st) tm_vprop)) : T.Tac (checker_result_t g pre post_hint) = let g = Pulse.Typing.Env.push_context g "check_intro_exists_non_erased" st.range in let Tm_IntroExists { p=t; witnesses=[witness] } = st.term in let (| t, t_typing |) = match vprop_typing with | Some typing -> (| t, typing |) | _ -> check_vprop g t in if not (Tm_ExistsSL? (t <: term).t) then fail g (Some st.range) (Printf.sprintf "check_intro_exists_non_erased: vprop %s is not an existential" (P.term_to_string t)); let Tm_ExistsSL u b p = (t <: term).t in Pulse.Typing.FV.tot_typing_freevars t_typing; let ty_typing, _ = Metatheory.tm_exists_inversion #g #u #b.binder_ty #p t_typing (fresh g) in let (| witness, witness_typing |) = check_term_with_expected_type_and_effect g witness T.E_Ghost b.binder_ty in let d = T_IntroExists g u b p witness ty_typing t_typing witness_typing in let (| c, d |) : (c:_ & st_typing g _ c) = (| _, d |) in prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname) post_hint (t <: term).range
val check_intro_exists (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { intro_exists_witness_singleton st }) (vprop_typing: option (tot_typing g (intro_exists_vprop st) tm_vprop)) : T.Tac (checker_result_t g pre post_hint) let check_intro_exists (g: env) (pre: term) (pre_typing: tot_typing g pre tm_vprop) (post_hint: post_hint_opt g) (res_ppname: ppname) (st: st_term{intro_exists_witness_singleton st}) (vprop_typing: option (tot_typing g (intro_exists_vprop st) tm_vprop)) : T.Tac (checker_result_t g pre post_hint) =
true
null
false
let g = Pulse.Typing.Env.push_context g "check_intro_exists_non_erased" st.range in let Tm_IntroExists { p = t ; witnesses = [witness] } = st.term in let (| t , t_typing |) = match vprop_typing with | Some typing -> (| t, typing |) | _ -> check_vprop g t in if not (Tm_ExistsSL? (t <: term).t) then fail g (Some st.range) (Printf.sprintf "check_intro_exists_non_erased: vprop %s is not an existential" (P.term_to_string t)); let Tm_ExistsSL u b p = (t <: term).t in Pulse.Typing.FV.tot_typing_freevars t_typing; let ty_typing, _ = Metatheory.tm_exists_inversion #g #u #b.binder_ty #p t_typing (fresh g) in let (| witness , witness_typing |) = check_term_with_expected_type_and_effect g witness T.E_Ghost b.binder_ty in let d = T_IntroExists g u b p witness ty_typing t_typing witness_typing in let (| c , d |):(c: _ & st_typing g _ c) = (| _, d |) in prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname) post_hint (t <: term).range
{ "checked_file": "Pulse.Checker.Exists.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Exists.fst" }
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.post_hint_opt", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.st_term", "Prims.b2t", "Pulse.Checker.Exists.intro_exists_witness_singleton", "FStar.Pervasives.Native.option", "Pulse.Checker.Exists.intro_exists_vprop", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Pulse.Typing.universe_of", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Typing.Env.push_binding", "Pulse.Typing.Env.fresh", "Pulse.Syntax.Base.ppname_default", "Pulse.Typing.typing", "FStar.Stubs.TypeChecker.Core.E_Ghost", "Pulse.Syntax.Base.comp", "Pulse.Typing.st_typing", "Pulse.Typing.wtag", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.ctag", "Pulse.Syntax.Base.STT_Ghost", "Pulse.Syntax.Base.Tm_IntroExists", "Pulse.Syntax.Base.Mkst_term'__Tm_IntroExists__payload", "Pulse.Syntax.Base.tm_exists_sl", "Prims.Cons", "Prims.Nil", "Pulse.Checker.Prover.prove_post_hint", "Pulse.Syntax.Base.__proj__Mkterm__item__range", "Pulse.Checker.Base.checker_result_t", "FStar.Pervasives.Native.None", "Pulse.Typing.post_hint_t", "Pulse.Checker.Prover.try_frame_pre", "FStar.Pervasives.dtuple3", "Pulse.Syntax.Base.comp_st", "Pulse.Checker.Base.match_comp_res_with_post_hint", "Prims.dtuple2", "Prims.Mkdtuple2", "Pulse.Typing.comp_intro_exists", "Pulse.Typing.T_IntroExists", "Pulse.Checker.Pure.check_term_with_expected_type_and_effect", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.Metatheory.Base.tm_exists_inversion", "Prims.unit", "Pulse.Typing.FV.tot_typing_freevars", "Pulse.Syntax.Base.term'", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Prims.op_Negation", "Pulse.Syntax.Base.uu___is_Tm_ExistsSL", "Pulse.Typing.Env.fail", "Pulse.Syntax.Base.range", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Prims.string", "FStar.Printf.sprintf", "Pulse.Syntax.Printer.term_to_string", "Prims.bool", "Pulse.Checker.Pure.check_vprop", "Pulse.Syntax.Base.st_term'", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Prims.eq2", "Pulse.Typing.Env.push_context" ]
[]
module Pulse.Checker.Exists open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module FV = Pulse.Typing.FV module Metatheory = Pulse.Typing.Metatheory let vprop_as_list_typing (#g:env) (#p:term) (t:tot_typing g p tm_vprop) (x:term { List.Tot.memP x (vprop_as_list p) }) : tot_typing g x tm_vprop = assume false; t let terms_to_string (t:list term) : T.Tac string = String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t) let check_elim_exists (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (t:st_term{Tm_ElimExists? t.term}) : T.Tac (checker_result_t g pre post_hint) = let g = Pulse.Typing.Env.push_context g "check_elim_exists" t.range in let Tm_ElimExists { p = t } = t.term in let (| t, t_typing |) : (t:term & tot_typing g t tm_vprop ) = match t.t with | Tm_Unknown -> ( //There should be exactly one exists_ vprop in the context and we eliminate it let ts = vprop_as_list pre in let exist_tms = List.Tot.Base.filter #term (function | {t = Tm_ExistsSL _ _ _ } -> true | _ -> false) ts in match exist_tms with | [one] -> assume (one `List.Tot.memP` ts); (| one, vprop_as_list_typing pre_typing one |) //shouldn't need to check this again | _ -> fail g (Some t.range) (Printf.sprintf "Could not decide which exists term to eliminate: choices are\n%s" (terms_to_string exist_tms)) ) | _ -> let t, _ = instantiate_term_implicits g t in check_vprop g t in if not (Tm_ExistsSL? t.t) then fail g (Some t.range) (Printf.sprintf "check_elim_exists: elim_exists argument %s not an existential" (P.term_to_string t)); let Tm_ExistsSL u { binder_ty=ty } p = t.t in let (| u', ty_typing |) = check_universe g ty in if eq_univ u u' then let x = fresh g in let d = T_ElimExists g u ty p x ty_typing t_typing in prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname) post_hint t.range else fail g (Some t.range) (Printf.sprintf "check_elim_exists: universe checking failed, computed %s, expected %s" (P.univ_to_string u') (P.univ_to_string u)) let check_intro_exists (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { intro_exists_witness_singleton st })
false
false
Pulse.Checker.Exists.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 check_intro_exists (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { intro_exists_witness_singleton st }) (vprop_typing: option (tot_typing g (intro_exists_vprop st) tm_vprop)) : T.Tac (checker_result_t g pre post_hint)
[]
Pulse.Checker.Exists.check_intro_exists
{ "file_name": "lib/steel/pulse/Pulse.Checker.Exists.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
g: Pulse.Typing.Env.env -> pre: Pulse.Syntax.Base.term -> pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop -> post_hint: Pulse.Typing.post_hint_opt g -> res_ppname: Pulse.Syntax.Base.ppname -> st: Pulse.Syntax.Base.st_term{Pulse.Checker.Exists.intro_exists_witness_singleton st} -> vprop_typing: FStar.Pervasives.Native.option (Pulse.Typing.tot_typing g (Pulse.Checker.Exists.intro_exists_vprop st) Pulse.Syntax.Base.tm_vprop) -> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre post_hint)
{ "end_col": 127, "end_line": 107, "start_col": 46, "start_line": 83 }
FStar.HyperStack.ST.Stack
val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one)
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 mk_felem_one b = Hacl.Bignum25519.make_one b
val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b =
true
null
false
Hacl.Bignum25519.make_one b
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "Hacl.Bignum25519.make_one", "Prims.unit" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one)
false
false
Hacl.EC.Ed25519.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 mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one)
[]
Hacl.EC.Ed25519.mk_felem_one
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 29, "end_line": 51, "start_col": 2, "start_line": 51 }
FStar.HyperStack.ST.Stack
val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero)
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 mk_felem_zero b = Hacl.Bignum25519.make_zero b
val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b =
true
null
false
Hacl.Bignum25519.make_zero b
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "Hacl.Bignum25519.make_zero", "Prims.unit" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero)
false
false
Hacl.EC.Ed25519.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 mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero)
[]
Hacl.EC.Ed25519.mk_felem_zero
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 30, "end_line": 37, "start_col": 2, "start_line": 37 }
FStar.HyperStack.ST.Stack
val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity)
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 mk_point_at_inf p = Hacl.Impl.Ed25519.PointConstants.make_point_inf p
val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity) let mk_point_at_inf p =
true
null
false
Hacl.Impl.Ed25519.PointConstants.make_point_inf p
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.point", "Hacl.Impl.Ed25519.PointConstants.make_point_inf", "Prims.unit" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out = Hacl.Bignum25519.store_51 out a [@@ CPrologue "/******************************************************************************* Verified group operations for the edwards25519 elliptic curve of the form −x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2. This is a 64-bit optimized version, where a group element in extended homogeneous coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit integers, i.e., uint64_t[20]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity)
false
false
Hacl.EC.Ed25519.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 mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity)
[]
Hacl.EC.Ed25519.mk_point_at_inf
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.Ed25519.Field51.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 51, "end_line": 236, "start_col": 2, "start_line": 236 }
FStar.HyperStack.ST.Stack
val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g)
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 mk_base_point p = Spec.Ed25519.Lemmas.g_is_on_curve (); Hacl.Impl.Ed25519.PointConstants.make_g p
val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g) let mk_base_point p =
true
null
false
Spec.Ed25519.Lemmas.g_is_on_curve (); Hacl.Impl.Ed25519.PointConstants.make_g p
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.point", "Hacl.Impl.Ed25519.PointConstants.make_g", "Prims.unit", "Spec.Ed25519.Lemmas.g_is_on_curve" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out = Hacl.Bignum25519.store_51 out a [@@ CPrologue "/******************************************************************************* Verified group operations for the edwards25519 elliptic curve of the form −x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2. This is a 64-bit optimized version, where a group element in extended homogeneous coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit integers, i.e., uint64_t[20]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity) let mk_point_at_inf p = Hacl.Impl.Ed25519.PointConstants.make_point_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g)
false
false
Hacl.EC.Ed25519.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 mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g)
[]
Hacl.EC.Ed25519.mk_base_point
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.Ed25519.Field51.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 43, "end_line": 251, "start_col": 2, "start_line": 250 }
FStar.HyperStack.ST.Stack
val point_eq: p:F51.point -> q:F51.point -> Stack bool (requires fun h -> live h p /\ live h q /\ eq_or_disjoint p q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> SE.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q)))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 point_eq p q = Hacl.Impl.Ed25519.PointEqual.point_equal p q
val point_eq: p:F51.point -> q:F51.point -> Stack bool (requires fun h -> live h p /\ live h q /\ eq_or_disjoint p q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> SE.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q))) let point_eq p q =
true
null
false
Hacl.Impl.Ed25519.PointEqual.point_equal p q
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.point", "Hacl.Impl.Ed25519.PointEqual.point_equal", "Prims.bool" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out = Hacl.Bignum25519.store_51 out a [@@ CPrologue "/******************************************************************************* Verified group operations for the edwards25519 elliptic curve of the form −x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2. This is a 64-bit optimized version, where a group element in extended homogeneous coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit integers, i.e., uint64_t[20]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity) let mk_point_at_inf p = Hacl.Impl.Ed25519.PointConstants.make_point_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g) let mk_base_point p = Spec.Ed25519.Lemmas.g_is_on_curve (); Hacl.Impl.Ed25519.PointConstants.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint"] val point_negate: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint out p /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) let point_negate p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointNegate.point_negate p out [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add: p:F51.point -> q:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\ F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add p q out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_add_lemma (F51.refl_ext_point (as_seq h0 p)) (F51.refl_ext_point (as_seq h0 q)); Hacl.Impl.Ed25519.PointAdd.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either pairwise disjoint or equal"] val point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p)) let point_double p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_double_lemma (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointDouble.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a little-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ SE.to_aff_point (F51.point_eval h1 out) == SE.to_aff_point (SE.point_mul (as_seq h0 scalar) (F51.point_eval h0 p))) let point_mul scalar p out = Hacl.Impl.Ed25519.Ladder.point_mul out scalar p [@@ Comment "Checks whether `p` is equal to `q` (point equality). The function returns `true` if `p` is equal to `q` and `false` otherwise. The arguments `p` and `q` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `q` are either disjoint or equal"] val point_eq: p:F51.point -> q:F51.point -> Stack bool (requires fun h -> live h p /\ live h q /\ eq_or_disjoint p q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> SE.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q)))
false
false
Hacl.EC.Ed25519.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 point_eq: p:F51.point -> q:F51.point -> Stack bool (requires fun h -> live h p /\ live h q /\ eq_or_disjoint p q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> SE.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q)))
[]
Hacl.EC.Ed25519.point_eq
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.Ed25519.Field51.point -> q: Hacl.Impl.Ed25519.Field51.point -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 46, "end_line": 372, "start_col": 2, "start_line": 372 }
FStar.HyperStack.ST.Stack
val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255)
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 felem_load b out = Hacl.Bignum25519.load_51 out b
val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out =
true
null
false
Hacl.Bignum25519.load_51 out b
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Ed25519.Field51.felem", "Hacl.Bignum25519.load_51", "Prims.unit" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255)
false
false
Hacl.EC.Ed25519.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 felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255)
[]
Hacl.EC.Ed25519.felem_load
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> out: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 32, "end_line": 192, "start_col": 2, "start_line": 192 }
FStar.HyperStack.ST.Stack
val point_compress: p:F51.point -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == SE.point_compress (F51.point_eval h0 p))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 point_compress p out = Hacl.Impl.Ed25519.PointCompress.point_compress out p
val point_compress: p:F51.point -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == SE.point_compress (F51.point_eval h0 p)) let point_compress p out =
true
null
false
Hacl.Impl.Ed25519.PointCompress.point_compress out p
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Ed25519.PointCompress.point_compress", "Prims.unit" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out = Hacl.Bignum25519.store_51 out a [@@ CPrologue "/******************************************************************************* Verified group operations for the edwards25519 elliptic curve of the form −x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2. This is a 64-bit optimized version, where a group element in extended homogeneous coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit integers, i.e., uint64_t[20]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity) let mk_point_at_inf p = Hacl.Impl.Ed25519.PointConstants.make_point_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g) let mk_base_point p = Spec.Ed25519.Lemmas.g_is_on_curve (); Hacl.Impl.Ed25519.PointConstants.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint"] val point_negate: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint out p /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) let point_negate p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointNegate.point_negate p out [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add: p:F51.point -> q:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\ F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add p q out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_add_lemma (F51.refl_ext_point (as_seq h0 p)) (F51.refl_ext_point (as_seq h0 q)); Hacl.Impl.Ed25519.PointAdd.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either pairwise disjoint or equal"] val point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p)) let point_double p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_double_lemma (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointDouble.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a little-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ SE.to_aff_point (F51.point_eval h1 out) == SE.to_aff_point (SE.point_mul (as_seq h0 scalar) (F51.point_eval h0 p))) let point_mul scalar p out = Hacl.Impl.Ed25519.Ladder.point_mul out scalar p [@@ Comment "Checks whether `p` is equal to `q` (point equality). The function returns `true` if `p` is equal to `q` and `false` otherwise. The arguments `p` and `q` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `q` are either disjoint or equal"] val point_eq: p:F51.point -> q:F51.point -> Stack bool (requires fun h -> live h p /\ live h q /\ eq_or_disjoint p q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> SE.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q))) let point_eq p q = Hacl.Impl.Ed25519.PointEqual.point_equal p q [@@ Comment "Compress a point in extended homogeneous coordinates to its compressed form. The argument `p` points to a point of 20 limbs in size, i.e., uint64_t[20]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. The function first converts a given point `p` from extended homogeneous to affine coordinates and then writes [ 2^255 * (`x` % 2) + `y` ] in `out`. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint"] val point_compress: p:F51.point -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == SE.point_compress (F51.point_eval h0 p))
false
false
Hacl.EC.Ed25519.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 point_compress: p:F51.point -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == SE.point_compress (F51.point_eval h0 p))
[]
Hacl.EC.Ed25519.point_compress
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.Ed25519.Field51.point -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 54, "end_line": 395, "start_col": 2, "start_line": 395 }
FStar.HyperStack.ST.Stack
val point_decompress: s:lbuffer uint8 32ul -> out:F51.point -> Stack bool (requires fun h -> live h out /\ live h s /\ disjoint s out) (ensures fun h0 b h1 -> modifies (loc out) h0 h1 /\ (b ==> F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out)) /\ (b <==> Some? (SE.point_decompress (as_seq h0 s))) /\ (b ==> (F51.point_eval h1 out == Some?.v (SE.point_decompress (as_seq h0 s)))))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 point_decompress s out = let h0 = ST.get () in Spec.Ed25519.Lemmas.point_decompress_lemma (as_seq h0 s); Hacl.Impl.Ed25519.PointDecompress.point_decompress out s
val point_decompress: s:lbuffer uint8 32ul -> out:F51.point -> Stack bool (requires fun h -> live h out /\ live h s /\ disjoint s out) (ensures fun h0 b h1 -> modifies (loc out) h0 h1 /\ (b ==> F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out)) /\ (b <==> Some? (SE.point_decompress (as_seq h0 s))) /\ (b ==> (F51.point_eval h1 out == Some?.v (SE.point_decompress (as_seq h0 s))))) let point_decompress s out =
true
null
false
let h0 = ST.get () in Spec.Ed25519.Lemmas.point_decompress_lemma (as_seq h0 s); Hacl.Impl.Ed25519.PointDecompress.point_decompress out s
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Ed25519.Field51.point", "Hacl.Impl.Ed25519.PointDecompress.point_decompress", "Prims.bool", "Prims.unit", "Spec.Ed25519.Lemmas.point_decompress_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out = Hacl.Bignum25519.store_51 out a [@@ CPrologue "/******************************************************************************* Verified group operations for the edwards25519 elliptic curve of the form −x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2. This is a 64-bit optimized version, where a group element in extended homogeneous coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit integers, i.e., uint64_t[20]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity) let mk_point_at_inf p = Hacl.Impl.Ed25519.PointConstants.make_point_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g) let mk_base_point p = Spec.Ed25519.Lemmas.g_is_on_curve (); Hacl.Impl.Ed25519.PointConstants.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint"] val point_negate: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint out p /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) let point_negate p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointNegate.point_negate p out [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add: p:F51.point -> q:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\ F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add p q out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_add_lemma (F51.refl_ext_point (as_seq h0 p)) (F51.refl_ext_point (as_seq h0 q)); Hacl.Impl.Ed25519.PointAdd.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either pairwise disjoint or equal"] val point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p)) let point_double p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_double_lemma (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointDouble.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a little-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ SE.to_aff_point (F51.point_eval h1 out) == SE.to_aff_point (SE.point_mul (as_seq h0 scalar) (F51.point_eval h0 p))) let point_mul scalar p out = Hacl.Impl.Ed25519.Ladder.point_mul out scalar p [@@ Comment "Checks whether `p` is equal to `q` (point equality). The function returns `true` if `p` is equal to `q` and `false` otherwise. The arguments `p` and `q` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `q` are either disjoint or equal"] val point_eq: p:F51.point -> q:F51.point -> Stack bool (requires fun h -> live h p /\ live h q /\ eq_or_disjoint p q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 z h1 -> modifies0 h0 h1 /\ (z <==> SE.point_equal (F51.point_eval h0 p) (F51.point_eval h0 q))) let point_eq p q = Hacl.Impl.Ed25519.PointEqual.point_equal p q [@@ Comment "Compress a point in extended homogeneous coordinates to its compressed form. The argument `p` points to a point of 20 limbs in size, i.e., uint64_t[20]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. The function first converts a given point `p` from extended homogeneous to affine coordinates and then writes [ 2^255 * (`x` % 2) + `y` ] in `out`. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint"] val point_compress: p:F51.point -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ F51.point_inv_t h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == SE.point_compress (F51.point_eval h0 p)) let point_compress p out = Hacl.Impl.Ed25519.PointCompress.point_compress out p [@@ Comment "Decompress a point in extended homogeneous coordinates from its compressed form. The function returns `true` for successful decompression of a compressed point and `false` otherwise. The argument `s` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a point of 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `s` and `out` are disjoint"] val point_decompress: s:lbuffer uint8 32ul -> out:F51.point -> Stack bool (requires fun h -> live h out /\ live h s /\ disjoint s out) (ensures fun h0 b h1 -> modifies (loc out) h0 h1 /\ (b ==> F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out)) /\ (b <==> Some? (SE.point_decompress (as_seq h0 s))) /\ (b ==> (F51.point_eval h1 out == Some?.v (SE.point_decompress (as_seq h0 s)))))
false
false
Hacl.EC.Ed25519.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 point_decompress: s:lbuffer uint8 32ul -> out:F51.point -> Stack bool (requires fun h -> live h out /\ live h s /\ disjoint s out) (ensures fun h0 b h1 -> modifies (loc out) h0 h1 /\ (b ==> F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out)) /\ (b <==> Some? (SE.point_decompress (as_seq h0 s))) /\ (b ==> (F51.point_eval h1 out == Some?.v (SE.point_decompress (as_seq h0 s)))))
[]
Hacl.EC.Ed25519.point_decompress
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> out: Hacl.Impl.Ed25519.Field51.point -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 58, "end_line": 421, "start_col": 28, "start_line": 418 }
FStar.HyperStack.ST.Stack
val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out
val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out =
true
null
false
Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "Hacl.Bignum25519.reduce_513", "Prims.unit", "Hacl.Impl.Curve25519.Field51.fsub" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b))
false
false
Hacl.EC.Ed25519.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 felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b))
[]
Hacl.EC.Ed25519.felem_sub
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Impl.Ed25519.Field51.felem -> b: Hacl.Impl.Ed25519.Field51.felem -> out: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 33, "end_line": 101, "start_col": 2, "start_line": 100 }
FStar.HyperStack.ST.Stack
val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out
val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out =
true
null
false
Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "Hacl.Bignum25519.reduce_513", "Prims.unit", "Hacl.Bignum25519.inverse" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2))
false
false
Hacl.EC.Ed25519.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 felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2))
[]
Hacl.EC.Ed25519.felem_inv
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Impl.Ed25519.Field51.felem -> out: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 33, "end_line": 171, "start_col": 2, "start_line": 170 }
FStar.HyperStack.ST.Stack
val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out
val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out =
true
null
false
Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "Hacl.Bignum25519.reduce_513", "Prims.unit", "Hacl.Impl.Curve25519.Field51.fadd" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b))
false
false
Hacl.EC.Ed25519.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 felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b))
[]
Hacl.EC.Ed25519.felem_add
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Impl.Ed25519.Field51.felem -> b: Hacl.Impl.Ed25519.Field51.felem -> out: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 33, "end_line": 76, "start_col": 2, "start_line": 75 }
FStar.HyperStack.ST.Stack
val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 felem_store a out = Hacl.Bignum25519.store_51 out a
val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out =
true
null
false
Hacl.Bignum25519.store_51 out a
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Bignum25519.store_51", "Prims.unit" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a))
false
false
Hacl.EC.Ed25519.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 felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a))
[]
Hacl.EC.Ed25519.felem_store
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Impl.Ed25519.Field51.felem -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 33, "end_line": 212, "start_col": 2, "start_line": 212 }
FStar.HyperStack.ST.Stack
val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame()
val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out =
true
null
false
push_frame (); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame ()
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Curve25519.Field51.fsqr", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Hacl.Impl.Curve25519.Fields.Core.wide", "Hacl.Impl.Curve25519.Fields.Core.M51", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u128", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a))
false
false
Hacl.EC.Ed25519.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 felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a))
[]
Hacl.EC.Ed25519.felem_sqr
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Impl.Ed25519.Field51.felem -> out: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 148, "start_col": 2, "start_line": 145 }
FStar.HyperStack.ST.Stack
val point_mul: scalar:lbuffer uint8 32ul -> p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ SE.to_aff_point (F51.point_eval h1 out) == SE.to_aff_point (SE.point_mul (as_seq h0 scalar) (F51.point_eval h0 p)))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 point_mul scalar p out = Hacl.Impl.Ed25519.Ladder.point_mul out scalar p
val point_mul: scalar:lbuffer uint8 32ul -> p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ SE.to_aff_point (F51.point_eval h1 out) == SE.to_aff_point (SE.point_mul (as_seq h0 scalar) (F51.point_eval h0 p))) let point_mul scalar p out =
true
null
false
Hacl.Impl.Ed25519.Ladder.point_mul out scalar p
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Ed25519.Field51.point", "Hacl.Impl.Ed25519.Ladder.point_mul", "Prims.unit" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out = Hacl.Bignum25519.store_51 out a [@@ CPrologue "/******************************************************************************* Verified group operations for the edwards25519 elliptic curve of the form −x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2. This is a 64-bit optimized version, where a group element in extended homogeneous coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit integers, i.e., uint64_t[20]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity) let mk_point_at_inf p = Hacl.Impl.Ed25519.PointConstants.make_point_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g) let mk_base_point p = Spec.Ed25519.Lemmas.g_is_on_curve (); Hacl.Impl.Ed25519.PointConstants.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint"] val point_negate: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint out p /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) let point_negate p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointNegate.point_negate p out [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add: p:F51.point -> q:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\ F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add p q out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_add_lemma (F51.refl_ext_point (as_seq h0 p)) (F51.refl_ext_point (as_seq h0 q)); Hacl.Impl.Ed25519.PointAdd.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either pairwise disjoint or equal"] val point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p)) let point_double p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_double_lemma (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointDouble.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a little-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ SE.to_aff_point (F51.point_eval h1 out) == SE.to_aff_point (SE.point_mul (as_seq h0 scalar) (F51.point_eval h0 p)))
false
false
Hacl.EC.Ed25519.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 point_mul: scalar:lbuffer uint8 32ul -> p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ SE.to_aff_point (F51.point_eval h1 out) == SE.to_aff_point (SE.point_mul (as_seq h0 scalar) (F51.point_eval h0 p)))
[]
Hacl.EC.Ed25519.point_mul
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
scalar: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> p: Hacl.Impl.Ed25519.Field51.point -> out: Hacl.Impl.Ed25519.Field51.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 49, "end_line": 351, "start_col": 2, "start_line": 351 }
FStar.HyperStack.ST.Stack
val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame()
val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out =
true
null
false
push_frame (); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame ()
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.felem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Curve25519.Field51.fmul", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Hacl.Impl.Curve25519.Fields.Core.wide", "Hacl.Impl.Curve25519.Fields.Core.M51", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u128", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b))
false
false
Hacl.EC.Ed25519.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 felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b))
[]
Hacl.EC.Ed25519.felem_mul
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Impl.Ed25519.Field51.felem -> b: Hacl.Impl.Ed25519.Field51.felem -> out: Hacl.Impl.Ed25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 125, "start_col": 2, "start_line": 122 }
FStar.HyperStack.ST.Stack
val point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p))
[ { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Ladder", "short_module": "ML" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": 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 point_double p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_double_lemma (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointDouble.point_double out p
val point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p)) let point_double p out =
true
null
false
let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_double_lemma (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointDouble.point_double out p
{ "checked_file": "Hacl.EC.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.PointNegate.fst.checked", "Hacl.Impl.Ed25519.PointEqual.fst.checked", "Hacl.Impl.Ed25519.PointDouble.fst.checked", "Hacl.Impl.Ed25519.PointDecompress.fst.checked", "Hacl.Impl.Ed25519.PointConstants.fst.checked", "Hacl.Impl.Ed25519.PointCompress.fst.checked", "Hacl.Impl.Ed25519.PointAdd.fst.checked", "Hacl.Impl.Ed25519.Ladder.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.Ed25519.fst" }
[]
[ "Hacl.Impl.Ed25519.Field51.point", "Hacl.Impl.Ed25519.PointDouble.point_double", "Prims.unit", "Spec.Ed25519.Lemmas.to_aff_point_double_lemma", "Hacl.Impl.Ed25519.Field51.refl_ext_point", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.EC.Ed25519 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Ed25519.Field51 module SE = Spec.Ed25519 module SC = Spec.Curve25519 module ML = Hacl.Impl.Ed25519.Ladder #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^255 - 19. This is a 64-bit optimized version, where a field element in radix-2^{51} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.zero) let mk_felem_zero b = Hacl.Bignum25519.make_zero b [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: b:F51.felem -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ F51.mul_inv_t h1 b /\ F51.fevalh h1 b == SC.one) let mk_felem_one b = Hacl.Bignum25519.make_one b [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_add a b out = Hacl.Impl.Curve25519.Field51.fadd out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ (disjoint out a \/ out == a) /\ (disjoint out b \/ out == b) /\ (disjoint a b \/ a == b) /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_sub a b out = Hacl.Impl.Curve25519.Field51.fsub out a b; Hacl.Bignum25519.reduce_513 out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ F51.mul_inv_t h a /\ F51.mul_inv_t h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b)) let felem_mul a b out = push_frame(); let tmp = create 10ul (u128 0) in Hacl.Impl.Curve25519.Field51.fmul out a b tmp; pop_frame() [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a)) let felem_sqr a out = push_frame(); let tmp = create 5ul (u128 0) in Hacl.Impl.Curve25519.Field51.fsqr out a tmp; pop_frame() [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv: a:F51.felem -> out:F51.felem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2)) let felem_inv a out = Hacl.Bignum25519.inverse out a; Hacl.Bignum25519.reduce_513 out [@@ Comment "Load a little-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint NOTE that the function also performs the reduction modulo 2^255."] val felem_load: b:lbuffer uint8 32ul -> out:F51.felem -> Stack unit (requires fun h -> live h b /\ live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255) let felem_load b out = Hacl.Bignum25519.load_51 out b [@@ Comment "Serialize a field element into little-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F51.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ F51.mul_inv_t h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a)) let felem_store a out = Hacl.Bignum25519.store_51 out a [@@ CPrologue "/******************************************************************************* Verified group operations for the edwards25519 elliptic curve of the form −x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2. This is a 64-bit optimized version, where a group element in extended homogeneous coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit integers, i.e., uint64_t[20]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_point_at_inf: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity) let mk_point_at_inf p = Hacl.Impl.Ed25519.PointConstants.make_point_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."] val mk_base_point: p:F51.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\ SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g) let mk_base_point p = Spec.Ed25519.Lemmas.g_is_on_curve (); Hacl.Impl.Ed25519.PointConstants.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint"] val point_negate: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint out p /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) let point_negate p out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p)); Hacl.Impl.Ed25519.PointNegate.point_negate p out [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add: p:F51.point -> q:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\ F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add p q out = let h0 = ST.get () in Spec.Ed25519.Lemmas.to_aff_point_add_lemma (F51.refl_ext_point (as_seq h0 p)) (F51.refl_ext_point (as_seq h0 q)); Hacl.Impl.Ed25519.PointAdd.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either pairwise disjoint or equal"] val point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p))
false
false
Hacl.EC.Ed25519.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 point_double: p:F51.point -> out:F51.point -> Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\ F51.point_eval h1 out == SE.point_double (F51.point_eval h0 p))
[]
Hacl.EC.Ed25519.point_double
{ "file_name": "code/ed25519/Hacl.EC.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.Ed25519.Field51.point -> out: Hacl.Impl.Ed25519.Field51.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 50, "end_line": 324, "start_col": 24, "start_line": 321 }