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 mem_correspondence (args: list arg) : hsprop | [
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 mem_correspondence (args:list arg) : hsprop =
match args with
| [] -> fun h s -> True
| hd :: tl ->
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ ->
fun h s ->
mem_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_ImmBuffer src bt _ ->
fun h s ->
mem_imm_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_Base _ ->
mem_correspondence tl | val mem_correspondence (args: list arg) : hsprop
let rec mem_correspondence (args: list arg) : hsprop = | false | null | false | match args with
| [] -> fun h s -> True
| hd :: tl ->
let (| tag , x |) = hd in
match tag with
| TD_Buffer src bt _ -> fun h s -> mem_correspondence_1 src bt x h s /\ mem_correspondence tl h s
| TD_ImmBuffer src bt _ ->
fun h s -> mem_imm_correspondence_1 src bt x h s /\ mem_correspondence tl h s
| TD_Base _ -> mem_correspondence tl | {
"checked_file": "Vale.AsLowStar.LowStarSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Regs.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.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.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.LowStarSig.fst"
} | [
"total"
] | [
"Prims.list",
"Vale.Interop.Base.arg",
"FStar.Monotonic.HyperStack.mem",
"Vale.X64.State.vale_state",
"Prims.l_True",
"Prims.prop",
"Vale.Interop.Base.td",
"Vale.Interop.Base.td_as_type",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Prims.l_and",
"Vale.AsLowStar.LowStarSig.mem_correspondence_1",
"Vale.AsLowStar.LowStarSig.mem_correspondence",
"Vale.AsLowStar.LowStarSig.mem_imm_correspondence_1",
"Vale.Interop.Base.valid_base_type",
"Vale.AsLowStar.LowStarSig.hsprop"
] | [] | module Vale.AsLowStar.LowStarSig
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module Map16 = Vale.Lib.Map16
open FStar.Mul
[@__reduce__]
let nat_to_uint (t:ME.base_typ) (x:ME.base_typ_as_vale_type t)
: base_typ_as_type t
= let open ME in
match t with
| TUInt8 -> UInt8.uint_to_t x
| TUInt16 -> UInt16.uint_to_t x
| TUInt32 -> UInt32.uint_to_t x
| TUInt64 -> UInt64.uint_to_t x
| TUInt128 -> x
let uint_to_nat (t:ME.base_typ) (x:base_typ_as_type t)
: ME.base_typ_as_vale_type t
= let open ME in
match t with
| TUInt8 -> UInt8.v x
| TUInt16 -> UInt16.v x
| TUInt32 -> UInt32.v x
| TUInt64 -> UInt64.v x
| TUInt128 -> x
let nat_to_uint_seq_t
(t:ME.base_typ)
(b:Seq.seq (ME.base_typ_as_vale_type t))
: Seq.seq (base_typ_as_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> nat_to_uint t (Seq.index b i))
let uint_to_nat_seq_t
(t:ME.base_typ)
(b:Seq.seq (base_typ_as_type t))
: Seq.seq (ME.base_typ_as_vale_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> uint_to_nat t (Seq.index b i))
[@__reduce__]
let view_of_base_typ (t:ME.base_typ)
: UV.view UInt8.t (base_typ_as_type t)
= let open ME in
match t with
| TUInt8 -> Vale.Interop.Views.up_view8
| TUInt16 -> Vale.Interop.Views.up_view16
| TUInt32 -> Vale.Interop.Views.up_view32
| TUInt64 -> Vale.Interop.Views.up_view64
| TUInt128 -> Vale.Interop.Views.up_view128
//////////////////////////////////////////////////////////////////////////////////////////
//lowstar_sig pre post:
// Interepreting a vale pre/post as a Low* function type
//////////////////////////////////////////////////////////////////////////////////////////
let hprop = HS.mem -> prop
let hsprop = HS.mem -> VS.vale_state -> prop
module IB = Vale.Interop.Base
[@__reduce__]
let mem_correspondence_1
(src t:ME.base_typ)
(x:IB.buf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_buffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__]
let mem_imm_correspondence_1
(src t:ME.base_typ)
(x:IB.ibuf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_immbuffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__] | false | true | Vale.AsLowStar.LowStarSig.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mem_correspondence (args: list arg) : hsprop | [
"recursion"
] | Vale.AsLowStar.LowStarSig.mem_correspondence | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.LowStarSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | args: Prims.list Vale.Interop.Base.arg -> Vale.AsLowStar.LowStarSig.hsprop | {
"end_col": 27,
"end_line": 118,
"start_col": 2,
"start_line": 104
} |
Prims.Tot | val nat_to_uint (t: ME.base_typ) (x: ME.base_typ_as_vale_type t) : base_typ_as_type t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 nat_to_uint (t:ME.base_typ) (x:ME.base_typ_as_vale_type t)
: base_typ_as_type t
= let open ME in
match t with
| TUInt8 -> UInt8.uint_to_t x
| TUInt16 -> UInt16.uint_to_t x
| TUInt32 -> UInt32.uint_to_t x
| TUInt64 -> UInt64.uint_to_t x
| TUInt128 -> x | val nat_to_uint (t: ME.base_typ) (x: ME.base_typ_as_vale_type t) : base_typ_as_type t
let nat_to_uint (t: ME.base_typ) (x: ME.base_typ_as_vale_type t) : base_typ_as_type t = | false | null | false | let open ME in
match t with
| TUInt8 -> UInt8.uint_to_t x
| TUInt16 -> UInt16.uint_to_t x
| TUInt32 -> UInt32.uint_to_t x
| TUInt64 -> UInt64.uint_to_t x
| TUInt128 -> x | {
"checked_file": "Vale.AsLowStar.LowStarSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Regs.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.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.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.LowStarSig.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.base_typ_as_vale_type",
"FStar.UInt8.uint_to_t",
"FStar.UInt16.uint_to_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt64.uint_to_t",
"Vale.Interop.Types.base_typ_as_type"
] | [] | module Vale.AsLowStar.LowStarSig
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module Map16 = Vale.Lib.Map16
open FStar.Mul
[@__reduce__]
let nat_to_uint (t:ME.base_typ) (x:ME.base_typ_as_vale_type t) | false | false | Vale.AsLowStar.LowStarSig.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_to_uint (t: ME.base_typ) (x: ME.base_typ_as_vale_type t) : base_typ_as_type t | [] | Vale.AsLowStar.LowStarSig.nat_to_uint | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.LowStarSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> x: Vale.X64.Memory.base_typ_as_vale_type t
-> Vale.Interop.Types.base_typ_as_type t | {
"end_col": 19,
"end_line": 30,
"start_col": 4,
"start_line": 24
} |
Prims.Tot | val stack_args (max_arity n: nat) (args: list arg {List.Tot.length args = n}) : VSig.sprop | [
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 stack_args (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
: VSig.sprop =
match args with
| [] -> (fun s -> True)
| hd::tl ->
fun s ->
stack_args max_arity (n - 1) tl s /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ VS.eval_reg_64 MS.rRsp s
in
SI.valid_stack_slot64 ptr s.VS.vs_stack MS.Public s.VS.vs_stackTaint /\
SI.load_stack64 ptr s.VS.vs_stack == arg_as_nat64 hd s) | val stack_args (max_arity n: nat) (args: list arg {List.Tot.length args = n}) : VSig.sprop
let rec stack_args (max_arity n: nat) (args: list arg {List.Tot.length args = n}) : VSig.sprop = | false | null | false | match args with
| [] -> (fun s -> True)
| hd :: tl ->
fun s ->
stack_args max_arity (n - 1) tl s /\
(if n <= max_arity
then True
else
let ptr =
((n - max_arity) - 1) * 8 + (if IA.win then 32 else 0) + 8 + VS.eval_reg_64 MS.rRsp s
in
SI.valid_stack_slot64 ptr s.VS.vs_stack MS.Public s.VS.vs_stackTaint /\
SI.load_stack64 ptr s.VS.vs_stack == arg_as_nat64 hd s) | {
"checked_file": "Vale.AsLowStar.LowStarSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Regs.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.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.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.LowStarSig.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.list",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_Equality",
"FStar.List.Tot.Base.length",
"Vale.X64.State.vale_state",
"Prims.l_True",
"Prims.prop",
"Prims.l_and",
"Vale.AsLowStar.LowStarSig.stack_args",
"Prims.op_Subtraction",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"Vale.X64.Stack_i.valid_stack_slot64",
"Vale.X64.State.__proj__Mkvale_state__item__vs_stack",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint",
"Prims.eq2",
"Vale.X64.Memory.nat64",
"Vale.X64.Stack_i.load_stack64",
"Vale.AsLowStar.LowStarSig.arg_as_nat64",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Vale.Interop.Assumptions.win",
"Vale.X64.State.eval_reg_64",
"Vale.X64.Machine_s.rRsp",
"Prims.logical",
"Vale.AsLowStar.ValeSig.sprop"
] | [] | module Vale.AsLowStar.LowStarSig
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module Map16 = Vale.Lib.Map16
open FStar.Mul
[@__reduce__]
let nat_to_uint (t:ME.base_typ) (x:ME.base_typ_as_vale_type t)
: base_typ_as_type t
= let open ME in
match t with
| TUInt8 -> UInt8.uint_to_t x
| TUInt16 -> UInt16.uint_to_t x
| TUInt32 -> UInt32.uint_to_t x
| TUInt64 -> UInt64.uint_to_t x
| TUInt128 -> x
let uint_to_nat (t:ME.base_typ) (x:base_typ_as_type t)
: ME.base_typ_as_vale_type t
= let open ME in
match t with
| TUInt8 -> UInt8.v x
| TUInt16 -> UInt16.v x
| TUInt32 -> UInt32.v x
| TUInt64 -> UInt64.v x
| TUInt128 -> x
let nat_to_uint_seq_t
(t:ME.base_typ)
(b:Seq.seq (ME.base_typ_as_vale_type t))
: Seq.seq (base_typ_as_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> nat_to_uint t (Seq.index b i))
let uint_to_nat_seq_t
(t:ME.base_typ)
(b:Seq.seq (base_typ_as_type t))
: Seq.seq (ME.base_typ_as_vale_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> uint_to_nat t (Seq.index b i))
[@__reduce__]
let view_of_base_typ (t:ME.base_typ)
: UV.view UInt8.t (base_typ_as_type t)
= let open ME in
match t with
| TUInt8 -> Vale.Interop.Views.up_view8
| TUInt16 -> Vale.Interop.Views.up_view16
| TUInt32 -> Vale.Interop.Views.up_view32
| TUInt64 -> Vale.Interop.Views.up_view64
| TUInt128 -> Vale.Interop.Views.up_view128
//////////////////////////////////////////////////////////////////////////////////////////
//lowstar_sig pre post:
// Interepreting a vale pre/post as a Low* function type
//////////////////////////////////////////////////////////////////////////////////////////
let hprop = HS.mem -> prop
let hsprop = HS.mem -> VS.vale_state -> prop
module IB = Vale.Interop.Base
[@__reduce__]
let mem_correspondence_1
(src t:ME.base_typ)
(x:IB.buf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_buffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__]
let mem_imm_correspondence_1
(src t:ME.base_typ)
(x:IB.ibuf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_immbuffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__]
let rec mem_correspondence (args:list arg) : hsprop =
match args with
| [] -> fun h s -> True
| hd :: tl ->
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ ->
fun h s ->
mem_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_ImmBuffer src bt _ ->
fun h s ->
mem_imm_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_Base _ ->
mem_correspondence tl
[@__reduce__]
let arg_as_nat64 (a:arg) (s:VS.vale_state) : GTot ME.nat64 =
let (| tag, x |) = a in
let open ME in
match tag with
| TD_Base TUInt8 ->
UInt8.v x
| TD_Base TUInt16 ->
UInt16.v x
| TD_Base TUInt32 ->
UInt32.v x
| TD_Base TUInt64 ->
UInt64.v x
| TD_Buffer src bt _ ->
buffer_addr_is_nat64 (as_vale_buffer #src #bt x) s;
ME.buffer_addr (as_vale_buffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap)
| TD_ImmBuffer src bt _ ->
buffer_addr_is_nat64 (as_vale_immbuffer #src #bt x) s;
ME.buffer_addr (as_vale_immbuffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap)
[@__reduce__]
let rec register_args (max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.Tot.length args = n}) : VSig.sprop =
match args with
| [] -> (fun s -> True)
| hd::tl ->
fun s ->
register_args max_arity arg_reg (n - 1) tl s /\
(if n > max_arity then True // This arg is passed on the stack
else VS.eval_reg_64 (arg_reg.IX64.of_arg (n - 1)) s == arg_as_nat64 hd s)
[@__reduce__]
let rec stack_args (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n}) | false | false | Vale.AsLowStar.LowStarSig.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stack_args (max_arity n: nat) (args: list arg {List.Tot.length args = n}) : VSig.sprop | [
"recursion"
] | Vale.AsLowStar.LowStarSig.stack_args | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.LowStarSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
max_arity: Prims.nat ->
n: Prims.nat ->
args: Prims.list Vale.Interop.Base.arg {FStar.List.Tot.Base.length args = n}
-> Vale.AsLowStar.ValeSig.sprop | {
"end_col": 66,
"end_line": 172,
"start_col": 4,
"start_line": 159
} |
Prims.Tot | val register_args
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.Tot.length args = n})
: VSig.sprop | [
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 register_args (max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.Tot.length args = n}) : VSig.sprop =
match args with
| [] -> (fun s -> True)
| hd::tl ->
fun s ->
register_args max_arity arg_reg (n - 1) tl s /\
(if n > max_arity then True // This arg is passed on the stack
else VS.eval_reg_64 (arg_reg.IX64.of_arg (n - 1)) s == arg_as_nat64 hd s) | val register_args
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.Tot.length args = n})
: VSig.sprop
let rec register_args
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.Tot.length args = n})
: VSig.sprop = | false | null | false | match args with
| [] -> (fun s -> True)
| hd :: tl ->
fun s ->
register_args max_arity arg_reg (n - 1) tl s /\
(if n > max_arity
then True
else VS.eval_reg_64 (arg_reg.IX64.of_arg (n - 1)) s == arg_as_nat64 hd s) | {
"checked_file": "Vale.AsLowStar.LowStarSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Regs.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.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.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.LowStarSig.fst"
} | [
"total"
] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Prims.list",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_Equality",
"FStar.List.Tot.Base.length",
"Vale.X64.State.vale_state",
"Prims.l_True",
"Prims.prop",
"Prims.l_and",
"Vale.AsLowStar.LowStarSig.register_args",
"Prims.op_Subtraction",
"Prims.op_GreaterThan",
"Prims.bool",
"Prims.eq2",
"Vale.X64.Memory.nat64",
"Vale.X64.State.eval_reg_64",
"Vale.Interop.X64.__proj__Rel__item__of_arg",
"Vale.AsLowStar.LowStarSig.arg_as_nat64",
"Prims.logical",
"Vale.AsLowStar.ValeSig.sprop"
] | [] | module Vale.AsLowStar.LowStarSig
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module Map16 = Vale.Lib.Map16
open FStar.Mul
[@__reduce__]
let nat_to_uint (t:ME.base_typ) (x:ME.base_typ_as_vale_type t)
: base_typ_as_type t
= let open ME in
match t with
| TUInt8 -> UInt8.uint_to_t x
| TUInt16 -> UInt16.uint_to_t x
| TUInt32 -> UInt32.uint_to_t x
| TUInt64 -> UInt64.uint_to_t x
| TUInt128 -> x
let uint_to_nat (t:ME.base_typ) (x:base_typ_as_type t)
: ME.base_typ_as_vale_type t
= let open ME in
match t with
| TUInt8 -> UInt8.v x
| TUInt16 -> UInt16.v x
| TUInt32 -> UInt32.v x
| TUInt64 -> UInt64.v x
| TUInt128 -> x
let nat_to_uint_seq_t
(t:ME.base_typ)
(b:Seq.seq (ME.base_typ_as_vale_type t))
: Seq.seq (base_typ_as_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> nat_to_uint t (Seq.index b i))
let uint_to_nat_seq_t
(t:ME.base_typ)
(b:Seq.seq (base_typ_as_type t))
: Seq.seq (ME.base_typ_as_vale_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> uint_to_nat t (Seq.index b i))
[@__reduce__]
let view_of_base_typ (t:ME.base_typ)
: UV.view UInt8.t (base_typ_as_type t)
= let open ME in
match t with
| TUInt8 -> Vale.Interop.Views.up_view8
| TUInt16 -> Vale.Interop.Views.up_view16
| TUInt32 -> Vale.Interop.Views.up_view32
| TUInt64 -> Vale.Interop.Views.up_view64
| TUInt128 -> Vale.Interop.Views.up_view128
//////////////////////////////////////////////////////////////////////////////////////////
//lowstar_sig pre post:
// Interepreting a vale pre/post as a Low* function type
//////////////////////////////////////////////////////////////////////////////////////////
let hprop = HS.mem -> prop
let hsprop = HS.mem -> VS.vale_state -> prop
module IB = Vale.Interop.Base
[@__reduce__]
let mem_correspondence_1
(src t:ME.base_typ)
(x:IB.buf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_buffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__]
let mem_imm_correspondence_1
(src t:ME.base_typ)
(x:IB.ibuf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_immbuffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__]
let rec mem_correspondence (args:list arg) : hsprop =
match args with
| [] -> fun h s -> True
| hd :: tl ->
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ ->
fun h s ->
mem_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_ImmBuffer src bt _ ->
fun h s ->
mem_imm_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_Base _ ->
mem_correspondence tl
[@__reduce__]
let arg_as_nat64 (a:arg) (s:VS.vale_state) : GTot ME.nat64 =
let (| tag, x |) = a in
let open ME in
match tag with
| TD_Base TUInt8 ->
UInt8.v x
| TD_Base TUInt16 ->
UInt16.v x
| TD_Base TUInt32 ->
UInt32.v x
| TD_Base TUInt64 ->
UInt64.v x
| TD_Buffer src bt _ ->
buffer_addr_is_nat64 (as_vale_buffer #src #bt x) s;
ME.buffer_addr (as_vale_buffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap)
| TD_ImmBuffer src bt _ ->
buffer_addr_is_nat64 (as_vale_immbuffer #src #bt x) s;
ME.buffer_addr (as_vale_immbuffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap)
[@__reduce__]
let rec register_args (max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat) | false | false | Vale.AsLowStar.LowStarSig.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val register_args
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.Tot.length args = n})
: VSig.sprop | [
"recursion"
] | Vale.AsLowStar.LowStarSig.register_args | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.LowStarSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
max_arity: Prims.nat ->
arg_reg: Vale.Interop.X64.arg_reg_relation max_arity ->
n: Prims.nat ->
args: Prims.list Vale.Interop.Base.arg {FStar.List.Tot.Base.length args = n}
-> Vale.AsLowStar.ValeSig.sprop | {
"end_col": 82,
"end_line": 152,
"start_col": 4,
"start_line": 146
} |
Prims.Tot | val uint_to_nat (t: ME.base_typ) (x: base_typ_as_type t) : ME.base_typ_as_vale_type t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 uint_to_nat (t:ME.base_typ) (x:base_typ_as_type t)
: ME.base_typ_as_vale_type t
= let open ME in
match t with
| TUInt8 -> UInt8.v x
| TUInt16 -> UInt16.v x
| TUInt32 -> UInt32.v x
| TUInt64 -> UInt64.v x
| TUInt128 -> x | val uint_to_nat (t: ME.base_typ) (x: base_typ_as_type t) : ME.base_typ_as_vale_type t
let uint_to_nat (t: ME.base_typ) (x: base_typ_as_type t) : ME.base_typ_as_vale_type t = | false | null | false | let open ME in
match t with
| TUInt8 -> UInt8.v x
| TUInt16 -> UInt16.v x
| TUInt32 -> UInt32.v x
| TUInt64 -> UInt64.v x
| TUInt128 -> x | {
"checked_file": "Vale.AsLowStar.LowStarSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Regs.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.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.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.LowStarSig.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Types.base_typ_as_type",
"FStar.UInt8.v",
"FStar.UInt16.v",
"FStar.UInt32.v",
"FStar.UInt64.v",
"Vale.X64.Memory.base_typ_as_vale_type"
] | [] | module Vale.AsLowStar.LowStarSig
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module Map16 = Vale.Lib.Map16
open FStar.Mul
[@__reduce__]
let nat_to_uint (t:ME.base_typ) (x:ME.base_typ_as_vale_type t)
: base_typ_as_type t
= let open ME in
match t with
| TUInt8 -> UInt8.uint_to_t x
| TUInt16 -> UInt16.uint_to_t x
| TUInt32 -> UInt32.uint_to_t x
| TUInt64 -> UInt64.uint_to_t x
| TUInt128 -> x
let uint_to_nat (t:ME.base_typ) (x:base_typ_as_type t) | false | false | Vale.AsLowStar.LowStarSig.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_to_nat (t: ME.base_typ) (x: base_typ_as_type t) : ME.base_typ_as_vale_type t | [] | Vale.AsLowStar.LowStarSig.uint_to_nat | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.LowStarSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> x: Vale.Interop.Types.base_typ_as_type t
-> Vale.X64.Memory.base_typ_as_vale_type t | {
"end_col": 19,
"end_line": 41,
"start_col": 4,
"start_line": 35
} |
Prims.GTot | val arg_as_nat64 (a: arg) (s: VS.vale_state) : GTot ME.nat64 | [
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 arg_as_nat64 (a:arg) (s:VS.vale_state) : GTot ME.nat64 =
let (| tag, x |) = a in
let open ME in
match tag with
| TD_Base TUInt8 ->
UInt8.v x
| TD_Base TUInt16 ->
UInt16.v x
| TD_Base TUInt32 ->
UInt32.v x
| TD_Base TUInt64 ->
UInt64.v x
| TD_Buffer src bt _ ->
buffer_addr_is_nat64 (as_vale_buffer #src #bt x) s;
ME.buffer_addr (as_vale_buffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap)
| TD_ImmBuffer src bt _ ->
buffer_addr_is_nat64 (as_vale_immbuffer #src #bt x) s;
ME.buffer_addr (as_vale_immbuffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap) | val arg_as_nat64 (a: arg) (s: VS.vale_state) : GTot ME.nat64
let arg_as_nat64 (a: arg) (s: VS.vale_state) : GTot ME.nat64 = | false | null | false | let (| tag , x |) = a in
let open ME in
match tag with
| TD_Base TUInt8 -> UInt8.v x
| TD_Base TUInt16 -> UInt16.v x
| TD_Base TUInt32 -> UInt32.v x
| TD_Base TUInt64 -> UInt64.v x
| TD_Buffer src bt _ ->
buffer_addr_is_nat64 (as_vale_buffer #src #bt x) s;
ME.buffer_addr (as_vale_buffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap)
| TD_ImmBuffer src bt _ ->
buffer_addr_is_nat64 (as_vale_immbuffer #src #bt x) s;
ME.buffer_addr (as_vale_immbuffer #src #bt x) (ME.get_vale_heap s.VS.vs_heap) | {
"checked_file": "Vale.AsLowStar.LowStarSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Regs.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.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.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.LowStarSig.fst"
} | [
"sometrivial"
] | [
"Vale.Interop.Base.arg",
"Vale.X64.State.vale_state",
"Vale.Interop.Base.td",
"Vale.Interop.Base.td_as_type",
"FStar.UInt8.v",
"FStar.UInt16.v",
"FStar.UInt32.v",
"FStar.UInt64.v",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.X64.Memory.buffer_addr",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.X64.Memory.get_vale_heap",
"Vale.X64.State.__proj__Mkvale_state__item__vs_heap",
"Prims.unit",
"Vale.X64.MemoryAdapters.buffer_addr_is_nat64",
"Vale.X64.MemoryAdapters.as_vale_immbuffer",
"Vale.X64.Memory.nat64"
] | [] | module Vale.AsLowStar.LowStarSig
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module Map16 = Vale.Lib.Map16
open FStar.Mul
[@__reduce__]
let nat_to_uint (t:ME.base_typ) (x:ME.base_typ_as_vale_type t)
: base_typ_as_type t
= let open ME in
match t with
| TUInt8 -> UInt8.uint_to_t x
| TUInt16 -> UInt16.uint_to_t x
| TUInt32 -> UInt32.uint_to_t x
| TUInt64 -> UInt64.uint_to_t x
| TUInt128 -> x
let uint_to_nat (t:ME.base_typ) (x:base_typ_as_type t)
: ME.base_typ_as_vale_type t
= let open ME in
match t with
| TUInt8 -> UInt8.v x
| TUInt16 -> UInt16.v x
| TUInt32 -> UInt32.v x
| TUInt64 -> UInt64.v x
| TUInt128 -> x
let nat_to_uint_seq_t
(t:ME.base_typ)
(b:Seq.seq (ME.base_typ_as_vale_type t))
: Seq.seq (base_typ_as_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> nat_to_uint t (Seq.index b i))
let uint_to_nat_seq_t
(t:ME.base_typ)
(b:Seq.seq (base_typ_as_type t))
: Seq.seq (ME.base_typ_as_vale_type t)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> uint_to_nat t (Seq.index b i))
[@__reduce__]
let view_of_base_typ (t:ME.base_typ)
: UV.view UInt8.t (base_typ_as_type t)
= let open ME in
match t with
| TUInt8 -> Vale.Interop.Views.up_view8
| TUInt16 -> Vale.Interop.Views.up_view16
| TUInt32 -> Vale.Interop.Views.up_view32
| TUInt64 -> Vale.Interop.Views.up_view64
| TUInt128 -> Vale.Interop.Views.up_view128
//////////////////////////////////////////////////////////////////////////////////////////
//lowstar_sig pre post:
// Interepreting a vale pre/post as a Low* function type
//////////////////////////////////////////////////////////////////////////////////////////
let hprop = HS.mem -> prop
let hsprop = HS.mem -> VS.vale_state -> prop
module IB = Vale.Interop.Base
[@__reduce__]
let mem_correspondence_1
(src t:ME.base_typ)
(x:IB.buf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_buffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__]
let mem_imm_correspondence_1
(src t:ME.base_typ)
(x:IB.ibuf_t src t)
(h:HS.mem)
(s:VS.vale_state) =
let y = as_vale_immbuffer x in
let db = get_downview x in
DV.length_eq db;
Seq.equal
(nat_to_uint_seq_t t (ME.buffer_as_seq (ME.get_vale_heap s.VS.vs_heap) y))
(UV.as_seq h (UV.mk_buffer db (view_of_base_typ t)))
[@__reduce__]
let rec mem_correspondence (args:list arg) : hsprop =
match args with
| [] -> fun h s -> True
| hd :: tl ->
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ ->
fun h s ->
mem_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_ImmBuffer src bt _ ->
fun h s ->
mem_imm_correspondence_1 src bt x h s /\
mem_correspondence tl h s
| TD_Base _ ->
mem_correspondence tl | false | false | Vale.AsLowStar.LowStarSig.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val arg_as_nat64 (a: arg) (s: VS.vale_state) : GTot ME.nat64 | [] | Vale.AsLowStar.LowStarSig.arg_as_nat64 | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.LowStarSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Vale.Interop.Base.arg -> s: Vale.X64.State.vale_state -> Prims.GTot Vale.X64.Memory.nat64 | {
"end_col": 82,
"end_line": 138,
"start_col": 60,
"start_line": 121
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 uint8 = Lib.IntTypes.uint8 | let uint8 = | false | null | false | Lib.IntTypes.uint8 | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint8"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint8 : Type0 | [] | Hacl.Streaming.Keccak.uint8 | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 30,
"end_line": 22,
"start_col": 12,
"start_line": 22
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 alg = keccak_alg | let alg = | false | null | false | keccak_alg | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.keccak_alg"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function. | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val alg : Type0 | [] | Hacl.Streaming.Keccak.alg | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 20,
"end_line": 48,
"start_col": 10,
"start_line": 48
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 hash_buf2 = hash_buf & hash_buf | let hash_buf2 = | false | null | false | hash_buf & hash_buf | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Hacl.Streaming.Keccak.hash_buf"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_buf2 : Type0 | [] | Hacl.Streaming.Keccak.hash_buf2 | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 35,
"end_line": 85,
"start_col": 16,
"start_line": 85
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 uint32 = Lib.IntTypes.uint32 | let uint32 = | false | null | false | Lib.IntTypes.uint32 | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint32"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8 | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint32 : Type0 | [] | Hacl.Streaming.Keccak.uint32 | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 32,
"end_line": 25,
"start_col": 13,
"start_line": 25
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 #t (x: t) = y:t { y == x } | let singleton #t (x: t) = | false | null | false | y: t{y == x} | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Prims.eq2"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val singleton : x: t -> Type | [] | Hacl.Streaming.Keccak.singleton | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: t -> Type | {
"end_col": 40,
"end_line": 81,
"start_col": 26,
"start_line": 81
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 hash_buf = hash_alg & B.buffer uint64 | let hash_buf = | false | null | false | hash_alg & B.buffer uint64 | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Spec.Hash.Definitions.hash_alg",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Keccak.uint64"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x } | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_buf : Type0 | [] | Hacl.Streaming.Keccak.hash_buf | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 41,
"end_line": 84,
"start_col": 15,
"start_line": 84
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul } | let sha3_state a = | false | null | false | singleton a & b: B.buffer uint64 {B.len b == 25ul} | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Hacl.Streaming.Keccak.singleton",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Keccak.uint64",
"Prims.eq2",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256 | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha3_state : a: _ -> Type | [] | Hacl.Streaming.Keccak.sha3_state | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: _ -> Type | {
"end_col": 70,
"end_line": 190,
"start_col": 19,
"start_line": 190
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 uint64 = Lib.IntTypes.uint64 | let uint64 = | false | null | false | Lib.IntTypes.uint64 | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint64"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32 | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint64 : Type0 | [] | Hacl.Streaming.Keccak.uint64 | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 32,
"end_line": 28,
"start_col": 13,
"start_line": 28
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 is_shake_ a = a = Shake128 || a = Shake256 | let is_shake_ a = | false | null | false | a = Shake128 || a = Shake256 | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.op_BarBar",
"Prims.op_Equality",
"Spec.Hash.Definitions.Shake128",
"Spec.Hash.Definitions.Shake256",
"Prims.bool"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul) | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_shake_ : a: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Hacl.Streaming.Keccak.is_shake_ | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 46,
"end_line": 118,
"start_col": 18,
"start_line": 118
} |
|
Prims.Tot | val coerce (#b #a: Type) (x: a{a == b}) : b | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 coerce (#b #a:Type) (x:a{a == b}) : b = x | val coerce (#b #a: Type) (x: a{a == b}) : b
let coerce (#b #a: Type) (x: a{a == b}) : b = | false | null | false | x | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Prims.eq2"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val coerce (#b #a: Type) (x: a{a == b}) : b | [] | Hacl.Streaming.Keccak.coerce | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: a{a == b} -> b | {
"end_col": 52,
"end_line": 50,
"start_col": 51,
"start_line": 50
} |
FStar.HyperStack.ST.Stack | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_alg (a: G.erased alg) =
F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | let get_alg (a: G.erased alg) = | true | null | false | F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [] | [
"FStar.Ghost.erased",
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Functor.index_of_state",
"Hacl.Streaming.Keccak.hacl_keccak",
"Hacl.Streaming.Keccak.sha3_state",
"FStar.Ghost.reveal",
"Prims.unit",
"Hacl.Streaming.Functor.state",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Streaming.Functor.invariant",
"Prims.l_and",
"Prims.eq2"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256
let sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul } | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_alg : a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg ->
s:
Hacl.Streaming.Functor.state (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit)
-> FStar.HyperStack.ST.Stack Hacl.Streaming.Keccak.alg | [] | Hacl.Streaming.Keccak.get_alg | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg ->
s:
Hacl.Streaming.Functor.state (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit)
-> FStar.HyperStack.ST.Stack Hacl.Streaming.Keccak.alg | {
"end_col": 78,
"end_line": 193,
"start_col": 2,
"start_line": 193
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 reset (a: G.erased alg) =
F.init (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | let reset (a: G.erased alg) = | false | null | false | F.init (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Functor.init",
"Hacl.Streaming.Keccak.hacl_keccak",
"Hacl.Streaming.Keccak.sha3_state",
"FStar.Ghost.reveal",
"Prims.unit",
"Hacl.Streaming.Functor.init_st",
"FStar.Ghost.hide"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256
let sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul }
let get_alg (a: G.erased alg) =
F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let malloc (a: alg) =
F.create_in (hacl_keccak a) a (sha3_state a) (G.erased unit)
let free (a: G.erased alg) =
F.free (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let copy (a: G.erased alg) =
F.copy (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val reset : a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.init_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.hide (FStar.Ghost.reveal a))
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.Keccak.reset | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.init_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.hide (FStar.Ghost.reveal a))
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | {
"end_col": 68,
"end_line": 205,
"start_col": 2,
"start_line": 205
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 copy (a: G.erased alg) =
F.copy (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | let copy (a: G.erased alg) = | false | null | false | F.copy (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Functor.copy",
"Hacl.Streaming.Keccak.hacl_keccak",
"Hacl.Streaming.Keccak.sha3_state",
"FStar.Ghost.reveal",
"Prims.unit",
"Hacl.Streaming.Functor.copy_st"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256
let sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul }
let get_alg (a: G.erased alg) =
F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let malloc (a: alg) =
F.create_in (hacl_keccak a) a (sha3_state a) (G.erased unit)
let free (a: G.erased alg) =
F.free (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val copy : a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.copy_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.Keccak.copy | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.copy_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | {
"end_col": 68,
"end_line": 202,
"start_col": 2,
"start_line": 202
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 malloc (a: alg) =
F.create_in (hacl_keccak a) a (sha3_state a) (G.erased unit) | let malloc (a: alg) = | false | null | false | F.create_in (hacl_keccak a) a (sha3_state a) (G.erased unit) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Functor.create_in",
"Hacl.Streaming.Keccak.hacl_keccak",
"FStar.Ghost.hide",
"Hacl.Streaming.Keccak.sha3_state",
"FStar.Ghost.erased",
"Prims.unit",
"Hacl.Streaming.Functor.create_in_st"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256
let sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul }
let get_alg (a: G.erased alg) =
F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val malloc : a: Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.create_in_st (Hacl.Streaming.Keccak.hacl_keccak (FStar.Ghost.hide a))
a
(Hacl.Streaming.Keccak.sha3_state a)
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.Keccak.malloc | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.create_in_st (Hacl.Streaming.Keccak.hacl_keccak (FStar.Ghost.hide a))
a
(Hacl.Streaming.Keccak.sha3_state a)
(FStar.Ghost.erased Prims.unit) | {
"end_col": 62,
"end_line": 196,
"start_col": 2,
"start_line": 196
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 update (a: G.erased alg) =
F.update (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | let update (a: G.erased alg) = | false | null | false | F.update (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Functor.update",
"Hacl.Streaming.Keccak.hacl_keccak",
"Hacl.Streaming.Keccak.sha3_state",
"FStar.Ghost.reveal",
"Prims.unit",
"Hacl.Streaming.Functor.update_st"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256
let sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul }
let get_alg (a: G.erased alg) =
F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let malloc (a: alg) =
F.create_in (hacl_keccak a) a (sha3_state a) (G.erased unit)
let free (a: G.erased alg) =
F.free (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let copy (a: G.erased alg) =
F.copy (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let reset (a: G.erased alg) =
F.init (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update : a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.update_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.Keccak.update | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.update_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | {
"end_col": 70,
"end_line": 208,
"start_col": 2,
"start_line": 208
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 finish_ (a: alg) =
F.mk_finish #alg (hacl_keccak a) a (sha3_state a) (G.erased unit) | let finish_ (a: alg) = | false | null | false | F.mk_finish #alg (hacl_keccak a) a (sha3_state a) (G.erased unit) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Functor.mk_finish",
"Hacl.Streaming.Keccak.hacl_keccak",
"FStar.Ghost.hide",
"Hacl.Streaming.Keccak.sha3_state",
"FStar.Ghost.erased",
"Prims.unit",
"Hacl.Streaming.Functor.finish_st"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256
let sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul }
let get_alg (a: G.erased alg) =
F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let malloc (a: alg) =
F.create_in (hacl_keccak a) a (sha3_state a) (G.erased unit)
let free (a: G.erased alg) =
F.free (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let copy (a: G.erased alg) =
F.copy (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let reset (a: G.erased alg) =
F.init (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let update (a: G.erased alg) =
F.update (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
private | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finish_ : a: Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.finish_st (Hacl.Streaming.Keccak.hacl_keccak (FStar.Ghost.hide a))
a
(Hacl.Streaming.Keccak.sha3_state a)
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.Keccak.finish_ | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.finish_st (Hacl.Streaming.Keccak.hacl_keccak (FStar.Ghost.hide a))
a
(Hacl.Streaming.Keccak.sha3_state a)
(FStar.Ghost.erased Prims.unit) | {
"end_col": 67,
"end_line": 212,
"start_col": 2,
"start_line": 212
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input | let update_multi_s (a: alg) acc (prevlen: nat) input = | false | null | false | Agile.update_multi a acc () input | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Hacl.Streaming.Keccak.alg",
"Spec.Hash.Definitions.words_state",
"Prims.nat",
"Spec.Hash.Definitions.bytes_blocks",
"Spec.Agile.Hash.update_multi"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_s : a: Hacl.Streaming.Keccak.alg ->
acc: Spec.Hash.Definitions.words_state a ->
prevlen: Prims.nat ->
input: Spec.Hash.Definitions.bytes_blocks a
-> Spec.Hash.Definitions.words_state a | [] | Hacl.Streaming.Keccak.update_multi_s | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Streaming.Keccak.alg ->
acc: Spec.Hash.Definitions.words_state a ->
prevlen: Prims.nat ->
input: Spec.Hash.Definitions.bytes_blocks a
-> Spec.Hash.Definitions.words_state a | {
"end_col": 35,
"end_line": 54,
"start_col": 2,
"start_line": 54
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 free (a: G.erased alg) =
F.free (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | let free (a: G.erased alg) = | false | null | false | F.free (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Functor.free",
"Hacl.Streaming.Keccak.hacl_keccak",
"Hacl.Streaming.Keccak.sha3_state",
"FStar.Ghost.reveal",
"Prims.unit",
"Hacl.Streaming.Functor.free_st"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l))
// For pretty names in C
let state = F.state_s' (hacl_keccak SHA3_256) SHA3_256
let sha3_state a = singleton a & b:B.buffer uint64 { B.len b == 25ul }
let get_alg (a: G.erased alg) =
F.index_of_state (hacl_keccak a) a (sha3_state (G.reveal a)) (G.erased unit)
let malloc (a: alg) =
F.create_in (hacl_keccak a) a (sha3_state a) (G.erased unit) | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val free : a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.free_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.Keccak.free | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Functor.free_st (Hacl.Streaming.Keccak.hacl_keccak a)
(FStar.Ghost.reveal a)
(Hacl.Streaming.Keccak.sha3_state (FStar.Ghost.reveal a))
(FStar.Ghost.erased Prims.unit) | {
"end_col": 68,
"end_line": 199,
"start_col": 2,
"start_line": 199
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 state = F.state_s' (hacl_keccak SHA3_256) SHA3_256 | let state = | false | null | false | F.state_s' (hacl_keccak SHA3_256) SHA3_256 | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state_s'",
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Keccak.hacl_keccak",
"FStar.Ghost.hide",
"Spec.Hash.Definitions.SHA3_256"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract
let hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l)) | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state : Type0 | [] | Hacl.Streaming.Keccak.state | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 54,
"end_line": 188,
"start_col": 12,
"start_line": 188
} |
|
FStar.Pervasives.Lemma | val update_multi_zero (a: alg) (acc: _) (prevlen: nat)
: Lemma (update_multi_s a acc prevlen S.empty == acc) | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc | val update_multi_zero (a: alg) (acc: _) (prevlen: nat)
: Lemma (update_multi_s a acc prevlen S.empty == acc)
let update_multi_zero (a: alg) acc (prevlen: nat)
: Lemma (update_multi_s a acc prevlen S.empty == acc) = | false | null | true | Spec.Hash.Lemmas.update_multi_zero a acc | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"lemma"
] | [
"Hacl.Streaming.Keccak.alg",
"Spec.Hash.Definitions.words_state",
"Prims.nat",
"Spec.Hash.Lemmas.update_multi_zero",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Hacl.Streaming.Keccak.update_multi_s",
"FStar.Seq.Base.empty",
"Lib.IntTypes.uint8",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_zero (a: alg) (acc: _) (prevlen: nat)
: Lemma (update_multi_s a acc prevlen S.empty == acc) | [] | Hacl.Streaming.Keccak.update_multi_zero | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Streaming.Keccak.alg -> acc: Spec.Hash.Definitions.words_state a -> prevlen: Prims.nat
-> FStar.Pervasives.Lemma
(ensures Hacl.Streaming.Keccak.update_multi_s a acc prevlen FStar.Seq.Base.empty == acc) | {
"end_col": 95,
"end_line": 58,
"start_col": 55,
"start_line": 58
} |
Prims.Tot | val stateful_keccak:stateful alg | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul) | val stateful_keccak:stateful alg
let stateful_keccak:stateful alg = | false | null | false | Stateful (fun (a: alg) -> singleton a & b: B.buffer uint64 {B.len b == 25ul})
(fun #_ h (_, s) -> B.loc_addr_of_buffer s)
(fun #_ h (_, s) -> B.freeable s)
(fun #_ h (_, s) -> B.live h s)
(fun _ -> s: S.seq uint64 {S.length s == 25})
(fun _ h (a, s) -> B.as_seq h s)
(fun #_ h (_, s) -> ())
(fun #_ l (_, s) h0 h1 -> ())
(fun #_ l (_, s) h0 h1 -> ())
(fun (a: alg) -> a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(fun a r -> a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(fun _ (_, s) -> B.free s)
(fun _ (a, s_src) (a', s_dst) -> B.blit s_src 0ul s_dst 0ul 25ul) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"Hacl.Streaming.Interface.Stateful",
"Hacl.Streaming.Keccak.alg",
"FStar.Pervasives.Native.tuple2",
"Hacl.Streaming.Keccak.singleton",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Keccak.uint64",
"Prims.eq2",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.freeable",
"LowStar.Monotonic.Buffer.live",
"FStar.Seq.Base.seq",
"Prims.int",
"FStar.Seq.Base.length",
"LowStar.Monotonic.Buffer.as_seq",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"FStar.UInt32.uint_to_t",
"LowStar.Buffer.alloca",
"Lib.IntTypes.u64",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.l_and",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Buffer.malloc",
"LowStar.Monotonic.Buffer.frameOf",
"FStar.Ghost.erased",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.free",
"LowStar.Monotonic.Buffer.blit"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stateful_keccak:stateful alg | [] | Hacl.Streaming.Keccak.stateful_keccak | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.stateful Hacl.Streaming.Keccak.alg | {
"end_col": 38,
"end_line": 115,
"start_col": 2,
"start_line": 89
} |
FStar.Pervasives.Lemma | val update_multi_associative (a: alg) (acc: _) (prevlen1 prevlen2: nat) (input1 input2: S.seq uint8)
: Lemma
(requires
(prevlen1 % U32.v (D.block_len a) = 0 /\ S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\ prevlen2 = prevlen1 + S.length input1))
(ensures
(let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\ prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2 | val update_multi_associative (a: alg) (acc: _) (prevlen1 prevlen2: nat) (input1 input2: S.seq uint8)
: Lemma
(requires
(prevlen1 % U32.v (D.block_len a) = 0 /\ S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\ prevlen2 = prevlen1 + S.length input1))
(ensures
(let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\ prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input))
let update_multi_associative
(a: alg)
acc
(prevlen1: nat)
(prevlen2: nat)
(input1: S.seq uint8)
(input2: S.seq uint8)
: Lemma
(requires
(prevlen1 % U32.v (D.block_len a) = 0 /\ S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\ prevlen2 = prevlen1 + S.length input1))
(ensures
(let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\ prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) = | false | null | true | Spec.Hash.Lemmas.update_multi_associative a acc input1 input2 | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"lemma"
] | [
"Hacl.Streaming.Keccak.alg",
"Spec.Hash.Definitions.words_state",
"Prims.nat",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Interface.uint8",
"Spec.Hash.Lemmas.update_multi_associative",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.UInt32.v",
"Hacl.Hash.Definitions.block_len",
"FStar.Seq.Base.length",
"Prims.op_Addition",
"Prims.squash",
"Prims.eq2",
"Hacl.Streaming.Keccak.update_multi_s",
"FStar.Seq.Base.append",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 == | false | false | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_associative (a: alg) (acc: _) (prevlen1 prevlen2: nat) (input1 input2: S.seq uint8)
: Lemma
(requires
(prevlen1 % U32.v (D.block_len a) = 0 /\ S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\ prevlen2 = prevlen1 + S.length input1))
(ensures
(let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\ prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) | [] | Hacl.Streaming.Keccak.update_multi_associative | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Streaming.Keccak.alg ->
acc: Spec.Hash.Definitions.words_state a ->
prevlen1: Prims.nat ->
prevlen2: Prims.nat ->
input1: FStar.Seq.Base.seq Hacl.Streaming.Interface.uint8 ->
input2: FStar.Seq.Base.seq Hacl.Streaming.Interface.uint8
-> FStar.Pervasives.Lemma
(requires
prevlen1 % FStar.UInt32.v (Hacl.Hash.Definitions.block_len a) = 0 /\
FStar.Seq.Base.length input1 % FStar.UInt32.v (Hacl.Hash.Definitions.block_len a) = 0 /\
FStar.Seq.Base.length input2 % FStar.UInt32.v (Hacl.Hash.Definitions.block_len a) = 0 /\
prevlen2 = prevlen1 + FStar.Seq.Base.length input1)
(ensures
(let input = FStar.Seq.Base.append input1 input2 in
FStar.Seq.Base.length input % FStar.UInt32.v (Hacl.Hash.Definitions.block_len a) = 0 /\
prevlen2 % FStar.UInt32.v (Hacl.Hash.Definitions.block_len a) = 0 /\
Hacl.Streaming.Keccak.update_multi_s a
(Hacl.Streaming.Keccak.update_multi_s a acc prevlen1 input1)
prevlen2
input2 ==
Hacl.Streaming.Keccak.update_multi_s a acc prevlen1 input)) | {
"end_col": 63,
"end_line": 77,
"start_col": 2,
"start_line": 77
} |
Prims.Tot | val hacl_keccak (a: G.erased alg) : block alg | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": 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 hacl_keccak (a: G.erased alg): block alg =
Block
Erased
stateful_keccak (* state *)
(stateful_unused alg) (* key *)
Lib.IntTypes.(x:size_t { v x > 0 }) (* output_length_t *)
(fun _ ->
[@inline_let]
let max = Lib.IntTypes.(ones U64 PUB) in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max) (* max_input_len *)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a) (* output_length *)
Hacl.Hash.SHA3.block_len (* block_len *)
Hacl.Hash.SHA3.block_len (* blocks_state_len *)
(fun _ -> 0ul) (* init_input_len *)
(* init_input_s *)
(fun _ _ -> S.empty)
(* init_s *)
(fun a _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun a acc prevlen blocks ->
update_multi_s a acc prevlen blocks)
(* update_last_s *)
(fun a acc prevlen input -> Spec.Hash.Incremental.(update_last a acc () input))
(* finish_s *)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(fun a _ s l -> Spec.Agile.Hash.(hash' a s (if is_shake_ a then (Lib.IntTypes.v l) else ())))
(* update_multi_zero *)
(fun a h prevlen -> update_multi_zero a h prevlen)
(* update_multi_associative *)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input (if is_shake_ a then (Lib.IntTypes.v l) else ()))
(* index_of_state *)
(fun _ (a, _) -> a)
(* init *)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(* update_multi *)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(* update_last *)
(fun _ (a, s) _ last last_len ->
Hacl.Hash.SHA3.update_last a s () last last_len)
(* finish *)
(fun _ _ (a, s) dst l ->
Hacl.Hash.SHA3.(finish_keccak a s dst l)) | val hacl_keccak (a: G.erased alg) : block alg
let hacl_keccak (a: G.erased alg) : block alg = | false | null | false | Block Erased
stateful_keccak
(stateful_unused alg)
Lib.IntTypes.(x: size_t{v x > 0})
(fun _ ->
[@@ inline_let ]let max = let open Lib.IntTypes in ones U64 PUB in
assert (forall (a: alg). Hacl.Hash.Definitions.max_input_len64 a == max);
max)
(fun a l -> if is_shake_ a then Lib.IntTypes.v l else Spec.Hash.Definitions.hash_length a)
Hacl.Hash.SHA3.block_len
Hacl.Hash.SHA3.block_len
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a acc prevlen blocks -> update_multi_s a acc prevlen blocks)
(fun a acc prevlen input -> let open Spec.Hash.Incremental in update_last a acc () input)
(fun a _ acc l -> Spec.Agile.Hash.finish a acc (if is_shake_ a then (Lib.IntTypes.v l)))
(fun a _ s l -> let open Spec.Agile.Hash in hash' a s (if is_shake_ a then (Lib.IntTypes.v l)))
(fun a h prevlen -> update_multi_zero a h prevlen)
(fun a acc prevlen1 prevlen2 input1 input2 ->
update_multi_associative a acc prevlen1 prevlen2 input1 input2)
(fun a _ input l ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a
input
(if is_shake_ a then (Lib.IntTypes.v l)))
(fun _ (a, _) -> a)
(fun _ _ _ (a, s) -> Hacl.Hash.SHA3.init a s)
(fun _ (a, s) _ blocks len ->
Hacl.Hash.SHA3.update_multi a s () blocks (len `U32.div` Hacl.Hash.SHA3.(block_len a)))
(fun _ (a, s) _ last last_len -> Hacl.Hash.SHA3.update_last a s () last last_len)
(fun _ _ (a, s) dst l -> let open Hacl.Hash.SHA3 in finish_keccak a s dst l) | {
"checked_file": "Hacl.Streaming.Keccak.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.Keccak.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Streaming.Keccak.alg",
"Hacl.Streaming.Interface.Block",
"Hacl.Streaming.Interface.Erased",
"Hacl.Streaming.Keccak.stateful_keccak",
"Hacl.Streaming.Interface.stateful_unused",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"Prims._assert",
"Prims.l_Forall",
"Prims.eq2",
"FStar.UInt64.t",
"Prims.l_or",
"Prims.l_and",
"Prims.op_LessThan",
"FStar.UInt64.v",
"Spec.Hash.Definitions.less_than_max_input_length",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.U64",
"Lib.IntTypes.ones_v",
"Hacl.Hash.Definitions.max_input_len64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.ones",
"FStar.Integers.op_Greater",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"Hacl.Streaming.Keccak.is_shake_",
"Prims.bool",
"Spec.Hash.Definitions.hash_length",
"Lib.IntTypes.size_nat",
"Hacl.Hash.SHA3.block_len",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.t",
"FStar.Integers.op_Less_Equals",
"FStar.UInt32.v",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"FStar.Seq.Base.empty",
"Hacl.Streaming.Interface.uint8",
"FStar.Seq.Base.seq",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.Seq.Base.length",
"Spec.Agile.Hash.init",
"FStar.Integers.nat",
"FStar.Integers.op_Percent",
"FStar.Integers.op_Plus",
"Hacl.Streaming.Keccak.update_multi_s",
"Spec.Hash.Incremental.Definitions.update_last",
"Spec.Agile.Hash.finish",
"Spec.Hash.Definitions.output_length",
"Prims.nat",
"Spec.Agile.Hash.hash'",
"Hacl.Streaming.Keccak.update_multi_zero",
"Hacl.Streaming.Keccak.update_multi_associative",
"Spec.Hash.Incremental.hash_is_hash_incremental'",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.append",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"FStar.Ghost.reveal",
"Hacl.Streaming.Keccak.singleton",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Keccak.uint64",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.length",
"Hacl.Hash.SHA3.init",
"Hacl.Hash.SHA3.update_multi",
"FStar.UInt32.div",
"Hacl.Hash.SHA3.update_last",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Hash.SHA3.finish_keccak",
"Hacl.Streaming.Interface.block"
] | [] | module Hacl.Streaming.Keccak
open FStar.HyperStack.ST
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Types
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
inline_for_extraction noextract
let uint64 = Lib.IntTypes.uint64
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
/// This is a dedicated streaming API for the Keccak construction. The reason we
/// are not piggybacking on Hacl.Streaming.MD is that we want a *single* piece
/// of code that can deal with all 6 variants at runtime, as opposed to a
/// meta-programmed version that requires six instantiations each for each one
/// of the Keccak algorithms. Notably, this means that we keep the rate at
/// run-time (relying on the key), and that we request the outputByteLen for the
/// finish function.
inline_for_extraction noextract
let alg = keccak_alg
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
inline_for_extraction noextract
let update_multi_s (a : alg) acc (prevlen : nat) input =
Agile.update_multi a acc () input
noextract
let update_multi_zero (a : alg) acc (prevlen : nat) :
Lemma(update_multi_s a acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
// TODO: this is the fourth copy of this lemma!! why?!
#push-options "--ifuel 1"
noextract
let update_multi_associative (a : alg) acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
prevlen1 % U32.v (D.block_len a) = 0 /\
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0 /\
prevlen2 = prevlen1 + S.length input1))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
prevlen2 % U32.v (D.block_len a) = 0 /\
update_multi_s a (update_multi_s a acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let singleton #t (x: t) = y:t { y == x }
// Pretty C name
let hash_buf = hash_alg & B.buffer uint64
let hash_buf2 = hash_buf & hash_buf
inline_for_extraction noextract
let stateful_keccak: stateful alg =
Stateful
(* s: *) (fun (a: alg) ->
singleton a & b:B.buffer uint64 { B.len b == 25ul })
(* footprint: *) (fun #_ h (_, s) ->
B.loc_addr_of_buffer s)
(* freeable: *) (fun #_ h (_, s) ->
B.freeable s)
(* invariant: *) (fun #_ h (_, s) ->
B.live h s)
(* t: *) (fun _ ->
s:S.seq uint64 { S.length s == 25 })
(* v: *) (fun _ h (a, s) ->
B.as_seq h s)
(* invariant_loc_in_footprint: *) (fun #_ h (_, s) ->
())
(* frame_invariant: *) (fun #_ l (_, s) h0 h1 ->
())
(* frame_freeable: *) (fun #_ l (_, s) h0 h1 ->
())
(* alloca: *) (fun (a: alg) ->
a, B.alloca (Lib.IntTypes.u64 0) 25ul)
(* create_in: *) (fun a r ->
a, B.malloc r (Lib.IntTypes.u64 0) 25ul)
(* free: *) (fun _ (_, s) ->
B.free s)
(* copy: *) (fun _ (a, s_src) (a', s_dst) ->
B.blit s_src 0ul s_dst 0ul 25ul)
noextract inline_for_extraction
let is_shake_ a = a = Shake128 || a = Shake256
inline_for_extraction noextract | false | true | Hacl.Streaming.Keccak.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hacl_keccak (a: G.erased alg) : block alg | [] | Hacl.Streaming.Keccak.hacl_keccak | {
"file_name": "code/streaming/Hacl.Streaming.Keccak.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.Ghost.erased Hacl.Streaming.Keccak.alg
-> Hacl.Streaming.Interface.block Hacl.Streaming.Keccak.alg | {
"end_col": 47,
"end_line": 185,
"start_col": 2,
"start_line": 122
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE} | let gbuffer (a: Type0) = | false | null | false | c: cbuffer a {CB.qual_of c == CB.IMMUTABLE} | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.cbuffer",
"Prims.eq2",
"LowStar.ConstBuffer.qual",
"LowStar.ConstBuffer.qual_of",
"LowStar.ConstBuffer.IMMUTABLE"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gbuffer : a: Type0 -> Type0 | [] | Lib.Buffer.gbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> Type0 | {
"end_col": 72,
"end_line": 46,
"start_col": 31,
"start_line": 46
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len | let clbuffer (a: Type0) (len: size_t) = | false | null | false | lbuffer_t CONST a len | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.CONST"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val clbuffer : a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | [] | Lib.Buffer.clbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 66,
"end_line": 74,
"start_col": 45,
"start_line": 74
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2 | let modifies1 (#a: Type0) (b: buffer_t MUT a) (h1 h2: HS.mem) = | false | null | false | modifies (loc b) h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"Lib.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies1 : b: Lib.Buffer.buffer_t Lib.Buffer.MUT a ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.Buffer.modifies1 | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.buffer_t Lib.Buffer.MUT a ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 24,
"end_line": 176,
"start_col": 2,
"start_line": 176
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len | let ilbuffer (a: Type0) (len: size_t) = | false | null | false | lbuffer_t IMMUT a len | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.IMMUT"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len} | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ilbuffer : a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | [] | Lib.Buffer.ilbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 66,
"end_line": 73,
"start_col": 45,
"start_line": 73
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2 | let modifies2 (#a0 #a1: Type0) (b0: buffer_t MUT a0) (b1: buffer_t MUT a1) (h1 h2: HS.mem) = | false | null | false | modifies (loc b0 |+| loc b1) h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies2 : b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.Buffer.modifies2 | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 36,
"end_line": 181,
"start_col": 2,
"start_line": 181
} |
|
Prims.GTot | val union (l1 l2: B.loc) : GTot B.loc | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2 | val union (l1 l2: B.loc) : GTot B.loc
let union (l1 l2: B.loc) : GTot B.loc = | false | null | false | B.loc_union l1 l2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_union"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0" | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val union (l1 l2: B.loc) : GTot B.loc | [] | Lib.Buffer.union | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l1: LowStar.Monotonic.Buffer.loc -> l2: LowStar.Monotonic.Buffer.loc
-> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 64,
"end_line": 139,
"start_col": 47,
"start_line": 139
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2 | let modifies3
(#a0 #a1 #a2: Type0)
(b0: buffer_t MUT a0)
(b1: buffer_t MUT a1)
(b2: buffer_t MUT a2)
(h1 h2: HS.mem)
= | false | null | false | modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies3 : b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.Buffer.modifies3 | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 47,
"end_line": 186,
"start_col": 2,
"start_line": 186
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2 | let modifies5
(#a0 #a1 #a2 #a3 #a4: Type0)
(b0: buffer_t MUT a0)
(b1: buffer_t MUT a1)
(b2: buffer_t MUT a2)
(b3: buffer_t MUT a3)
(b4: buffer_t MUT a4)
(h1 h2: HS.mem)
= | false | null | false | modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies5 : b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
b3: Lib.Buffer.buffer_t Lib.Buffer.MUT a3 ->
b4: Lib.Buffer.buffer_t Lib.Buffer.MUT a4 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.Buffer.modifies5 | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
b3: Lib.Buffer.buffer_t Lib.Buffer.MUT a3 ->
b4: Lib.Buffer.buffer_t Lib.Buffer.MUT a4 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 69,
"end_line": 198,
"start_col": 2,
"start_line": 198
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cbuffer (a:Type0) = buffer_t CONST a | let cbuffer (a: Type0) = | false | null | false | buffer_t CONST a | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.CONST"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cbuffer : a: Type0 -> Type0 | [] | Lib.Buffer.cbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> Type0 | {
"end_col": 47,
"end_line": 43,
"start_col": 31,
"start_line": 43
} |
|
FStar.HyperStack.ST.Stack | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Array_Assignment #a #len = upd #a #len | let op_Array_Assignment #a #len = | true | null | false | upd #a #len | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.upd",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Prims.op_LessThan",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Lib.Buffer.modifies1",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Lib.Sequence.upd"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Array_Assignment : b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT a len ->
i: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v i < Lib.IntTypes.v len} ->
x: a
-> FStar.HyperStack.ST.Stack Prims.unit | [] | Lib.Buffer.op_Array_Assignment | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT a len ->
i: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v i < Lib.IntTypes.v len} ->
x: a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 45,
"end_line": 304,
"start_col": 34,
"start_line": 304
} |
|
FStar.HyperStack.ST.Stack | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Array_Access #t #a #len = index #t #a #len | let op_Array_Access #t #a #len = | true | null | false | index #t #a #len | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.index",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Prims.op_LessThan",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.index",
"Lib.Buffer.as_seq"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Array_Access : b: Lib.Buffer.lbuffer_t t a len ->
i: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v i < Lib.IntTypes.v len}
-> FStar.HyperStack.ST.Stack a | [] | Lib.Buffer.op_Array_Access | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.lbuffer_t t a len ->
i: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v i < Lib.IntTypes.v len}
-> FStar.HyperStack.ST.Stack a | {
"end_col": 49,
"end_line": 308,
"start_col": 33,
"start_line": 308
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2 | let modifies4
(#a0 #a1 #a2 #a3: Type0)
(b0: buffer_t MUT a0)
(b1: buffer_t MUT a1)
(b2: buffer_t MUT a2)
(b3: buffer_t MUT a3)
(h1 h2: HS.mem)
= | false | null | false | modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies4 : b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
b3: Lib.Buffer.buffer_t Lib.Buffer.MUT a3 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.Buffer.modifies4 | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
b3: Lib.Buffer.buffer_t Lib.Buffer.MUT a3 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 58,
"end_line": 192,
"start_col": 2,
"start_line": 192
} |
|
Prims.GTot | val op_Bar_Plus_Bar (l1 l2: B.loc) : GTot B.loc | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2 | val op_Bar_Plus_Bar (l1 l2: B.loc) : GTot B.loc
let op_Bar_Plus_Bar (l1 l2: B.loc) : GTot B.loc = | false | null | false | union l1 l2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"LowStar.Monotonic.Buffer.loc",
"Lib.Buffer.union"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0" | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Bar_Plus_Bar (l1 l2: B.loc) : GTot B.loc | [] | Lib.Buffer.op_Bar_Plus_Bar | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l1: LowStar.Monotonic.Buffer.loc -> l2: LowStar.Monotonic.Buffer.loc
-> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 60,
"end_line": 140,
"start_col": 49,
"start_line": 140
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len | let lbuffer (a: Type0) (len: size_t) = | false | null | false | lbuffer_t MUT a len | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len} | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lbuffer : a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | [] | Lib.Buffer.lbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 63,
"end_line": 72,
"start_col": 44,
"start_line": 72
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ibuffer (a:Type0) = buffer_t IMMUT a | let ibuffer (a: Type0) = | false | null | false | buffer_t IMMUT a | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.IMMUT"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ibuffer : a: Type0 -> Type0 | [] | Lib.Buffer.ibuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> Type0 | {
"end_col": 47,
"end_line": 40,
"start_col": 31,
"start_line": 40
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2 | let modifies (s: B.loc) (h1 h2: HS.mem) = | false | null | false | B.modifies s h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"LowStar.Monotonic.Buffer.loc",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.modifies"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2 | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies : s: LowStar.Monotonic.Buffer.loc ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.Buffer.modifies | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s: LowStar.Monotonic.Buffer.loc ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 58,
"end_line": 143,
"start_col": 40,
"start_line": 143
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2) | let disjoint (#t1 #t2: buftype) (#a1 #a2: Type0) (b1: buffer_t t1 a1) (b2: buffer_t t2 a2) = | false | null | false | B.loc_disjoint (loc b1) (loc b2) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Lib.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val disjoint : b1: Lib.Buffer.buffer_t t1 a1 -> b2: Lib.Buffer.buffer_t t2 a2 -> Type0 | [] | Lib.Buffer.disjoint | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b1: Lib.Buffer.buffer_t t1 a1 -> b2: Lib.Buffer.buffer_t t2 a2 -> Type0 | {
"end_col": 34,
"end_line": 152,
"start_col": 2,
"start_line": 152
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2 | let modifies0 (h1 h2: HS.mem) = | false | null | false | modifies (B.loc_none) h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *) | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies0 : h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> Type0 | [] | Lib.Buffer.modifies0 | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> Type0 | {
"end_col": 29,
"end_line": 172,
"start_col": 2,
"start_line": 172
} |
|
Prims.GTot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len | let op_Brack_Lens_Access #t #a #len = | false | null | false | as_seq #t #a #len | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.as_seq",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Brack_Lens_Access : h: FStar.Monotonic.HyperStack.mem -> b: Lib.Buffer.lbuffer_t t a len
-> Prims.GTot (Lib.Sequence.lseq a (Lib.IntTypes.v len)) | [] | Lib.Buffer.op_Brack_Lens_Access | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> b: Lib.Buffer.lbuffer_t t a len
-> Prims.GTot (Lib.Sequence.lseq a (Lib.IntTypes.v len)) | {
"end_col": 55,
"end_line": 313,
"start_col": 38,
"start_line": 313
} |
|
Prims.Tot | val cpred (#a: Type0) (s: Seq.seq a) : B.spred a | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cpred (#a:Type0) (s:Seq.seq a) : B.spred a = fun s1 -> FStar.Seq.equal s s1 | val cpred (#a: Type0) (s: Seq.seq a) : B.spred a
let cpred (#a: Type0) (s: Seq.seq a) : B.spred a = | false | null | false | fun s1 -> FStar.Seq.equal s s1 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Sequence.seq",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.equal",
"LowStar.Monotonic.Buffer.spred"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s
let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction
val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cpred (#a: Type0) (s: Seq.seq a) : B.spred a | [] | Lib.Buffer.cpred | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.Sequence.seq a -> LowStar.Monotonic.Buffer.spred a | {
"end_col": 79,
"end_line": 367,
"start_col": 49,
"start_line": 367
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2 | let modifies6
(#a0 #a1 #a2 #a3 #a4 #a5: Type0)
(b0: buffer_t MUT a0)
(b1: buffer_t MUT a1)
(b2: buffer_t MUT a2)
(b3: buffer_t MUT a3)
(b4: buffer_t MUT a4)
(b5: buffer_t MUT a5)
(h1 h2: HS.mem)
= | false | null | false | modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2 | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies6 : b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
b3: Lib.Buffer.buffer_t Lib.Buffer.MUT a3 ->
b4: Lib.Buffer.buffer_t Lib.Buffer.MUT a4 ->
b5: Lib.Buffer.buffer_t Lib.Buffer.MUT a5 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | [] | Lib.Buffer.modifies6 | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b0: Lib.Buffer.buffer_t Lib.Buffer.MUT a0 ->
b1: Lib.Buffer.buffer_t Lib.Buffer.MUT a1 ->
b2: Lib.Buffer.buffer_t Lib.Buffer.MUT a2 ->
b3: Lib.Buffer.buffer_t Lib.Buffer.MUT a3 ->
b4: Lib.Buffer.buffer_t Lib.Buffer.MUT a4 ->
b5: Lib.Buffer.buffer_t Lib.Buffer.MUT a5 ->
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 80,
"end_line": 204,
"start_col": 2,
"start_line": 204
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer (a:Type0) = buffer_t MUT a | let buffer (a: Type0) = | false | null | false | buffer_t MUT a | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val buffer : a: Type0 -> Type0 | [] | Lib.Buffer.buffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> Type0 | {
"end_col": 44,
"end_line": 37,
"start_col": 30,
"start_line": 37
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len} | let lbuffer_t (t: buftype) (a: Type0) (len: size_t) = | false | null | false | b: buffer_t t a {length #t #a b == v len} | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.buffer_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lbuffer_t : t: Lib.Buffer.buftype -> a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | [] | Lib.Buffer.lbuffer_t | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.Buffer.buftype -> a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 41,
"end_line": 70,
"start_col": 2,
"start_line": 70
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a | let buffer_t (t: buftype) (a: Type0) = | false | null | false | match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buftype",
"LowStar.ImmutableBuffer.ibuffer",
"LowStar.Buffer.buffer",
"LowStar.ConstBuffer.const_buffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val buffer_t : t: Lib.Buffer.buftype -> a: Type0 -> Type0 | [] | Lib.Buffer.buffer_t | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.Buffer.buftype -> a: Type0 -> Type0 | {
"end_col": 30,
"end_line": 34,
"start_col": 2,
"start_line": 31
} |
|
Prims.GTot | val freeable (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot Type0 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a)) | val freeable (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot Type0
let freeable (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot Type0 = | false | null | false | match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a)) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.Monotonic.Buffer.freeable",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.as_mbuf",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val freeable (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot Type0 | [] | Lib.Buffer.freeable | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.buffer_t t a -> Prims.GTot Type0 | {
"end_col": 53,
"end_line": 106,
"start_col": 2,
"start_line": 103
} |
Prims.Tot | val const_to_buffer (#a: _) (b: cbuffer a {CB.qual_of b == CB.MUTABLE})
: r: buffer a {length r == length b} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b | val const_to_buffer (#a: _) (b: cbuffer a {CB.qual_of b == CB.MUTABLE})
: r: buffer a {length r == length b}
let const_to_buffer #a (b: cbuffer a {CB.qual_of b == CB.MUTABLE})
: r: buffer a {length r == length b} = | false | null | false | CB.to_buffer b | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.cbuffer",
"Prims.eq2",
"LowStar.ConstBuffer.qual",
"LowStar.ConstBuffer.qual_of",
"LowStar.ConstBuffer.MUTABLE",
"LowStar.ConstBuffer.to_buffer",
"Lib.Buffer.buffer",
"Prims.nat",
"Lib.Buffer.length",
"Lib.Buffer.MUT",
"Lib.Buffer.CONST"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val const_to_buffer (#a: _) (b: cbuffer a {CB.qual_of b == CB.MUTABLE})
: r: buffer a {length r == length b} | [] | Lib.Buffer.const_to_buffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.cbuffer a {LowStar.ConstBuffer.qual_of b == LowStar.ConstBuffer.MUTABLE}
-> r: Lib.Buffer.buffer a {Lib.Buffer.length r == Lib.Buffer.length b} | {
"end_col": 16,
"end_line": 62,
"start_col": 2,
"start_line": 62
} |
Prims.GTot | val g_is_null (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot bool | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a)) | val g_is_null (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot bool
let g_is_null (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot bool = | false | null | false | match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a)) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.as_mbuf",
"Lib.Buffer.cbuffer",
"Prims.bool"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val g_is_null (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot bool | [] | Lib.Buffer.g_is_null | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.buffer_t t a -> Prims.GTot Prims.bool | {
"end_col": 54,
"end_line": 94,
"start_col": 2,
"start_line": 91
} |
Prims.Tot | val const_to_ilbuffer (#a #len: _) (b: glbuffer a len) : ilbuffer a len | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b | val const_to_ilbuffer (#a #len: _) (b: glbuffer a len) : ilbuffer a len
let const_to_ilbuffer #a #len (b: glbuffer a len) : ilbuffer a len = | false | null | false | const_to_ibuffer #a b | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.glbuffer",
"Lib.Buffer.const_to_ibuffer",
"Lib.Buffer.ilbuffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val const_to_ilbuffer (#a #len: _) (b: glbuffer a len) : ilbuffer a len | [] | Lib.Buffer.const_to_ilbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.glbuffer a len -> Lib.Buffer.ilbuffer a len | {
"end_col": 23,
"end_line": 82,
"start_col": 2,
"start_line": 82
} |
Prims.Tot | val to_const (#a #t: _) (b: buffer_t t a) : r: cbuffer a {length r == length b} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a | val to_const (#a #t: _) (b: buffer_t t a) : r: cbuffer a {length r == length b}
let to_const #a #t (b: buffer_t t a) : r: cbuffer a {length r == length b} = | false | null | false | match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.ConstBuffer.of_buffer",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.of_ibuffer",
"Lib.Buffer.ibuffer",
"Lib.Buffer.cbuffer",
"Prims.eq2",
"Prims.nat",
"Lib.Buffer.length",
"Lib.Buffer.CONST"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val to_const (#a #t: _) (b: buffer_t t a) : r: cbuffer a {length r == length b} | [] | Lib.Buffer.to_const | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.buffer_t t a -> r: Lib.Buffer.cbuffer a {Lib.Buffer.length r == Lib.Buffer.length b} | {
"end_col": 27,
"end_line": 59,
"start_col": 2,
"start_line": 56
} |
Prims.Tot | val null (#t: buftype) (a: Type0) : buffer_t t a | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a | val null (#t: buftype) (a: Type0) : buffer_t t a
let null (#t: buftype) (a: Type0) : buffer_t t a = | false | null | false | match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buftype",
"LowStar.ImmutableBuffer.inull",
"LowStar.Buffer.null",
"LowStar.ConstBuffer.null",
"Lib.Buffer.buffer_t"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val null (#t: buftype) (a: Type0) : buffer_t t a | [] | Lib.Buffer.null | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> Lib.Buffer.buffer_t t a | {
"end_col": 22,
"end_line": 88,
"start_col": 2,
"start_line": 85
} |
Prims.GTot | val loc (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a) | val loc (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc
let loc (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc = | false | null | false | match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.ConstBuffer.loc_buffer",
"Lib.Buffer.cbuffer",
"LowStar.Monotonic.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a)) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc | [] | Lib.Buffer.loc | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.buffer_t t a -> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 43,
"end_line": 112,
"start_col": 2,
"start_line": 109
} |
Prims.GTot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a) | let length (#t: buftype) (#a: Type0) (b: buffer_t t a) = | false | null | false | match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.ConstBuffer.length",
"Lib.Buffer.cbuffer",
"Prims.nat"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE} | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val length : b: Lib.Buffer.buffer_t t a -> Prims.GTot Prims.nat | [] | Lib.Buffer.length | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.buffer_t t a -> Prims.GTot Prims.nat | {
"end_col": 39,
"end_line": 52,
"start_col": 2,
"start_line": 49
} |
|
FStar.Pervasives.Lemma | val mut_immut_disjoint (#t #t': _) (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)] | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h | val mut_immut_disjoint (#t #t': _) (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)] = | false | null | true | IB.buffer_immutable_buffer_disjoint b ib h | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"lemma"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.IMMUT",
"FStar.Monotonic.HyperStack.mem",
"LowStar.ImmutableBuffer.buffer_immutable_buffer_disjoint",
"Prims.unit",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Buffer.trivial_preorder",
"LowStar.ImmutableBuffer.immutable_preorder",
"Prims.squash",
"Lib.Buffer.disjoint",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Lib.Buffer.loc",
"Prims.Nil"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)] | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mut_immut_disjoint (#t #t': _) (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)] | [] | Lib.Buffer.mut_immut_disjoint | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.buffer_t Lib.Buffer.MUT t ->
ib: Lib.Buffer.buffer_t Lib.Buffer.IMMUT t' ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires LowStar.Monotonic.Buffer.live h b /\ LowStar.Monotonic.Buffer.live h ib)
(ensures Lib.Buffer.disjoint b ib)
[
SMTPat (LowStar.Monotonic.Buffer.loc_disjoint (Lib.Buffer.loc b) (Lib.Buffer.loc ib));
SMTPat (LowStar.Monotonic.Buffer.live h b);
SMTPat (LowStar.Monotonic.Buffer.live h ib)
] | {
"end_col": 44,
"end_line": 160,
"start_col": 2,
"start_line": 160
} |
Prims.GTot | val get (#t: buftype) (#a: Type0) (h: mem) (b: buffer_t t a) (i: nat{i < length b}) : GTot a | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i | val get (#t: buftype) (#a: Type0) (h: mem) (b: buffer_t t a) (i: nat{i < length b}) : GTot a
let get (#t: buftype) (#a: Type0) (h: mem) (b: buffer_t t a) (i: nat{i < length b}) : GTot a = | false | null | false | match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.buffer_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Buffer.length",
"LowStar.Monotonic.Buffer.get",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.as_mbuf",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) : | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get (#t: buftype) (#a: Type0) (h: mem) (b: buffer_t t a) (i: nat{i < length b}) : GTot a | [] | Lib.Buffer.get | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
b: Lib.Buffer.buffer_t t a ->
i: Prims.nat{i < Lib.Buffer.length b}
-> Prims.GTot a | {
"end_col": 52,
"end_line": 135,
"start_col": 2,
"start_line": 132
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a)) | let recallable (#t: buftype) (#a: Type0) (#len: size_t) (b: lbuffer_t t a len) = | false | null | false | match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a)) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"LowStar.Monotonic.Buffer.recallable",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.as_mbuf",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val recallable : b: Lib.Buffer.lbuffer_t t a len -> Type0 | [] | Lib.Buffer.recallable | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.lbuffer_t t a len -> Type0 | {
"end_col": 55,
"end_line": 354,
"start_col": 2,
"start_line": 351
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE} | let glbuffer (a: Type0) (len: size_t) = | false | null | false | c: clbuffer a len {CB.qual_of #a c == CB.IMMUTABLE} | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.clbuffer",
"Prims.eq2",
"LowStar.ConstBuffer.qual",
"LowStar.ConstBuffer.qual_of",
"LowStar.ConstBuffer.IMMUTABLE"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len | false | true | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val glbuffer : a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | [] | Lib.Buffer.glbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type0 -> len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 94,
"end_line": 75,
"start_col": 45,
"start_line": 75
} |
|
Prims.GTot | val loc_addr_of_buffer (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a)) | val loc_addr_of_buffer (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc
let loc_addr_of_buffer (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc = | false | null | false | match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a)) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.as_mbuf",
"Lib.Buffer.cbuffer",
"LowStar.Monotonic.Buffer.loc"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_addr_of_buffer (#t: buftype) (#a: Type0) (b: buffer_t t a) : GTot B.loc | [] | Lib.Buffer.loc_addr_of_buffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.buffer_t t a -> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 63,
"end_line": 118,
"start_col": 2,
"start_line": 115
} |
Prims.GTot | val bget
(#t: buftype)
(#a: Type0)
(#len: size_t)
(h: mem)
(b: lbuffer_t t a len)
(i: size_nat{i < v len})
: GTot a | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i | val bget
(#t: buftype)
(#a: Type0)
(#len: size_t)
(h: mem)
(b: lbuffer_t t a len)
(i: size_nat{i < v len})
: GTot a
let bget
(#t: buftype)
(#a: Type0)
(#len: size_t)
(h: mem)
(b: lbuffer_t t a len)
(i: size_nat{i < v len})
: GTot a = | false | null | false | match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"LowStar.Monotonic.Buffer.get",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"FStar.Seq.Base.index",
"LowStar.ConstBuffer.as_seq",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bget
(#t: buftype)
(#a: Type0)
(#len: size_t)
(h: mem)
(b: lbuffer_t t a len)
(i: size_nat{i < v len})
: GTot a | [] | Lib.Buffer.bget | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
b: Lib.Buffer.lbuffer_t t a len ->
i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v len}
-> Prims.GTot a | {
"end_col": 61,
"end_line": 322,
"start_col": 2,
"start_line": 319
} |
Prims.Tot | val loop_refl_inv
(h0: mem)
(n: size_t)
(a_spec: Type)
(refl: (mem -> GTot a_spec))
(footprint: B.loc)
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec -> a_spec)))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_refl_inv
(h0:mem)
(n:size_t)
(a_spec: Type)
(refl:(mem -> GTot a_spec))
(footprint:B.loc)
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec)))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies footprint h0 h /\
refl h == Loop.repeati i (spec h0) (refl h0) | val loop_refl_inv
(h0: mem)
(n: size_t)
(a_spec: Type)
(refl: (mem -> GTot a_spec))
(footprint: B.loc)
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec -> a_spec)))
(i: size_nat{i <= v n})
(h: mem)
: Type0
let loop_refl_inv
(h0: mem)
(n: size_t)
(a_spec: Type)
(refl: (mem -> GTot a_spec))
(footprint: B.loc)
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec -> a_spec)))
(i: size_nat{i <= v n})
(h: mem)
: Type0 = | false | null | false | modifies footprint h0 h /\ refl h == Loop.repeati i (spec h0) (refl h0) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"LowStar.Monotonic.Buffer.loc",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Lib.Buffer.modifies",
"Prims.eq2",
"Lib.LoopCombinators.repeati"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s
let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction
val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b)
unfold private
let cpred (#a:Type0) (s:Seq.seq a) : B.spred a = fun s1 -> FStar.Seq.equal s s1
let witnessed (#a:Type0) (#len:size_t) (b:glbuffer a len) (s:Seq.lseq a (v len)) =
B.witnessed (CB.as_mbuf b) (cpred s)
(** Allocate a stack fixed-length mutable buffer and initialize it to value [init] *)
inline_for_extraction
val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init))
#set-options "--max_fuel 1"
(** Allocate a stack fixed-length mutable buffer initialized to a list *)
inline_for_extraction
val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init))
(** Allocate a global fixed-length const immutable buffer initialized to value [init] *)
inline_for_extraction
val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init))
(** Allocate a global fixed-length mutable buffer initialized to value [init] *)
inline_for_extraction
val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init))
#set-options "--max_fuel 0"
(** Recall the liveness and contents of a global immutable buffer *)
inline_for_extraction
val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s)
(** Copy a buffer into a mutable buffer *)
inline_for_extraction
val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i)
(**
* Set all elements of a mutable buffer to a specific value
*
* WARNING: don't rely on the extracted implementation for secure erasure,
* C compilers may remove optimize it away.
*)
inline_for_extraction
val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len)))
(** Copy a buffer into a sub-buffer of a mutable buffer *)
inline_for_extraction
val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
(** Update a mutable buffer in-place by applying a function on a sub-buffer of it *)
inline_for_extraction
val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0))
(** Copy two buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1))
(** Copy three buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2))
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
let loop_inv
(h0:mem)
(n:size_t)
(a_spec:(i:size_nat{i <= v n} -> Type))
(refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i)))
(footprint:(i:size_nat{i <= v n} -> GTot B.loc))
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies (footprint i) h0 h /\
refl h i == Loop.repeat_gen i a_spec (spec h0) (refl h0 0)
(**
* A generalized loop combinator paremetrized by its state (e.g. an accumulator)
*
* Arguments:
* - [h0] the heap when entering the loop
* - [n] the number of iterations
* - [a_spec] the type for the specification state (may depend on the loop index)
* - [refl] a ghost function that reflects the Low* state in an iteration as [a_spec]
* - [footprint] locations modified by the loop (may depend on the loop index)
* - [spec] a specification of how the body of the loop modifies the state
* - [impl] the body of the loop as a Stack function
*)
inline_for_extraction
val loop:
h0:mem
-> n:size_t
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot B.loc)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_inv h0 n a_spec refl footprint spec (v n) h1)
let loop_refl_inv
(h0:mem)
(n:size_t)
(a_spec: Type)
(refl:(mem -> GTot a_spec))
(footprint:B.loc)
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec)))
(i:size_nat{i <= v n})
(h:mem):
Type0 | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_refl_inv
(h0: mem)
(n: size_t)
(a_spec: Type)
(refl: (mem -> GTot a_spec))
(footprint: B.loc)
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec -> a_spec)))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [] | Lib.Buffer.loop_refl_inv | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
a_spec: Type ->
refl: (_: FStar.Monotonic.HyperStack.mem -> Prims.GTot a_spec) ->
footprint: LowStar.Monotonic.Buffer.loc ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot (i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} -> _: a_spec -> a_spec)) ->
i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} ->
h: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 46,
"end_line": 665,
"start_col": 2,
"start_line": 664
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let eq_or_disjoint
(#t1:buftype)
(#t2:buftype)
(#a1:Type)
(#a2:Type)
(#clen1:size_t)
(#clen2:size_t)
(b1:lbuffer_t t1 a1 clen1)
(b2:lbuffer_t t2 a2 clen2) =
disjoint b1 b2 \/
(t1 == t2 /\ a1 == a2 /\ clen1 == clen2 /\ b1 == b2) | let eq_or_disjoint
(#t1 #t2: buftype)
(#a1 #a2: Type)
(#clen1 #clen2: size_t)
(b1: lbuffer_t t1 a1 clen1)
(b2: lbuffer_t t2 a2 clen2)
= | false | null | false | disjoint b1 b2 \/ (t1 == t2 /\ a1 == a2 /\ clen1 == clen2 /\ b1 == b2) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.buffer_t",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Prims.logical"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s
let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction
val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b)
unfold private
let cpred (#a:Type0) (s:Seq.seq a) : B.spred a = fun s1 -> FStar.Seq.equal s s1
let witnessed (#a:Type0) (#len:size_t) (b:glbuffer a len) (s:Seq.lseq a (v len)) =
B.witnessed (CB.as_mbuf b) (cpred s)
(** Allocate a stack fixed-length mutable buffer and initialize it to value [init] *)
inline_for_extraction
val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init))
#set-options "--max_fuel 1"
(** Allocate a stack fixed-length mutable buffer initialized to a list *)
inline_for_extraction
val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init))
(** Allocate a global fixed-length const immutable buffer initialized to value [init] *)
inline_for_extraction
val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init))
(** Allocate a global fixed-length mutable buffer initialized to value [init] *)
inline_for_extraction
val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init))
#set-options "--max_fuel 0"
(** Recall the liveness and contents of a global immutable buffer *)
inline_for_extraction
val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s)
(** Copy a buffer into a mutable buffer *)
inline_for_extraction
val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i)
(**
* Set all elements of a mutable buffer to a specific value
*
* WARNING: don't rely on the extracted implementation for secure erasure,
* C compilers may remove optimize it away.
*)
inline_for_extraction
val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len)))
(** Copy a buffer into a sub-buffer of a mutable buffer *)
inline_for_extraction
val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
(** Update a mutable buffer in-place by applying a function on a sub-buffer of it *)
inline_for_extraction
val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0))
(** Copy two buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1))
(** Copy three buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2))
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
let loop_inv
(h0:mem)
(n:size_t)
(a_spec:(i:size_nat{i <= v n} -> Type))
(refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i)))
(footprint:(i:size_nat{i <= v n} -> GTot B.loc))
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies (footprint i) h0 h /\
refl h i == Loop.repeat_gen i a_spec (spec h0) (refl h0 0)
(**
* A generalized loop combinator paremetrized by its state (e.g. an accumulator)
*
* Arguments:
* - [h0] the heap when entering the loop
* - [n] the number of iterations
* - [a_spec] the type for the specification state (may depend on the loop index)
* - [refl] a ghost function that reflects the Low* state in an iteration as [a_spec]
* - [footprint] locations modified by the loop (may depend on the loop index)
* - [spec] a specification of how the body of the loop modifies the state
* - [impl] the body of the loop as a Stack function
*)
inline_for_extraction
val loop:
h0:mem
-> n:size_t
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot B.loc)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_inv h0 n a_spec refl footprint spec (v n) h1)
let loop_refl_inv
(h0:mem)
(n:size_t)
(a_spec: Type)
(refl:(mem -> GTot a_spec))
(footprint:B.loc)
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec)))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies footprint h0 h /\
refl h == Loop.repeati i (spec h0) (refl h0)
inline_for_extraction
val loop_refl:
h0:mem
-> n:size_t
-> a_spec:Type
-> refl:(mem -> GTot a_spec)
-> footprint:Ghost.erased B.loc
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_refl_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_refl_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_refl_inv h0 n a_spec refl footprint spec (v n) h1)
let loop1_inv
(h0:mem)
(n:size_t)
(b: Type)
(blen: size_t)
(write:lbuffer b blen)
(spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies1 write h0 h /\
as_seq h write == Loop.repeati i (spec h0) (as_seq h0 write)
(** Loop combinator specialized to modifying a single buffer [write] *)
inline_for_extraction
val loop1:
#b:Type
-> #blen:size_t
-> h0:mem
-> n:size_t
-> write:lbuffer b blen
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop1_inv h0 n b blen write spec (v i))
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v n))
let loop2_inv
(#b0:Type)
(#blen0:size_t)
(#b1:Type)
(#blen1:size_t)
(h0:mem)
(n:size_t)
(write0:lbuffer b0 blen0)
(write1:lbuffer b1 blen1)
(spec:(mem -> GTot (i:size_nat{i < v n}
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1))
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies2 write0 write1 h0 h /\
(let s0, s1 = Loop.repeati i (spec h0) (as_seq h0 write0, as_seq h0 write1) in
as_seq h write0 == s0 /\ as_seq h write1 == s1)
(** Loop combinator specialized to modifying two buffers [write0] and [write1] *)
inline_for_extraction
val loop2:
#b0:Type
-> #blen0:size_t
-> #b1:Type
-> #blen1:size_t
-> h0:mem
-> n:size_t
-> write0:lbuffer b0 blen0
-> write1:lbuffer b1 blen1
-> spec:(mem -> GTot (i:size_nat{i < v n}
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))
-> (Seq.lseq b0 (v blen0) & Seq.lseq b1 (v blen1))))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i))
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop2_inv #b0 #blen0 #b1 #blen1 h0 n write0 write1 spec (v n))
(**
* Allocates a mutable buffer [b] in the stack, calls [impl b] and ovewrites the contents
* of [b] before returning.
*
* [spec] is the functional post-condition of [impl], it only takes the final memory
* because the initial memory is determined by [h]
* [spec_inv] is used to propagate the post-condition of [impl] to the final memory
* after popping the stack frame
*)
inline_for_extraction
val salloc1_with_inv:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> spec_inv:(h1:mem -> h2:mem -> h3:mem -> r:res -> Lemma
(requires
B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2)
(ensures spec r h3))
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1)
inline_for_extraction
val salloc1:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> spec: (res -> mem -> GTot Type0)
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b : buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1 /\
spec r h1)) ->
Stack res
(requires fun h0 -> h0 == h /\
(forall (h1 h2 h3:mem) (r:res).
(B.modifies (B.loc_none) h h1 /\
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h1))
(Ghost.reveal footprint)) h1 h2 /\
B.modifies (B.loc_region_only false (get_tip h1)) h2 h3 /\
~(live_region h (get_tip h1)) /\
spec r h2) ==> spec r h3))
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1 /\ spec r h1)
inline_for_extraction
val salloc_nospec:
#a:Type
-> #res:Type
-> h:mem
-> len:size_t{0 < v len}
-> x:a
-> footprint:Ghost.erased B.loc
-> impl:(b:lbuffer a len -> Stack res
(requires fun h0 ->
let b:buffer a = b in
B.modifies (B.loc_none) h h0 /\ ~(live_region h (get_tip h0)) /\
B.frameOf b == get_tip h0 /\ B.live h0 b /\ B.as_seq h0 b == Seq.create (v len) x)
(ensures fun h0 r h1 ->
B.modifies (B.loc_union (B.loc_all_regions_from false (get_tip h0))
(Ghost.reveal footprint)) h0 h1)) ->
Stack res
(requires fun h0 -> h0 == h)
(ensures fun h0 r h1 -> modifies (Ghost.reveal footprint) h0 h1)
inline_for_extraction
val loopi_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> spec_f:(i:nat{i < v inpLen / v blocksize}
-> Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(i:nat{i == v inpLen / v blocksize}
-> len:size_nat{len == v inpLen % v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (v i) (as_seq h0 inp) (as_seq h0 w)))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v i) (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeati_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write))
inline_for_extraction
val loopi_blocks_nospec:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> inpLen:size_t
-> inp:lbuffer a inpLen
-> f:(i:size_t{v i < v inpLen / v blocksize}
-> inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> l:(i:size_t{v i == v inpLen / v blocksize}
-> len:size_t{v len == v inpLen % v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ B.loc_disjoint (loc inp) (loc w))
(ensures fun h0 _ h1 ->
modifies1 w h0 h1))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 -> modifies1 write h0 h1)
open FStar.Mul
inline_for_extraction
val loop_blocks_multi:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t { v n_blocks * v blocksize < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks) {v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks_multi #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f (as_seq h0 write))
inline_for_extraction
val loop_blocks:
#a:Type0
-> #b:Type0
-> #blen:size_t
-> blocksize:size_t{v blocksize > 0}
-> n_blocks:size_t
-> rem:size_t { v n_blocks * v blocksize + v rem < pow2 32 }
-> inp:lbuffer a (blocksize *! n_blocks +! rem) { v n_blocks == length inp / v blocksize }
-> spec_f:(Seq.lseq a (v blocksize)
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> spec_l:(len:size_nat{len < v blocksize}
-> s:Seq.lseq a len
-> Seq.lseq b (v blen)
-> Seq.lseq b (v blen))
-> f:(inp:lbuffer a blocksize
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_f (as_seq h0 inp) (as_seq h0 w)))
-> l:(len:size_t{v len < v blocksize}
-> inp:lbuffer a len
-> w:lbuffer b blen -> Stack unit
(requires fun h ->
live h inp /\ live h w /\ disjoint inp w)
(ensures fun h0 _ h1 ->
modifies1 w h0 h1 /\
as_seq h1 w == spec_l (v len) (as_seq h0 inp) (as_seq h0 w)))
-> write:lbuffer b blen ->
Stack unit
(requires fun h -> live h inp /\ live h write /\ disjoint inp write)
(ensures fun h0 _ h1 ->
modifies1 write h0 h1 /\
as_seq h1 write ==
Seq.repeat_blocks #a #(Seq.lseq b (v blen)) (v blocksize) (as_seq h0 inp) spec_f spec_l (as_seq h0 write))
open FStar.Mul
(*
(** Fills a buffer block by block using a function with an accumulator *)
inline_for_extraction
val fill_blocks_:
#t:Type0
-> h0:mem
-> len:size_t
-> n:size_t{v n * v len <= max_size_t}
-> output:lbuffer t (n *! len)
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot
(l:B.loc{B.loc_disjoint l (loc output) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}))
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1) & Seq.lseq t (v len)))
-> impl:(i:size_t{v i < v n} -> block:lbuffer t len -> Stack unit
(requires fun h1 ->
live h1 block /\
loc output `B.loc_includes` loc block /\
modifies (B.loc_union (footprint (v i)) (loc output)) h0 h1)
(ensures fun h1 _ h2 ->
let s, b = spec h0 (v i) (refl h1 (v i)) in
footprint (v i + 1) `B.loc_includes` footprint (v i) /\
B.modifies (B.loc_union (footprint (v i + 1)) (loc block)) h1 h2 /\
refl h2 (v i + 1) == s /\ as_seq h2 block == b)) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 ->
let s, o = Seq.generate_blocks (v len) (v n) a_spec (spec h0) (refl h0 0) in
B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1 /\
refl h1 (v n) == s /\
as_seq #_ #t h1 (gsub output (size 0) (n *! len)) == o)
*)
#set-options "--z3rlimit 150"
(** Fills a buffer block by block using a function with an accumulator *)
inline_for_extraction
val fill_blocks:
#t:Type0
-> h0:mem
-> len:size_t
-> n:size_t{v n * v len <= max_size_t}
-> output:lbuffer t (n *! len)
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot
(l:B.loc{B.loc_disjoint l (loc output) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}))
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1) & Seq.lseq t (v len)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
(v i + 1) * v len <= max_size_t /\
modifies (footprint (v i) |+| loc (gsub output 0ul (i *! len))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! len) len in
let s, b = spec h0 (v i) (refl h1 (v i)) in
footprint (v i + 1) `B.loc_includes` footprint (v i) /\
B.modifies (B.loc_union (footprint (v i + 1)) (loc block)) h1 h2 /\
refl h2 (v i + 1) == s /\ as_seq h2 block == b))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 ->
B.modifies (B.loc_union (footprint (v n)) (loc output)) h0 h1 /\
(let s, o = Seq.generate_blocks (v len) (v n) (v n) a_spec (spec h0) (refl h0 0) in
refl h1 (v n) == s /\
as_seq #_ #t h1 output == o))
(** Fills a buffer block by block using a function without an accumulator *)
inline_for_extraction
val fill_blocks_simple:
#t:Type0
-> h0:mem
-> bs:size_t{v bs > 0}
-> n:size_t{v bs * v n <= max_size_t}
-> output:lbuffer t (bs *! n)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq t (v bs)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires fun h1 ->
FStar.Math.Lemmas.lemma_mult_le_right (v bs) (v i) (v n);
(v i + 1) * v bs <= max_size_t /\
modifies (loc (gsub output 0ul (i *! bs))) h0 h1)
(ensures fun h1 _ h2 ->
(let block = gsub output (i *! bs) bs in
let ob = spec h0 (v i) in
B.modifies (loc block) h1 h2 /\
as_seq h2 block == ob))) ->
Stack unit
(requires fun h -> h0 == h /\ live h output)
(ensures fun _ _ h1 -> modifies1 output h0 h1 /\
as_seq #_ #t h1 output == Sequence.generate_blocks_simple (v bs) (v n) (v n) (spec h0))
(** Fill a buffer with a total function *)
inline_for_extraction
val fillT:
#a:Type
-> clen:size_t
-> o:lbuffer a clen
-> spec_f:(i:size_nat{i < v clen} -> a)
-> f:(i:size_t{v i < v clen} -> r:a{r == spec_f (size_v i)}) ->
Stack unit
(requires fun h0 -> live h0 o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == Seq.createi #a (v clen) spec_f)
(** Fill a buffer with a stateful function *)
inline_for_extraction
val fill:
#a:Type
-> h0:mem
-> clen:size_t
-> o:lbuffer a clen
-> spec:(mem -> GTot(i:size_nat{i < v clen} -> a))
-> impl:(i:size_t{v i < v clen} -> Stack a
(requires fun h -> modifies1 (gsub o 0ul i) h0 h)
(ensures fun h r h' -> h == h' /\
r == spec h0 (v i)))
-> Stack unit
(requires fun h -> h == h0 /\ live h0 o)
(ensures fun h _ h' ->
modifies1 o h h' /\
as_seq h' o == Seq.createi #a (v clen) (spec h0))
inline_for_extraction
let eq_or_disjoint
(#t1:buftype)
(#t2:buftype)
(#a1:Type)
(#a2:Type)
(#clen1:size_t)
(#clen2:size_t)
(b1:lbuffer_t t1 a1 clen1) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eq_or_disjoint : b1: Lib.Buffer.lbuffer_t t1 a1 clen1 -> b2: Lib.Buffer.lbuffer_t t2 a2 clen2 -> Prims.logical | [] | Lib.Buffer.eq_or_disjoint | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b1: Lib.Buffer.lbuffer_t t1 a1 clen1 -> b2: Lib.Buffer.lbuffer_t t2 a2 clen2 -> Prims.logical | {
"end_col": 56,
"end_line": 1116,
"start_col": 4,
"start_line": 1115
} |
|
FStar.HyperStack.ST.Stack | val is_null (#t: buftype) (#a: Type0) (b: buffer_t t a)
: Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a) | val is_null (#t: buftype) (#a: Type0) (b: buffer_t t a)
: Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b))
let is_null (#t: buftype) (#a: Type0) (b: buffer_t t a)
: Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) = | true | null | false | match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [] | [
"Lib.Buffer.buftype",
"Lib.Buffer.buffer_t",
"LowStar.Monotonic.Buffer.is_null",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"Prims.bool",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ConstBuffer.is_null",
"Lib.Buffer.cbuffer",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.g_is_null"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b)) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_null (#t: buftype) (#a: Type0) (b: buffer_t t a)
: Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) | [] | Lib.Buffer.is_null | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.buffer_t t a -> FStar.HyperStack.ST.Stack Prims.bool | {
"end_col": 40,
"end_line": 128,
"start_col": 2,
"start_line": 125
} |
Prims.GTot | val as_seq (#t: buftype) (#a: Type0) (#len: size_t) (h: HS.mem) (b: lbuffer_t t a len)
: GTot (Seq.lseq a (v len)) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a) | val as_seq (#t: buftype) (#a: Type0) (#len: size_t) (h: HS.mem) (b: lbuffer_t t a len)
: GTot (Seq.lseq a (v len))
let as_seq (#t: buftype) (#a: Type0) (#len: size_t) (h: HS.mem) (b: lbuffer_t t a len)
: GTot (Seq.lseq a (v len)) = | false | null | false | match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer_t",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Buffer.trivial_preorder",
"Lib.Buffer.buffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"Lib.Buffer.ibuffer",
"LowStar.ConstBuffer.as_seq",
"Lib.Buffer.cbuffer",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) : | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_seq (#t: buftype) (#a: Type0) (#len: size_t) (h: HS.mem) (b: lbuffer_t t a len)
: GTot (Seq.lseq a (v len)) | [] | Lib.Buffer.as_seq | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> b: Lib.Buffer.lbuffer_t t a len
-> Prims.GTot (Lib.Sequence.lseq a (Lib.IntTypes.v len)) | {
"end_col": 41,
"end_line": 212,
"start_col": 2,
"start_line": 209
} |
Prims.Tot | val const_to_lbuffer (#a #len: _) (b: clbuffer a len {CB.qual_of (b <: cbuffer a) == CB.MUTABLE})
: lbuffer a len | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b | val const_to_lbuffer (#a #len: _) (b: clbuffer a len {CB.qual_of (b <: cbuffer a) == CB.MUTABLE})
: lbuffer a len
let const_to_lbuffer #a #len (b: clbuffer a len {CB.qual_of (b <: cbuffer a) == CB.MUTABLE})
: lbuffer a len = | false | null | false | const_to_buffer #a b | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.clbuffer",
"Prims.eq2",
"LowStar.ConstBuffer.qual",
"LowStar.ConstBuffer.qual_of",
"Lib.Buffer.cbuffer",
"LowStar.ConstBuffer.MUTABLE",
"Lib.Buffer.const_to_buffer",
"Lib.Buffer.lbuffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val const_to_lbuffer (#a #len: _) (b: clbuffer a len {CB.qual_of (b <: cbuffer a) == CB.MUTABLE})
: lbuffer a len | [] | Lib.Buffer.const_to_lbuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.clbuffer a len {LowStar.ConstBuffer.qual_of b == LowStar.ConstBuffer.MUTABLE}
-> Lib.Buffer.lbuffer a len | {
"end_col": 22,
"end_line": 79,
"start_col": 2,
"start_line": 79
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root | let stack_allocated
(#a: Type0)
(#len: size_t)
(b: lbuffer a len)
(h0 h1: mem)
(s: Seq.lseq a (v len))
= | false | null | false | let b:B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\ B.frameOf b = HS.get_tip h0 /\ B.frameOf b <> HyperStack.root | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"FStar.Monotonic.HyperStack.mem",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.l_and",
"LowStar.Monotonic.Buffer.alloc_post_mem_common",
"LowStar.Buffer.trivial_preorder",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.op_disEquality",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Buffer.buffer",
"Prims.logical"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)] | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stack_allocated : b: Lib.Buffer.lbuffer a len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
s: Lib.Sequence.lseq a (Lib.IntTypes.v len)
-> Prims.logical | [] | Lib.Buffer.stack_allocated | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.lbuffer a len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
s: Lib.Sequence.lseq a (Lib.IntTypes.v len)
-> Prims.logical | {
"end_col": 32,
"end_line": 342,
"start_col": 62,
"start_line": 338
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let witnessed (#a:Type0) (#len:size_t) (b:glbuffer a len) (s:Seq.lseq a (v len)) =
B.witnessed (CB.as_mbuf b) (cpred s) | let witnessed (#a: Type0) (#len: size_t) (b: glbuffer a len) (s: Seq.lseq a (v len)) = | false | null | false | B.witnessed (CB.as_mbuf b) (cpred s) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.glbuffer",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"LowStar.Monotonic.Buffer.witnessed",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.as_mbuf",
"Lib.Buffer.cpred"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s
let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction
val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b)
unfold private
let cpred (#a:Type0) (s:Seq.seq a) : B.spred a = fun s1 -> FStar.Seq.equal s s1 | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val witnessed : b: Lib.Buffer.glbuffer a len -> s: Lib.Sequence.lseq a (Lib.IntTypes.v len) -> Type0 | [] | Lib.Buffer.witnessed | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.glbuffer a len -> s: Lib.Sequence.lseq a (Lib.IntTypes.v len) -> Type0 | {
"end_col": 38,
"end_line": 370,
"start_col": 2,
"start_line": 370
} |
|
Prims.GTot | val gsub
(#t: buftype)
(#a: Type0)
(#len: size_t)
(b: lbuffer_t t a len)
(start: size_t)
(n: size_t{v start + v n <= v len})
: GTot (lbuffer_t t a n) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n) | val gsub
(#t: buftype)
(#a: Type0)
(#len: size_t)
(b: lbuffer_t t a len)
(start: size_t)
(n: size_t{v start + v n <= v len})
: GTot (lbuffer_t t a n)
let gsub
(#t: buftype)
(#a: Type0)
(#len: size_t)
(b: lbuffer_t t a len)
(start: size_t)
(n: size_t{v start + v n <= v len})
: GTot (lbuffer_t t a n) = | false | null | false | match t with
| IMMUT ->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.Buffer.buftype",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.ilbuffer",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"LowStar.Monotonic.Buffer.length",
"LowStar.ImmutableBuffer.immutable_preorder",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.ImmutableBuffer.igsub",
"Lib.Buffer.ibuffer",
"Lib.Buffer.lbuffer",
"LowStar.Buffer.trivial_preorder",
"LowStar.Buffer.gsub",
"Lib.Buffer.buffer",
"Lib.Buffer.clbuffer",
"LowStar.ConstBuffer.length",
"LowStar.ConstBuffer.const_buffer",
"LowStar.ConstBuffer.gsub",
"Lib.Buffer.cbuffer"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n) | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gsub
(#t: buftype)
(#a: Type0)
(#len: size_t)
(b: lbuffer_t t a len)
(start: size_t)
(n: size_t{v start + v n <= v len})
: GTot (lbuffer_t t a n) | [] | Lib.Buffer.gsub | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.lbuffer_t t a len ->
start: Lib.IntTypes.size_t ->
n: Lib.IntTypes.size_t{Lib.IntTypes.v start + Lib.IntTypes.v n <= Lib.IntTypes.v len}
-> Prims.GTot (Lib.Buffer.lbuffer_t t a n) | {
"end_col": 23,
"end_line": 230,
"start_col": 2,
"start_line": 218
} |
Prims.GTot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s | let global_allocated
(#a: Type0)
(#len: size_t)
(b: glbuffer a len)
(h0 h1: mem)
(s: Seq.lseq a (v len))
= | false | null | false | let b:ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\ B.alloc_post_mem_common b h0 h1 s | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"sometrivial"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.glbuffer",
"FStar.Monotonic.HyperStack.mem",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.l_and",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.ImmutableBuffer.immutable_preorder",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.alloc_post_mem_common",
"Lib.Buffer.buffer_t",
"Lib.Buffer.IMMUT",
"LowStar.ConstBuffer.as_mbuf",
"Prims.logical"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val global_allocated : b: Lib.Buffer.glbuffer a len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
s: Lib.Sequence.lseq a (Lib.IntTypes.v len)
-> Prims.GTot Prims.logical | [] | Lib.Buffer.global_allocated | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.glbuffer a len ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
s: Lib.Sequence.lseq a (Lib.IntTypes.v len)
-> Prims.GTot Prims.logical | {
"end_col": 35,
"end_line": 348,
"start_col": 62,
"start_line": 345
} |
|
Prims.Tot | val loop1_inv
(h0: mem)
(n: size_t)
(b: Type)
(blen: size_t)
(write: lbuffer b blen)
(spec: (mem -> GTot (i: size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop1_inv
(h0:mem)
(n:size_t)
(b: Type)
(blen: size_t)
(write:lbuffer b blen)
(spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies1 write h0 h /\
as_seq h write == Loop.repeati i (spec h0) (as_seq h0 write) | val loop1_inv
(h0: mem)
(n: size_t)
(b: Type)
(blen: size_t)
(write: lbuffer b blen)
(spec: (mem -> GTot (i: size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i: size_nat{i <= v n})
(h: mem)
: Type0
let loop1_inv
(h0: mem)
(n: size_t)
(b: Type)
(blen: size_t)
(write: lbuffer b blen)
(spec: (mem -> GTot (i: size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 = | false | null | false | modifies1 write h0 h /\ as_seq h write == Loop.repeati i (spec h0) (as_seq h0 write) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.lseq",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Lib.Buffer.modifies1",
"Prims.eq2",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.LoopCombinators.repeati"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s
let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction
val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b)
unfold private
let cpred (#a:Type0) (s:Seq.seq a) : B.spred a = fun s1 -> FStar.Seq.equal s s1
let witnessed (#a:Type0) (#len:size_t) (b:glbuffer a len) (s:Seq.lseq a (v len)) =
B.witnessed (CB.as_mbuf b) (cpred s)
(** Allocate a stack fixed-length mutable buffer and initialize it to value [init] *)
inline_for_extraction
val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init))
#set-options "--max_fuel 1"
(** Allocate a stack fixed-length mutable buffer initialized to a list *)
inline_for_extraction
val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init))
(** Allocate a global fixed-length const immutable buffer initialized to value [init] *)
inline_for_extraction
val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init))
(** Allocate a global fixed-length mutable buffer initialized to value [init] *)
inline_for_extraction
val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init))
#set-options "--max_fuel 0"
(** Recall the liveness and contents of a global immutable buffer *)
inline_for_extraction
val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s)
(** Copy a buffer into a mutable buffer *)
inline_for_extraction
val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i)
(**
* Set all elements of a mutable buffer to a specific value
*
* WARNING: don't rely on the extracted implementation for secure erasure,
* C compilers may remove optimize it away.
*)
inline_for_extraction
val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len)))
(** Copy a buffer into a sub-buffer of a mutable buffer *)
inline_for_extraction
val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
(** Update a mutable buffer in-place by applying a function on a sub-buffer of it *)
inline_for_extraction
val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0))
(** Copy two buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1))
(** Copy three buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2))
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
let loop_inv
(h0:mem)
(n:size_t)
(a_spec:(i:size_nat{i <= v n} -> Type))
(refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i)))
(footprint:(i:size_nat{i <= v n} -> GTot B.loc))
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies (footprint i) h0 h /\
refl h i == Loop.repeat_gen i a_spec (spec h0) (refl h0 0)
(**
* A generalized loop combinator paremetrized by its state (e.g. an accumulator)
*
* Arguments:
* - [h0] the heap when entering the loop
* - [n] the number of iterations
* - [a_spec] the type for the specification state (may depend on the loop index)
* - [refl] a ghost function that reflects the Low* state in an iteration as [a_spec]
* - [footprint] locations modified by the loop (may depend on the loop index)
* - [spec] a specification of how the body of the loop modifies the state
* - [impl] the body of the loop as a Stack function
*)
inline_for_extraction
val loop:
h0:mem
-> n:size_t
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot B.loc)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_inv h0 n a_spec refl footprint spec (v n) h1)
let loop_refl_inv
(h0:mem)
(n:size_t)
(a_spec: Type)
(refl:(mem -> GTot a_spec))
(footprint:B.loc)
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec)))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies footprint h0 h /\
refl h == Loop.repeati i (spec h0) (refl h0)
inline_for_extraction
val loop_refl:
h0:mem
-> n:size_t
-> a_spec:Type
-> refl:(mem -> GTot a_spec)
-> footprint:Ghost.erased B.loc
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_refl_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_refl_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_refl_inv h0 n a_spec refl footprint spec (v n) h1)
let loop1_inv
(h0:mem)
(n:size_t)
(b: Type)
(blen: size_t)
(write:lbuffer b blen)
(spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i:size_nat{i <= v n})
(h:mem):
Type0 | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop1_inv
(h0: mem)
(n: size_t)
(b: Type)
(blen: size_t)
(write: lbuffer b blen)
(spec: (mem -> GTot (i: size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [] | Lib.Buffer.loop1_inv | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
b: Type0 ->
blen: Lib.IntTypes.size_t ->
write: Lib.Buffer.lbuffer b blen ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(
i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} ->
_: Lib.Sequence.lseq b (Lib.IntTypes.v blen)
-> Lib.Sequence.lseq b (Lib.IntTypes.v blen))) ->
i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} ->
h: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 62,
"end_line": 694,
"start_col": 2,
"start_line": 693
} |
Prims.Tot | val loop2_inv
(#b0: Type)
(#blen0: size_t)
(#b1: Type)
(#blen1: size_t)
(h0: mem)
(n: size_t)
(write0: lbuffer b0 blen0)
(write1: lbuffer b1 blen1)
(spec:
(mem
-> GTot
(i: size_nat{i < v n} -> ((Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop2_inv
(#b0:Type)
(#blen0:size_t)
(#b1:Type)
(#blen1:size_t)
(h0:mem)
(n:size_t)
(write0:lbuffer b0 blen0)
(write1:lbuffer b1 blen1)
(spec:(mem -> GTot (i:size_nat{i < v n}
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1))
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies2 write0 write1 h0 h /\
(let s0, s1 = Loop.repeati i (spec h0) (as_seq h0 write0, as_seq h0 write1) in
as_seq h write0 == s0 /\ as_seq h write1 == s1) | val loop2_inv
(#b0: Type)
(#blen0: size_t)
(#b1: Type)
(#blen1: size_t)
(h0: mem)
(n: size_t)
(write0: lbuffer b0 blen0)
(write1: lbuffer b1 blen1)
(spec:
(mem
-> GTot
(i: size_nat{i < v n} -> ((Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))))
(i: size_nat{i <= v n})
(h: mem)
: Type0
let loop2_inv
(#b0: Type)
(#blen0: size_t)
(#b1: Type)
(#blen1: size_t)
(h0: mem)
(n: size_t)
(write0: lbuffer b0 blen0)
(write1: lbuffer b1 blen1)
(spec:
(mem
-> GTot
(i: size_nat{i < v n} -> ((Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 = | false | null | false | modifies2 write0 write1 h0 h /\
(let s0, s1 = Loop.repeati i (spec h0) (as_seq h0 write0, as_seq h0 write1) in
as_seq h write0 == s0 /\ as_seq h write1 == s1) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.lseq",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Lib.Buffer.modifies2",
"Prims.eq2",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.logical",
"Lib.LoopCombinators.repeati",
"FStar.Pervasives.Native.Mktuple2"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s
let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction
val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b)
unfold private
let cpred (#a:Type0) (s:Seq.seq a) : B.spred a = fun s1 -> FStar.Seq.equal s s1
let witnessed (#a:Type0) (#len:size_t) (b:glbuffer a len) (s:Seq.lseq a (v len)) =
B.witnessed (CB.as_mbuf b) (cpred s)
(** Allocate a stack fixed-length mutable buffer and initialize it to value [init] *)
inline_for_extraction
val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init))
#set-options "--max_fuel 1"
(** Allocate a stack fixed-length mutable buffer initialized to a list *)
inline_for_extraction
val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init))
(** Allocate a global fixed-length const immutable buffer initialized to value [init] *)
inline_for_extraction
val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init))
(** Allocate a global fixed-length mutable buffer initialized to value [init] *)
inline_for_extraction
val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init))
#set-options "--max_fuel 0"
(** Recall the liveness and contents of a global immutable buffer *)
inline_for_extraction
val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s)
(** Copy a buffer into a mutable buffer *)
inline_for_extraction
val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i)
(**
* Set all elements of a mutable buffer to a specific value
*
* WARNING: don't rely on the extracted implementation for secure erasure,
* C compilers may remove optimize it away.
*)
inline_for_extraction
val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len)))
(** Copy a buffer into a sub-buffer of a mutable buffer *)
inline_for_extraction
val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
(** Update a mutable buffer in-place by applying a function on a sub-buffer of it *)
inline_for_extraction
val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0))
(** Copy two buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1))
(** Copy three buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2))
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
let loop_inv
(h0:mem)
(n:size_t)
(a_spec:(i:size_nat{i <= v n} -> Type))
(refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i)))
(footprint:(i:size_nat{i <= v n} -> GTot B.loc))
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies (footprint i) h0 h /\
refl h i == Loop.repeat_gen i a_spec (spec h0) (refl h0 0)
(**
* A generalized loop combinator paremetrized by its state (e.g. an accumulator)
*
* Arguments:
* - [h0] the heap when entering the loop
* - [n] the number of iterations
* - [a_spec] the type for the specification state (may depend on the loop index)
* - [refl] a ghost function that reflects the Low* state in an iteration as [a_spec]
* - [footprint] locations modified by the loop (may depend on the loop index)
* - [spec] a specification of how the body of the loop modifies the state
* - [impl] the body of the loop as a Stack function
*)
inline_for_extraction
val loop:
h0:mem
-> n:size_t
-> a_spec:(i:size_nat{i <= v n} -> Type)
-> refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i))
-> footprint:(i:size_nat{i <= v n} -> GTot B.loc)
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_inv h0 n a_spec refl footprint spec (v n) h1)
let loop_refl_inv
(h0:mem)
(n:size_t)
(a_spec: Type)
(refl:(mem -> GTot a_spec))
(footprint:B.loc)
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec)))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies footprint h0 h /\
refl h == Loop.repeati i (spec h0) (refl h0)
inline_for_extraction
val loop_refl:
h0:mem
-> n:size_t
-> a_spec:Type
-> refl:(mem -> GTot a_spec)
-> footprint:Ghost.erased B.loc
-> spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec -> a_spec))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop_refl_inv h0 n a_spec refl footprint spec (v i))
(ensures fun _ _ h -> loop_refl_inv h0 n a_spec refl footprint spec (v i + 1) h)) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 -> loop_refl_inv h0 n a_spec refl footprint spec (v n) h1)
let loop1_inv
(h0:mem)
(n:size_t)
(b: Type)
(blen: size_t)
(write:lbuffer b blen)
(spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies1 write h0 h /\
as_seq h write == Loop.repeati i (spec h0) (as_seq h0 write)
(** Loop combinator specialized to modifying a single buffer [write] *)
inline_for_extraction
val loop1:
#b:Type
-> #blen:size_t
-> h0:mem
-> n:size_t
-> write:lbuffer b blen
-> spec:(mem -> GTot (i:size_nat{i < v n} -> Seq.lseq b (v blen) -> Seq.lseq b (v blen)))
-> impl:(i:size_t{v i < v n} -> Stack unit
(requires loop1_inv h0 n b blen write spec (v i))
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v i + 1))) ->
Stack unit
(requires fun h -> h0 == h)
(ensures fun _ _ -> loop1_inv h0 n b blen write spec (v n))
let loop2_inv
(#b0:Type)
(#blen0:size_t)
(#b1:Type)
(#blen1:size_t)
(h0:mem)
(n:size_t)
(write0:lbuffer b0 blen0)
(write1:lbuffer b1 blen1)
(spec:(mem -> GTot (i:size_nat{i < v n}
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1))
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))))
(i:size_nat{i <= v n})
(h:mem):
Type0 | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop2_inv
(#b0: Type)
(#blen0: size_t)
(#b1: Type)
(#blen1: size_t)
(h0: mem)
(n: size_t)
(write0: lbuffer b0 blen0)
(write1: lbuffer b1 blen1)
(spec:
(mem
-> GTot
(i: size_nat{i < v n} -> ((Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))
-> (Seq.lseq b0 (v blen0)) & (Seq.lseq b1 (v blen1)))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [] | Lib.Buffer.loop2_inv | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
write0: Lib.Buffer.lbuffer b0 blen0 ->
write1: Lib.Buffer.lbuffer b1 blen1 ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(
i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} ->
_:
(Lib.Sequence.lseq b0 (Lib.IntTypes.v blen0) *
Lib.Sequence.lseq b1 (Lib.IntTypes.v blen1))
-> Lib.Sequence.lseq b0 (Lib.IntTypes.v blen0) *
Lib.Sequence.lseq b1 (Lib.IntTypes.v blen1))) ->
i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} ->
h: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 50,
"end_line": 730,
"start_col": 2,
"start_line": 728
} |
Prims.Tot | val loop_inv
(h0: mem)
(n: size_t)
(a_spec: (i: size_nat{i <= v n} -> Type))
(refl: (mem -> i: size_nat{i <= v n} -> GTot (a_spec i)))
(footprint: (i: size_nat{i <= v n} -> GTot B.loc))
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loop_inv
(h0:mem)
(n:size_t)
(a_spec:(i:size_nat{i <= v n} -> Type))
(refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i)))
(footprint:(i:size_nat{i <= v n} -> GTot B.loc))
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i:size_nat{i <= v n})
(h:mem):
Type0
=
modifies (footprint i) h0 h /\
refl h i == Loop.repeat_gen i a_spec (spec h0) (refl h0 0) | val loop_inv
(h0: mem)
(n: size_t)
(a_spec: (i: size_nat{i <= v n} -> Type))
(refl: (mem -> i: size_nat{i <= v n} -> GTot (a_spec i)))
(footprint: (i: size_nat{i <= v n} -> GTot B.loc))
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i: size_nat{i <= v n})
(h: mem)
: Type0
let loop_inv
(h0: mem)
(n: size_t)
(a_spec: (i: size_nat{i <= v n} -> Type))
(refl: (mem -> i: size_nat{i <= v n} -> GTot (a_spec i)))
(footprint: (i: size_nat{i <= v n} -> GTot B.loc))
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 = | false | null | false | modifies (footprint i) h0 h /\ refl h i == Loop.repeat_gen i a_spec (spec h0) (refl h0 0) | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"LowStar.Monotonic.Buffer.loc",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.l_and",
"Lib.Buffer.modifies",
"Prims.eq2",
"Lib.LoopCombinators.repeat_gen"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h
(** Modifies nothing *)
let modifies0 (h1 h2:HS.mem) =
modifies (B.loc_none) h1 h2
(** Modifies one buffer *)
let modifies1 (#a:Type0) (b:buffer_t MUT a) (h1 h2:HS.mem) =
modifies (loc b) h1 h2
(** Modifies two buffers *)
let modifies2 (#a0:Type0) (#a1:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1) h1 h2
(** Modifies three buffers *)
let modifies3 (#a0:Type0) (#a1:Type0) (#a2:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2) h1 h2
(** Modifies four buffers *)
let modifies4 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h1 h2
(** Modifies five buffers *)
let modifies5 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4) h1 h2
(** Modifies six buffers *)
let modifies6 (#a0:Type0) (#a1:Type0) (#a2:Type0) (#a3:Type0) (#a4:Type0) (#a5:Type0)
(b0:buffer_t MUT a0) (b1:buffer_t MUT a1) (b2:buffer_t MUT a2) (b3:buffer_t MUT a3)
(b4:buffer_t MUT a4) (b5:buffer_t MUT a5) (h1 h2: HS.mem) =
modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5) h1 h2
(** Ghost reveal a buffer as a sequence *)
let as_seq (#t:buftype) (#a:Type0) (#len:size_t) (h:HS.mem) (b:lbuffer_t t a len) :
GTot (Seq.lseq a (v len)) =
match t with
| MUT -> B.as_seq h (b <: buffer a)
| IMMUT -> IB.as_seq h (b <: ibuffer a)
| CONST -> CB.as_seq h (b <: cbuffer a)
(** Ghostly get a sub-buffer of a buffer *)
let gsub (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len)
(start:size_t) (n:size_t{v start + v n <= v len}) : GTot (lbuffer_t t a n)
=
match t with
| IMMUT->
let b = IB.igsub (b <: ibuffer a) start n in
assert (B.length b == v n);
(b <: ilbuffer a n)
| MUT ->
let b = B.gsub (b <: buffer a) start n in
assert (B.length b == v n);
(b <: lbuffer a n)
| CONST ->
let b = CB.gsub (b <: cbuffer a) start n in
assert (CB.length b == v n);
(b <: clbuffer a n)
(** JP: are these not covered already by standard SMT patterns? is this to avoid
having to invert on `buftype`? *)
val live_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h:mem
-> Lemma
(ensures live h b ==> live h (gsub b start n))
[SMTPat (live h (gsub b start n))]
val modifies_sub: #t:buftype -> #a:Type0 -> #len:size_t -> b:lbuffer_t t a len
-> start:size_t -> n:size_t{v start + v n <= v len} -> h0:mem -> h1:mem
-> Lemma
(requires modifies (loc (gsub b start n)) h0 h1)
(ensures modifies (loc b) h0 h1)
[SMTPat (modifies (loc (gsub b start n)) h0 h1)]
inline_for_extraction
val as_seq_gsub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:HS.mem
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Lemma
(as_seq h (gsub b start n) ==
Seq.sub #a #(v len) (as_seq h b) (v start) (v n))
[SMTPat (Seq.sub #a #(v len) (as_seq h b) (v start) (v n))]
(** Statefully get a sub-buffer of a buffer *)
inline_for_extraction
val sub:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len
-> start:size_t
-> n:size_t{v start + v n <= v len} ->
Stack (lbuffer_t t a n)
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == gsub b start n)
(** Statefully read an element in a buffer *)
inline_for_extraction
val index:
#t:buftype
-> #a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer_t t a len
-> i:size_t{v i < v len} ->
Stack a
(requires fun h0 -> live h0 b)
(ensures fun h0 r h1 ->
h0 == h1 /\
r == Seq.index #a #(v len) (as_seq h1 b) (v i))
(** Update a specific value in a mutable buffer *)
inline_for_extraction
val upd:
#a:Type0
-> #len:size_t{v len > 0}
-> b:lbuffer a len
-> i:size_t{v i < v len}
-> x:a ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 b == Seq.upd #a #(v len) (as_seq h0 b) (v i) x)
(** Operator for updating a mutable buffer: b.(i) <- x *)
inline_for_extraction
let op_Array_Assignment #a #len = upd #a #len
(** Operator for accessing a buffer: b.(i) *)
inline_for_extraction
let op_Array_Access #t #a #len = index #t #a #len
(* 2018.16.11 SZ: this doesn't parse: let f a len (b:lbuffer a len) h = h.[| b |] *)
(** Operator for getting a ghost view of a buffer as a sequence: h.[(b)] *)
inline_for_extraction
let op_Brack_Lens_Access #t #a #len = as_seq #t #a #len
(** Ghostly read an element in a buffer *)
let bget (#t:buftype) (#a:Type0) (#len:size_t) (h:mem) (b:lbuffer_t t a len)
(i:size_nat{i < v len}) : GTot a
=
match t with
| MUT -> B.get h (b <: buffer a) i
| IMMUT -> IB.get h (b <: ibuffer a) i
| CONST -> FStar.Seq.index (CB.as_seq h (b <: cbuffer a)) i
(* We don't have access to Lib.Sequence to know `Lib.Sequence.index == FStar.Seq.index` *)
val bget_as_seq:
#t:buftype
-> #a:Type0
-> #len:size_t
-> h:mem
-> b:lbuffer_t t a len
-> i:size_nat
-> Lemma
(requires i < v len)
(ensures bget #t #a #len h b i == Seq.index #a #(v len) (as_seq h b) i)
[SMTPat (bget #t #a #len h b i)]
let stack_allocated (#a:Type0) (#len:size_t) (b:lbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: B.buffer a = b in
B.alloc_post_mem_common b h0 h1 s /\
B.frameOf b = HS.get_tip h0 /\
B.frameOf b <> HyperStack.root
let global_allocated (#a:Type0) (#len:size_t) (b:glbuffer a len)
(h0:mem) (h1:mem) (s:Seq.lseq a (v len)) =
let b: ibuffer a = CB.as_mbuf b in
B.frameOf b == HyperStack.root /\
B.alloc_post_mem_common b h0 h1 s
let recallable (#t:buftype) (#a:Type0) (#len:size_t) (b:lbuffer_t t a len) =
match t with
| IMMUT -> B.recallable (b <: ibuffer a)
| MUT -> B.recallable (b <: buffer a)
| CONST -> B.recallable (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction
val recall:
#t:buftype
-> #a:Type0
-> #len:size_t
-> b:lbuffer_t t a len ->
Stack unit
(requires fun _ -> recallable b)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b)
unfold private
let cpred (#a:Type0) (s:Seq.seq a) : B.spred a = fun s1 -> FStar.Seq.equal s s1
let witnessed (#a:Type0) (#len:size_t) (b:glbuffer a len) (s:Seq.lseq a (v len)) =
B.witnessed (CB.as_mbuf b) (cpred s)
(** Allocate a stack fixed-length mutable buffer and initialize it to value [init] *)
inline_for_extraction
val create:
#a:Type0
-> len:size_t
-> init:a ->
StackInline (lbuffer a len)
(requires fun h0 -> v len > 0)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create (v len) init))
#set-options "--max_fuel 1"
(** Allocate a stack fixed-length mutable buffer initialized to a list *)
inline_for_extraction
val createL:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
StackInline (lbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.alloca_of_list_pre #a init)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.of_list init))
(** Allocate a global fixed-length const immutable buffer initialized to value [init] *)
inline_for_extraction
val createL_global:
#a:Type0
-> init:list a{normalize (List.Tot.length init <= max_size_t)} ->
ST (glbuffer a (size (normalize_term (List.Tot.length init))))
(requires fun h0 -> B.gcmalloc_of_list_pre #a HyperStack.root init)
(ensures fun h0 b h1 -> global_allocated b h0 h1 (Seq.of_list init) /\
recallable b /\
witnessed b (Seq.of_list init))
(** Allocate a global fixed-length mutable buffer initialized to value [init] *)
inline_for_extraction
val createL_mglobal: #a:Type0 -> init:list a ->
ST (buffer a)
(requires fun h0 -> normalize (FStar.List.Tot.length init <= max_size_t))
(ensures fun h0 b h1 ->
B.frameOf b == HyperStack.root /\ B.recallable b /\
B.alloc_post_mem_common (b <: buffer a) h0 h1 (FStar.Seq.seq_of_list init) /\
length b == normalize_term (FStar.List.Tot.length init))
#set-options "--max_fuel 0"
(** Recall the liveness and contents of a global immutable buffer *)
inline_for_extraction
val recall_contents:
#a:Type0
-> #len:size_t{v len <= max_size_t}
-> b:glbuffer a len
-> s:Seq.lseq a (v len) ->
ST unit
(requires fun h0 -> (live h0 b \/ recallable b) /\ witnessed b s)
(ensures fun h0 _ h1 -> h0 == h1 /\ live h0 b /\ as_seq h0 b == s)
(** Copy a buffer into a mutable buffer *)
inline_for_extraction
val copy:
#t:buftype
-> #a:Type
-> #len:size_t
-> o:lbuffer a len
-> i:lbuffer_t t a len ->
Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == as_seq h0 i)
(**
* Set all elements of a mutable buffer to a specific value
*
* WARNING: don't rely on the extracted implementation for secure erasure,
* C compilers may remove optimize it away.
*)
inline_for_extraction
val memset:
#a:Type
-> #blen:size_t
-> b:lbuffer a blen
-> w:a
-> len:size_t{v len <= v blen} ->
Stack unit
(requires fun h0 -> live h0 b)
(ensures fun h0 _ h1 ->
modifies1 b h0 h1 /\
as_seq h1 (gsub b 0ul len) == Seq.create (v len) w /\
as_seq h1 (gsub b len (blen -! len)) ==
as_seq h0 (gsub b len (blen -! len)))
(** Copy a buffer into a sub-buffer of a mutable buffer *)
inline_for_extraction
val update_sub:
#t:buftype
-> #a:Type
-> #len:size_t
-> dst:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> src:lbuffer_t t a n ->
Stack unit
(requires fun h -> live h dst /\ live h src /\ disjoint dst src)
(ensures fun h0 _ h1 ->
modifies1 dst h0 h1 /\
as_seq h1 dst == Seq.update_sub (as_seq h0 dst) (v start) (v n) (as_seq h0 src))
(** Update a mutable buffer in-place by applying a function on a sub-buffer of it *)
inline_for_extraction
val update_sub_f:
#a:Type
-> #len:size_t
-> h0:mem
-> buf:lbuffer a len
-> start:size_t
-> n:size_t{v start + v n <= v len}
-> spec:(mem -> GTot (Seq.lseq a (v n)))
-> f:(unit -> Stack unit
(requires fun h -> h0 == h)
(ensures fun h0 _ h1 ->
(let b = gsub buf start n in
modifies (loc b) h0 h1 /\
as_seq h1 b == spec h0))) ->
Stack unit
(requires fun h -> h0 == h /\ live h buf)
(ensures fun h0 _ h1 ->
modifies (loc buf) h0 h1 /\
as_seq h1 buf == Seq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) (spec h0))
(** Copy two buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat2:
#t0:buftype
-> #t1:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> s:lbuffer a (len0 +! len1)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s /\
disjoint s s0 /\ disjoint s s1)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (as_seq h0 s0) (as_seq h0 s1))
(** Copy three buffers one after the other into a mutable buffer *)
inline_for_extraction
val concat3:
#t0:buftype
-> #t1:buftype
-> #t2:buftype
-> #a:Type0
-> len0:size_t
-> s0:lbuffer_t t0 a len0
-> len1:size_t{v len0 + v len1 <= max_size_t}
-> s1:lbuffer_t t1 a len1
-> len2:size_t{v len0 + v len1 + v len2 <= max_size_t}
-> s2:lbuffer_t t2 a len2
-> s:lbuffer a (len0 +! len1 +! len2)
-> Stack unit
(requires fun h ->
live h s0 /\ live h s1 /\ live h s2 /\ live h s /\
disjoint s s0 /\ disjoint s s1 /\ disjoint s s2)
(ensures fun h0 _ h1 ->
modifies1 s h0 h1 /\
as_seq h1 s == Seq.concat (Seq.concat (as_seq h0 s0) (as_seq h0 s1)) (as_seq h0 s2))
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> n:size_t
-> buf:lbuffer a len
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec2:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #len1:size_t
-> #len2:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies2 buf1 buf2 h0 h)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2)
(ensures fun _ _ h1 -> modifies2 buf1 buf2 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_nospec3:
#h0:mem
-> #a1:Type0
-> #a2:Type0
-> #a3:Type0
-> #len1:size_t
-> #len2:size_t
-> #len3:size_t
-> n:size_t
-> buf1:lbuffer a1 len1
-> buf2:lbuffer a2 len2
-> buf3:lbuffer a3 len3
-> impl: (i:size_t{v i < v n} -> Stack unit
(requires fun h -> modifies3 buf1 buf2 buf3 h0 h)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf1 /\ live h0 buf2 /\ live h0 buf3)
(ensures fun _ _ h1 -> modifies3 buf1 buf2 buf3 h0 h1)
(** Loop combinator with just memory safety specification *)
inline_for_extraction
val loop_range_nospec:
#h0:mem
-> #a:Type0
-> #len:size_t
-> start:size_t
-> n:size_t{v start + v n <= max_size_t}
-> buf:lbuffer a len
-> impl: (i:size_t{v start <= v i /\ v i < v start + v n} -> Stack unit
(requires fun h -> modifies1 buf h0 h)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)) ->
Stack unit
(requires fun h -> h0 == h /\ live h0 buf)
(ensures fun _ _ h1 -> modifies1 buf h0 h1)
let loop_inv
(h0:mem)
(n:size_t)
(a_spec:(i:size_nat{i <= v n} -> Type))
(refl:(mem -> i:size_nat{i <= v n} -> GTot (a_spec i)))
(footprint:(i:size_nat{i <= v n} -> GTot B.loc))
(spec:(mem -> GTot (i:size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i:size_nat{i <= v n})
(h:mem):
Type0 | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loop_inv
(h0: mem)
(n: size_t)
(a_spec: (i: size_nat{i <= v n} -> Type))
(refl: (mem -> i: size_nat{i <= v n} -> GTot (a_spec i)))
(footprint: (i: size_nat{i <= v n} -> GTot B.loc))
(spec: (mem -> GTot (i: size_nat{i < v n} -> a_spec i -> a_spec (i + 1))))
(i: size_nat{i <= v n})
(h: mem)
: Type0 | [] | Lib.Buffer.loop_inv | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
n: Lib.IntTypes.size_t ->
a_spec: (i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} -> Type) ->
refl:
(_: FStar.Monotonic.HyperStack.mem -> i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n}
-> Prims.GTot (a_spec i)) ->
footprint:
(i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} -> Prims.GTot LowStar.Monotonic.Buffer.loc) ->
spec:
(_: FStar.Monotonic.HyperStack.mem
-> Prims.GTot
(i: Lib.IntTypes.size_nat{i < Lib.IntTypes.v n} -> _: a_spec i -> a_spec (i + 1))) ->
i: Lib.IntTypes.size_nat{i <= Lib.IntTypes.v n} ->
h: FStar.Monotonic.HyperStack.mem
-> Type0 | {
"end_col": 60,
"end_line": 623,
"start_col": 2,
"start_line": 622
} |
Prims.Tot | val const_to_ibuffer (#a: _) (b: cbuffer a {CB.qual_of b == CB.IMMUTABLE})
: r: ibuffer a {length r == length b} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b | val const_to_ibuffer (#a: _) (b: cbuffer a {CB.qual_of b == CB.IMMUTABLE})
: r: ibuffer a {length r == length b}
let const_to_ibuffer #a (b: cbuffer a {CB.qual_of b == CB.IMMUTABLE})
: r: ibuffer a {length r == length b} = | false | null | false | CB.to_ibuffer b | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"total"
] | [
"Lib.Buffer.cbuffer",
"Prims.eq2",
"LowStar.ConstBuffer.qual",
"LowStar.ConstBuffer.qual_of",
"LowStar.ConstBuffer.IMMUTABLE",
"LowStar.ConstBuffer.to_ibuffer",
"Lib.Buffer.ibuffer",
"Prims.nat",
"Lib.Buffer.length",
"Lib.Buffer.IMMUT",
"Lib.Buffer.CONST"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val const_to_ibuffer (#a: _) (b: cbuffer a {CB.qual_of b == CB.IMMUTABLE})
: r: ibuffer a {length r == length b} | [] | Lib.Buffer.const_to_ibuffer | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.cbuffer a {LowStar.ConstBuffer.qual_of b == LowStar.ConstBuffer.IMMUTABLE}
-> r: Lib.Buffer.ibuffer a {Lib.Buffer.length r == Lib.Buffer.length b} | {
"end_col": 17,
"end_line": 65,
"start_col": 2,
"start_line": 65
} |
FStar.Pervasives.Lemma | val mut_const_immut_disjoint (#t #t': _) (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[
SMTPat (B.loc_disjoint (loc b) (loc ib));
SMTPat (B.live h b);
SMTPat (B.live h (CB.as_mbuf ib))
] | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loop"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "ByteSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "LMB"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))]
=
IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h | val mut_const_immut_disjoint (#t #t': _) (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[
SMTPat (B.loc_disjoint (loc b) (loc ib));
SMTPat (B.live h b);
SMTPat (B.live h (CB.as_mbuf ib))
]
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[
SMTPat (B.loc_disjoint (loc b) (loc ib));
SMTPat (B.live h b);
SMTPat (B.live h (CB.as_mbuf ib))
] = | false | null | true | IB.buffer_immutable_buffer_disjoint #t #t' b (CB.as_mbuf #t' ib) h | {
"checked_file": "Lib.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.Buffer.fsti"
} | [
"lemma"
] | [
"Lib.Buffer.buffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.CONST",
"FStar.Monotonic.HyperStack.mem",
"LowStar.ImmutableBuffer.buffer_immutable_buffer_disjoint",
"LowStar.ConstBuffer.as_mbuf",
"Prims.unit",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Buffer.trivial_preorder",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"Prims.eq2",
"LowStar.ConstBuffer.qual",
"LowStar.ConstBuffer.qual_of",
"LowStar.ConstBuffer.IMMUTABLE",
"Prims.squash",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Lib.Buffer.loc",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module Lib.Buffer
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.RawIntTypes
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module CB = LowStar.ConstBuffer
module LMB = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module Seq = Lib.Sequence
module ByteSeq = Lib.ByteSequence
module Loop = Lib.LoopCombinators
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
type buftype =
| MUT
| IMMUT
| CONST
inline_for_extraction
let buffer_t (t:buftype) (a:Type0) =
match t with
| IMMUT -> IB.ibuffer a
| MUT -> B.buffer a
| CONST -> CB.const_buffer a
(** Mutable buffer. Extracted as `a*` *)
unfold let buffer (a:Type0) = buffer_t MUT a
(** Immutable buffer. Extracted as `a*`. Enjoys nice properties for recalling contents. *)
unfold let ibuffer (a:Type0) = buffer_t IMMUT a
(** Const buffer. Either one of the two above. Extracts as `const a*`. *)
unfold let cbuffer (a:Type0) = buffer_t CONST a
(** Global buffers are const immutable *)
unfold let gbuffer (a:Type0) = c:cbuffer a{CB.qual_of c == CB.IMMUTABLE}
let length (#t:buftype) (#a:Type0) (b:buffer_t t a) =
match t with
| MUT -> B.length (b <: buffer a)
| IMMUT -> IB.length (b <: ibuffer a)
| CONST -> CB.length (b <: cbuffer a)
inline_for_extraction
let to_const #a #t (b:buffer_t t a) : r:cbuffer a {length r == length b}=
match t with
| MUT -> CB.of_buffer (b <: buffer a)
| IMMUT -> CB.of_ibuffer (b <: ibuffer a)
| CONST -> b <: cbuffer a
let const_to_buffer #a (b:cbuffer a{CB.qual_of b == CB.MUTABLE}) : r:buffer a{length r == length b} =
CB.to_buffer b
let const_to_ibuffer #a (b:cbuffer a{CB.qual_of b == CB.IMMUTABLE}) : r:ibuffer a{length r == length b} =
CB.to_ibuffer b
inline_for_extraction
let lbuffer_t (t:buftype) (a:Type0) (len:size_t) =
b:buffer_t t a{length #t #a b == v len}
unfold let lbuffer (a:Type0) (len:size_t) = lbuffer_t MUT a len
unfold let ilbuffer (a:Type0) (len:size_t) = lbuffer_t IMMUT a len
unfold let clbuffer (a:Type0) (len:size_t) = lbuffer_t CONST a len
unfold let glbuffer (a:Type0) (len:size_t) = c:clbuffer a len{CB.qual_of #a c == CB.IMMUTABLE}
let const_to_lbuffer #a #len
(b:clbuffer a len{CB.qual_of (b <: cbuffer a) == CB.MUTABLE}) : lbuffer a len =
const_to_buffer #a b
let const_to_ilbuffer #a #len (b:glbuffer a len) : ilbuffer a len =
const_to_ibuffer #a b
unfold let null (#t : buftype) (a : Type0) : buffer_t t a =
match t with
| IMMUT -> IB.inull #a
| MUT -> B.null #a
| CONST -> CB.null a
let g_is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot bool =
match t with
| IMMUT -> IB.g_is_null (b <: ibuffer a)
| MUT -> B.g_is_null (b <: buffer a)
| CONST -> B.g_is_null (CB.as_mbuf (b <: cbuffer a))
let live (#t:buftype) (#a:Type0) (h:HS.mem) (b:buffer_t t a) : Type =
match t with
| MUT -> B.live h (b <: buffer a)
| IMMUT -> IB.live h (b <: ibuffer a)
| CONST -> CB.live h (b <: cbuffer a)
let freeable (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot Type0 =
match t with
| IMMUT -> IB.freeable (b <: ibuffer a)
| MUT -> B.freeable (b <: buffer a)
| CONST -> B.freeable (CB.as_mbuf (b <: cbuffer a))
let loc (#t:buftype) (#a:Type0) (b:buffer_t t a) : GTot B.loc =
match t with
| MUT -> B.loc_buffer (b <: buffer a)
| IMMUT -> B.loc_buffer (b <: ibuffer a)
| CONST -> CB.loc_buffer (b <: cbuffer a)
let loc_addr_of_buffer (#t : buftype) (#a : Type0) (b : buffer_t t a) : GTot B.loc =
match t with
| IMMUT -> IB.loc_addr_of_buffer (b <: ibuffer a)
| MUT -> B.loc_addr_of_buffer (b <: buffer a)
| CONST -> B.loc_addr_of_buffer (CB.as_mbuf (b <: cbuffer a))
inline_for_extraction noextract
let is_null (#t : buftype) (#a : Type0) (b : buffer_t t a) :
Stack bool
(requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b)) =
match t with
| IMMUT -> IB.is_null (b <: ibuffer a)
| MUT -> B.is_null (b <: buffer a)
| CONST -> CB.is_null (b <: cbuffer a)
let get (#t : buftype) (#a : Type0) (h : mem) (b : buffer_t t a) (i : nat{i < length b}) :
GTot a =
match t with
| IMMUT -> IB.get h (b <: ibuffer a) i
| MUT -> B.get h (b <: buffer a) i
| CONST -> B.get h (CB.as_mbuf (b <: cbuffer a)) i
#set-options "--max_ifuel 0"
let union (l1:B.loc) (l2:B.loc) : GTot B.loc = B.loc_union l1 l2
let ( |+| ) (l1:B.loc) (l2:B.loc) : GTot B.loc = union l1 l2
(** Generalized modification clause for Buffer locations *)
let modifies (s:B.loc) (h1 h2:HS.mem) = B.modifies s h1 h2
(* JP: redefining is generally dangerous; someone may inadvertently write a pattern
for the disjoint predicate below, which does not enjoy transitivity, etc. and run
into strange behavior. This explains why the SMTPat on mut_immut_disjoint
operates over B.loc_disjoint, not disjoint. *)
(** Disjointness clause for Buffers *)
let disjoint (#t1 #t2:buftype) (#a1 #a2:Type0) (b1:buffer_t t1 a1) (b2:buffer_t t2 a2) =
B.loc_disjoint (loc b1) (loc b2)
let mut_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t IMMUT t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h ib))
(ensures (disjoint b ib))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h ib)]
=
IB.buffer_immutable_buffer_disjoint b ib h
let mut_const_immut_disjoint #t #t' (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem):
Lemma
(requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[SMTPat (B.loc_disjoint (loc b) (loc ib)); SMTPat (B.live h b); SMTPat (B.live h (CB.as_mbuf ib))] | false | false | Lib.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mut_const_immut_disjoint (#t #t': _) (b: buffer_t MUT t) (ib: buffer_t CONST t') (h: HS.mem)
: Lemma (requires (B.live h b /\ B.live h (CB.as_mbuf ib) /\ CB.qual_of #t' ib == CB.IMMUTABLE))
(ensures (B.loc_disjoint (loc b) (loc ib)))
[
SMTPat (B.loc_disjoint (loc b) (loc ib));
SMTPat (B.live h b);
SMTPat (B.live h (CB.as_mbuf ib))
] | [] | Lib.Buffer.mut_const_immut_disjoint | {
"file_name": "lib/Lib.Buffer.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Lib.Buffer.buffer_t Lib.Buffer.MUT t ->
ib: Lib.Buffer.buffer_t Lib.Buffer.CONST t' ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.live h b /\
LowStar.Monotonic.Buffer.live h (LowStar.ConstBuffer.as_mbuf ib) /\
LowStar.ConstBuffer.qual_of ib == LowStar.ConstBuffer.IMMUTABLE)
(ensures LowStar.Monotonic.Buffer.loc_disjoint (Lib.Buffer.loc b) (Lib.Buffer.loc ib))
[
SMTPat (LowStar.Monotonic.Buffer.loc_disjoint (Lib.Buffer.loc b) (Lib.Buffer.loc ib));
SMTPat (LowStar.Monotonic.Buffer.live h b);
SMTPat (LowStar.Monotonic.Buffer.live h (LowStar.ConstBuffer.as_mbuf ib))
] | {
"end_col": 68,
"end_line": 168,
"start_col": 2,
"start_line": 168
} |
Prims.Tot | val parse_int32le:parser (total_constant_size_parser_kind 4) U32.t | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le | val parse_int32le:parser (total_constant_size_parser_kind 4) U32.t
let parse_int32le:parser (total_constant_size_parser_kind 4) U32.t = | false | null | false | decode_int32le_total_constant ();
make_total_constant_size_parser 4 U32.t decode_int32le | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"total"
] | [
"LowParse.Spec.Combinators.make_total_constant_size_parser",
"FStar.UInt32.t",
"LowParse.Spec.Int32le.decode_int32le",
"Prims.unit",
"LowParse.Spec.Int32le.decode_int32le_total_constant"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective | false | false | LowParse.Spec.Int32le.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val parse_int32le:parser (total_constant_size_parser_kind 4) U32.t | [] | LowParse.Spec.Int32le.parse_int32le | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Spec.Base.parser (LowParse.Spec.Base.total_constant_size_parser_kind 4) FStar.UInt32.t | {
"end_col": 56,
"end_line": 53,
"start_col": 2,
"start_line": 52
} |
FStar.Pervasives.Lemma | val le_to_n_0_eq (b: bytes{Seq.length b == 0}) : Lemma (le_to_n b == 0) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 le_to_n_0_eq
(b : bytes { Seq.length b == 0 } )
: Lemma (le_to_n b == 0)
= reveal_le_to_n b | val le_to_n_0_eq (b: bytes{Seq.length b == 0}) : Lemma (le_to_n b == 0)
let le_to_n_0_eq (b: bytes{Seq.length b == 0}) : Lemma (le_to_n b == 0) = | false | null | true | reveal_le_to_n b | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.Endianness.reveal_le_to_n",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"FStar.Endianness.le_to_n",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective
let parse_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le
let serialize_int32le : serializer parse_int32le
= fun (x : U32.t) -> n_to_le 4 (U32.v x)
(* lemmas for inplace comparison in validators *)
let le_to_n_0_eq
(b : bytes { Seq.length b == 0 } ) | false | false | LowParse.Spec.Int32le.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 le_to_n_0_eq (b: bytes{Seq.length b == 0}) : Lemma (le_to_n b == 0) | [] | LowParse.Spec.Int32le.le_to_n_0_eq | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == 0}
-> FStar.Pervasives.Lemma (ensures FStar.Endianness.le_to_n b == 0) | {
"end_col": 18,
"end_line": 63,
"start_col": 2,
"start_line": 63
} |
Prims.Tot | val decode_int32le (b: bytes{Seq.length b == 4})
: Tot (v: U32.t{0 <= U32.v v /\ U32.v v < 4294967296}) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res | val decode_int32le (b: bytes{Seq.length b == 4})
: Tot (v: U32.t{0 <= U32.v v /\ U32.v v < 4294967296})
let decode_int32le (b: bytes{Seq.length b == 4})
: Tot (v: U32.t{0 <= U32.v v /\ U32.v v < 4294967296}) = | false | null | false | lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"total"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.UInt32.uint_to_t",
"Prims.unit",
"Prims._assert",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.nat",
"FStar.Endianness.le_to_n",
"FStar.Math.Lemmas.pow2_le_compat",
"FStar.Endianness.lemma_le_to_n_is_bounded",
"FStar.UInt32.t",
"FStar.UInt32.v"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } ) | false | false | LowParse.Spec.Int32le.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 decode_int32le (b: bytes{Seq.length b == 4})
: Tot (v: U32.t{0 <= U32.v v /\ U32.v v < 4294967296}) | [] | LowParse.Spec.Int32le.decode_int32le | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == 4}
-> v: FStar.UInt32.t{0 <= FStar.UInt32.v v /\ FStar.UInt32.v v < 4294967296} | {
"end_col": 19,
"end_line": 28,
"start_col": 2,
"start_line": 24
} |
FStar.Pervasives.Lemma | val decode_int32le_total_constant: Prims.unit
-> Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective | val decode_int32le_total_constant: Prims.unit
-> Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
let decode_int32le_total_constant ()
: Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le) = | false | null | true | Classical.forall_intro_2 decode_int32le_injective | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"Prims.unit",
"FStar.Classical.forall_intro_2",
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_imp",
"FStar.UInt32.t",
"Prims.l_or",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.Spec.Int32le.decode_int32le",
"LowParse.Spec.Int32le.decode_int32le_injective",
"Prims.l_True",
"Prims.squash",
"LowParse.Spec.Combinators.make_total_constant_size_parser_precond",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
() | false | false | LowParse.Spec.Int32le.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 decode_int32le_total_constant: Prims.unit
-> Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le) | [] | LowParse.Spec.Int32le.decode_int32le_total_constant | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Combinators.make_total_constant_size_parser_precond 4
FStar.UInt32.t
LowParse.Spec.Int32le.decode_int32le) | {
"end_col": 51,
"end_line": 49,
"start_col": 2,
"start_line": 49
} |
Prims.Tot | val serialize_int32le:serializer parse_int32le | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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_int32le : serializer parse_int32le
= fun (x : U32.t) -> n_to_le 4 (U32.v x) | val serialize_int32le:serializer parse_int32le
let serialize_int32le:serializer parse_int32le = | false | null | false | fun (x: U32.t) -> n_to_le 4 (U32.v x) | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"FStar.Endianness.n_to_le",
"FStar.UInt32.v",
"FStar.Endianness.bytes",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.UInt8.t",
"FStar.Endianness.le_to_n"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective
let parse_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le | false | false | LowParse.Spec.Int32le.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 serialize_int32le:serializer parse_int32le | [] | LowParse.Spec.Int32le.serialize_int32le | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Spec.Base.serializer LowParse.Spec.Int32le.parse_int32le | {
"end_col": 40,
"end_line": 56,
"start_col": 2,
"start_line": 56
} |
FStar.Pervasives.Lemma | val decode_int32le_injective (b1: bytes{Seq.length b1 == 4}) (b2: bytes{Seq.length b2 == 4})
: Lemma (decode_int32le b1 == decode_int32le b2 ==> b1 == b2) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
() | val decode_int32le_injective (b1: bytes{Seq.length b1 == 4}) (b2: bytes{Seq.length b2 == 4})
: Lemma (decode_int32le b1 == decode_int32le b2 ==> b1 == b2)
let decode_int32le_injective (b1: bytes{Seq.length b1 == 4}) (b2: bytes{Seq.length b2 == 4})
: Lemma (decode_int32le b1 == decode_int32le b2 ==> b1 == b2) = | false | null | true | if (decode_int32le b1) = (decode_int32le b2)
then
(lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2) | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.op_Equality",
"FStar.UInt32.t",
"Prims.l_or",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.Spec.Int32le.decode_int32le",
"FStar.Endianness.le_to_n_inj",
"Prims.unit",
"Prims._assert",
"Prims.nat",
"FStar.Endianness.le_to_n",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.UInt32.uint_to_t",
"FStar.Endianness.lemma_le_to_n_is_bounded",
"Prims.bool",
"Prims.l_True",
"Prims.squash",
"Prims.l_imp",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==> | false | false | LowParse.Spec.Int32le.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 decode_int32le_injective (b1: bytes{Seq.length b1 == 4}) (b2: bytes{Seq.length b2 == 4})
: Lemma (decode_int32le b1 == decode_int32le b2 ==> b1 == b2) | [] | LowParse.Spec.Int32le.decode_int32le_injective | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
b1: LowParse.Bytes.bytes{FStar.Seq.Base.length b1 == 4} ->
b2: LowParse.Bytes.bytes{FStar.Seq.Base.length b2 == 4}
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Int32le.decode_int32le b1 == LowParse.Spec.Int32le.decode_int32le b2 ==>
b1 == b2) | {
"end_col": 6,
"end_line": 46,
"start_col": 2,
"start_line": 36
} |
FStar.Pervasives.Lemma | val le_to_n_1_eq (b: bytes{Seq.length b == 1}) : Lemma (le_to_n b == U8.v (Seq.index b 0)) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 le_to_n_1_eq
(b : bytes { Seq.length b == 1 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_0_eq (Seq.tail b) | val le_to_n_1_eq (b: bytes{Seq.length b == 1}) : Lemma (le_to_n b == U8.v (Seq.index b 0))
let le_to_n_1_eq (b: bytes{Seq.length b == 1}) : Lemma (le_to_n b == U8.v (Seq.index b 0)) = | false | null | true | assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_0_eq (Seq.tail b) | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Int32le.le_to_n_0_eq",
"FStar.Seq.Properties.tail",
"Prims.unit",
"FStar.Endianness.reveal_le_to_n",
"FStar.Pervasives.assert_norm",
"Prims.pow2",
"Prims.l_True",
"Prims.squash",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.Endianness.le_to_n",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective
let parse_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le
let serialize_int32le : serializer parse_int32le
= fun (x : U32.t) -> n_to_le 4 (U32.v x)
(* lemmas for inplace comparison in validators *)
let le_to_n_0_eq
(b : bytes { Seq.length b == 0 } )
: Lemma (le_to_n b == 0)
= reveal_le_to_n b
let le_to_n_1_eq
(b : bytes { Seq.length b == 1 } )
: Lemma (le_to_n b == | false | false | LowParse.Spec.Int32le.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 le_to_n_1_eq (b: bytes{Seq.length b == 1}) : Lemma (le_to_n b == U8.v (Seq.index b 0)) | [] | LowParse.Spec.Int32le.le_to_n_1_eq | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == 1}
-> FStar.Pervasives.Lemma
(ensures FStar.Endianness.le_to_n b == FStar.UInt8.v (FStar.Seq.Base.index b 0)) | {
"end_col": 27,
"end_line": 71,
"start_col": 2,
"start_line": 69
} |
FStar.Pervasives.Lemma | val decode_int32le_eq (b: bytes{Seq.length b == 4})
: Lemma
(U32.v (decode_int32le b) ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3))))) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 decode_int32le_eq
(b : bytes { Seq.length b == 4 } )
: Lemma
(U32.v (decode_int32le b) ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3)))))
= lemma_le_to_n_is_bounded b;
assert (U32.v (decode_int32le b) == le_to_n b);
le_to_n_4_eq b | val decode_int32le_eq (b: bytes{Seq.length b == 4})
: Lemma
(U32.v (decode_int32le b) ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3)))))
let decode_int32le_eq (b: bytes{Seq.length b == 4})
: Lemma
(U32.v (decode_int32le b) ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3))))) = | false | null | true | lemma_le_to_n_is_bounded b;
assert (U32.v (decode_int32le b) == le_to_n b);
le_to_n_4_eq b | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Int32le.le_to_n_4_eq",
"Prims.unit",
"Prims._assert",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"LowParse.Spec.Int32le.decode_int32le",
"FStar.Endianness.le_to_n",
"FStar.Endianness.lemma_le_to_n_is_bounded",
"Prims.l_True",
"Prims.squash",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"FStar.Mul.op_Star",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective
let parse_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le
let serialize_int32le : serializer parse_int32le
= fun (x : U32.t) -> n_to_le 4 (U32.v x)
(* lemmas for inplace comparison in validators *)
let le_to_n_0_eq
(b : bytes { Seq.length b == 0 } )
: Lemma (le_to_n b == 0)
= reveal_le_to_n b
let le_to_n_1_eq
(b : bytes { Seq.length b == 1 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_0_eq (Seq.tail b)
let le_to_n_2_eq
(b : bytes { Seq.length b == 2 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1)))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_1_eq (Seq.tail b)
let le_to_n_3_eq
(b : bytes { Seq.length b == 3 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2))))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_2_eq (Seq.tail b)
let le_to_n_4_eq
(b : bytes { Seq.length b == 4 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3)))))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_3_eq (Seq.tail b)
let decode_int32le_eq
(b : bytes { Seq.length b == 4 } )
: Lemma
(U32.v (decode_int32le b) ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2) + | false | false | LowParse.Spec.Int32le.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 decode_int32le_eq (b: bytes{Seq.length b == 4})
: Lemma
(U32.v (decode_int32le b) ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3))))) | [] | LowParse.Spec.Int32le.decode_int32le_eq | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == 4}
-> FStar.Pervasives.Lemma
(ensures
FStar.UInt32.v (LowParse.Spec.Int32le.decode_int32le b) ==
FStar.UInt8.v (FStar.Seq.Base.index b 0) +
256 *
(FStar.UInt8.v (FStar.Seq.Base.index b 1) +
256 *
(FStar.UInt8.v (FStar.Seq.Base.index b 2) + 256 * FStar.UInt8.v (FStar.Seq.Base.index b 3)))
) | {
"end_col": 16,
"end_line": 113,
"start_col": 2,
"start_line": 111
} |
FStar.Pervasives.Lemma | val le_to_n_3_eq (b: bytes{Seq.length b == 3})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2)))) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 le_to_n_3_eq
(b : bytes { Seq.length b == 3 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2))))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_2_eq (Seq.tail b) | val le_to_n_3_eq (b: bytes{Seq.length b == 3})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2))))
let le_to_n_3_eq (b: bytes{Seq.length b == 3})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2)))) = | false | null | true | assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_2_eq (Seq.tail b) | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Int32le.le_to_n_2_eq",
"FStar.Seq.Properties.tail",
"Prims.unit",
"FStar.Endianness.reveal_le_to_n",
"FStar.Pervasives.assert_norm",
"Prims.pow2",
"Prims.l_True",
"Prims.squash",
"FStar.Endianness.le_to_n",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"FStar.Mul.op_Star",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective
let parse_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le
let serialize_int32le : serializer parse_int32le
= fun (x : U32.t) -> n_to_le 4 (U32.v x)
(* lemmas for inplace comparison in validators *)
let le_to_n_0_eq
(b : bytes { Seq.length b == 0 } )
: Lemma (le_to_n b == 0)
= reveal_le_to_n b
let le_to_n_1_eq
(b : bytes { Seq.length b == 1 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_0_eq (Seq.tail b)
let le_to_n_2_eq
(b : bytes { Seq.length b == 2 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1)))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_1_eq (Seq.tail b)
let le_to_n_3_eq
(b : bytes { Seq.length b == 3 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) + | false | false | LowParse.Spec.Int32le.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 le_to_n_3_eq (b: bytes{Seq.length b == 3})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2)))) | [] | LowParse.Spec.Int32le.le_to_n_3_eq | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == 3}
-> FStar.Pervasives.Lemma
(ensures
FStar.Endianness.le_to_n b ==
FStar.UInt8.v (FStar.Seq.Base.index b 0) +
256 *
(FStar.UInt8.v (FStar.Seq.Base.index b 1) + 256 * FStar.UInt8.v (FStar.Seq.Base.index b 2))) | {
"end_col": 27,
"end_line": 90,
"start_col": 2,
"start_line": 88
} |
FStar.Pervasives.Lemma | val le_to_n_2_eq (b: bytes{Seq.length b == 2})
: Lemma (le_to_n b == U8.v (Seq.index b 0) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1))) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 le_to_n_2_eq
(b : bytes { Seq.length b == 2 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1)))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_1_eq (Seq.tail b) | val le_to_n_2_eq (b: bytes{Seq.length b == 2})
: Lemma (le_to_n b == U8.v (Seq.index b 0) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1)))
let le_to_n_2_eq (b: bytes{Seq.length b == 2})
: Lemma (le_to_n b == U8.v (Seq.index b 0) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1))) = | false | null | true | assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_1_eq (Seq.tail b) | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Int32le.le_to_n_1_eq",
"FStar.Seq.Properties.tail",
"Prims.unit",
"FStar.Endianness.reveal_le_to_n",
"FStar.Pervasives.assert_norm",
"Prims.pow2",
"Prims.l_True",
"Prims.squash",
"FStar.Endianness.le_to_n",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"FStar.Mul.op_Star",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective
let parse_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le
let serialize_int32le : serializer parse_int32le
= fun (x : U32.t) -> n_to_le 4 (U32.v x)
(* lemmas for inplace comparison in validators *)
let le_to_n_0_eq
(b : bytes { Seq.length b == 0 } )
: Lemma (le_to_n b == 0)
= reveal_le_to_n b
let le_to_n_1_eq
(b : bytes { Seq.length b == 1 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_0_eq (Seq.tail b)
let le_to_n_2_eq
(b : bytes { Seq.length b == 2 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) + | false | false | LowParse.Spec.Int32le.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 le_to_n_2_eq (b: bytes{Seq.length b == 2})
: Lemma (le_to_n b == U8.v (Seq.index b 0) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1))) | [] | LowParse.Spec.Int32le.le_to_n_2_eq | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == 2}
-> FStar.Pervasives.Lemma
(ensures
FStar.Endianness.le_to_n b ==
FStar.UInt8.v (FStar.Seq.Base.index b 0) + 256 * FStar.UInt8.v (FStar.Seq.Base.index b 1)) | {
"end_col": 27,
"end_line": 80,
"start_col": 2,
"start_line": 78
} |
FStar.Pervasives.Lemma | val le_to_n_4_eq (b: bytes{Seq.length b == 4})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3))))) | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"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 le_to_n_4_eq
(b : bytes { Seq.length b == 4 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3)))))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_3_eq (Seq.tail b) | val le_to_n_4_eq (b: bytes{Seq.length b == 4})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3)))))
let le_to_n_4_eq (b: bytes{Seq.length b == 4})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3))))) = | false | null | true | assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_3_eq (Seq.tail b) | {
"checked_file": "LowParse.Spec.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Int32le.fst"
} | [
"lemma"
] | [
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Int32le.le_to_n_3_eq",
"FStar.Seq.Properties.tail",
"Prims.unit",
"FStar.Endianness.reveal_le_to_n",
"FStar.Pervasives.assert_norm",
"Prims.pow2",
"Prims.l_True",
"Prims.squash",
"FStar.Endianness.le_to_n",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"FStar.Mul.op_Star",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Int32le
(* LowParse specification module for parsing unconstrainted 32 bits = 4 bytes unsigned little endian integers
Examples:
uint32le foo
*)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let decode_int32le
(b: bytes { Seq.length b == 4 } )
: Tot (v: U32.t { 0 <= U32.v v /\ U32.v v < 4294967296 } )
= lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 32;
let res = le_to_n b in
assert (0 <= res /\ res < 4294967296);
U32.uint_to_t res
let decode_int32le_injective
(b1 : bytes { Seq.length b1 == 4 } )
(b2 : bytes { Seq.length b2 == 4 } )
: Lemma (decode_int32le b1 == decode_int32le b2
==>
b1 == b2)
= if (decode_int32le b1) = (decode_int32le b2) then
begin
lemma_le_to_n_is_bounded b1;
lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (le_to_n b1)) == le_to_n b1);
assert (U32.v (U32.uint_to_t (le_to_n b2)) == le_to_n b2);
assert (le_to_n b1 == le_to_n b2);
le_to_n_inj b1 b2
end
else
()
let decode_int32le_total_constant () : Lemma (make_total_constant_size_parser_precond 4 U32.t decode_int32le)
= Classical.forall_intro_2 decode_int32le_injective
let parse_int32le : parser (total_constant_size_parser_kind 4) U32.t
= decode_int32le_total_constant () ;
make_total_constant_size_parser 4 U32.t decode_int32le
let serialize_int32le : serializer parse_int32le
= fun (x : U32.t) -> n_to_le 4 (U32.v x)
(* lemmas for inplace comparison in validators *)
let le_to_n_0_eq
(b : bytes { Seq.length b == 0 } )
: Lemma (le_to_n b == 0)
= reveal_le_to_n b
let le_to_n_1_eq
(b : bytes { Seq.length b == 1 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_0_eq (Seq.tail b)
let le_to_n_2_eq
(b : bytes { Seq.length b == 2 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1)))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_1_eq (Seq.tail b)
let le_to_n_3_eq
(b : bytes { Seq.length b == 3 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2))))
= assert_norm (pow2 8 == 256);
reveal_le_to_n b;
le_to_n_2_eq (Seq.tail b)
let le_to_n_4_eq
(b : bytes { Seq.length b == 4 } )
: Lemma (le_to_n b ==
U8.v (Seq.index b 0) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 1) +
256 `FStar.Mul.op_Star` (U8.v (Seq.index b 2) + | false | false | LowParse.Spec.Int32le.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 le_to_n_4_eq (b: bytes{Seq.length b == 4})
: Lemma
(le_to_n b ==
U8.v (Seq.index b 0) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 1) +
256
`FStar.Mul.op_Star`
(U8.v (Seq.index b 2) + 256 `FStar.Mul.op_Star` (U8.v (Seq.index b 3))))) | [] | LowParse.Spec.Int32le.le_to_n_4_eq | {
"file_name": "src/lowparse/LowParse.Spec.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == 4}
-> FStar.Pervasives.Lemma
(ensures
FStar.Endianness.le_to_n b ==
FStar.UInt8.v (FStar.Seq.Base.index b 0) +
256 *
(FStar.UInt8.v (FStar.Seq.Base.index b 1) +
256 *
(FStar.UInt8.v (FStar.Seq.Base.index b 2) + 256 * FStar.UInt8.v (FStar.Seq.Base.index b 3)))
) | {
"end_col": 27,
"end_line": 101,
"start_col": 2,
"start_line": 99
} |
Prims.Tot | val buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) =
s | val buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a)
let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) = | false | null | false | s | {
"checked_file": "LowParse.Slice.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Slice.fst"
} | [
"total"
] | [
"LowParse.Slice.srel",
"LowStar.Monotonic.Buffer.srel"
] | [] | module LowParse.Slice
open LowParse.Bytes
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
inline_for_extraction
noextract
type srel (a: Type) = (B.srel a)
inline_for_extraction
noextract | false | false | LowParse.Slice.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 buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) | [] | LowParse.Slice.buffer_srel_of_srel | {
"file_name": "src/lowparse/LowParse.Slice.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: LowParse.Slice.srel a -> LowStar.Monotonic.Buffer.srel a | {
"end_col": 3,
"end_line": 15,
"start_col": 2,
"start_line": 15
} |
Prims.Tot | val srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) =
s | val srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a)
let srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) = | false | null | false | s | {
"checked_file": "LowParse.Slice.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Slice.fst"
} | [
"total"
] | [
"LowStar.Monotonic.Buffer.srel",
"LowParse.Slice.srel"
] | [] | module LowParse.Slice
open LowParse.Bytes
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
inline_for_extraction
noextract
type srel (a: Type) = (B.srel a)
inline_for_extraction
noextract
let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) =
s
inline_for_extraction
noextract | false | false | LowParse.Slice.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 srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) | [] | LowParse.Slice.srel_of_buffer_srel | {
"file_name": "src/lowparse/LowParse.Slice.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: LowStar.Monotonic.Buffer.srel a -> LowParse.Slice.srel a | {
"end_col": 3,
"end_line": 20,
"start_col": 2,
"start_line": 20
} |
Prims.GTot | val live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0 = B.live h s.base | val live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0
let live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0 = | false | null | false | B.live h s.base | {
"checked_file": "LowParse.Slice.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Slice.fst"
} | [
"sometrivial"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.slice",
"LowStar.Monotonic.Buffer.live",
"LowParse.Slice.buffer_srel_of_srel",
"LowParse.Slice.__proj__Mkslice__item__base"
] | [] | module LowParse.Slice
open LowParse.Bytes
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
inline_for_extraction
noextract
type srel (a: Type) = (B.srel a)
inline_for_extraction
noextract
let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) =
s
inline_for_extraction
noextract
let srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) =
s
let buffer_srel_of_srel_of_buffer_srel (#a: Type) (s: B.srel a) : Lemma
(buffer_srel_of_srel (srel_of_buffer_srel s) == s)
[SMTPat (buffer_srel_of_srel (srel_of_buffer_srel s))]
= ()
noeq
inline_for_extraction
type slice (rrel rel: srel byte) = {
base: B.mbuffer byte (buffer_srel_of_srel rrel) (buffer_srel_of_srel rel);
len: (len: U32.t { U32.v len <= B.length base } );
}
inline_for_extraction
noextract
let make_slice
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(len: U32.t { U32.v len <= B.length b } )
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel))
= {
base = b;
len = len;
} | false | false | LowParse.Slice.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 live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0 | [] | LowParse.Slice.live_slice | {
"file_name": "src/lowparse/LowParse.Slice.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | h: FStar.Monotonic.HyperStack.mem -> s: LowParse.Slice.slice rrel rel -> Prims.GTot Type0 | {
"end_col": 94,
"end_line": 46,
"start_col": 79,
"start_line": 46
} |
Prims.GTot | val loc_slice_from (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : GTot B.loc | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_slice_from (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : GTot B.loc =
loc_slice_from_to s pos s.len | val loc_slice_from (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : GTot B.loc
let loc_slice_from (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : GTot B.loc = | false | null | false | loc_slice_from_to s pos s.len | {
"checked_file": "LowParse.Slice.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Slice.fst"
} | [
"sometrivial"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Slice.loc_slice_from_to",
"LowParse.Slice.__proj__Mkslice__item__len",
"LowStar.Monotonic.Buffer.loc"
] | [] | module LowParse.Slice
open LowParse.Bytes
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
inline_for_extraction
noextract
type srel (a: Type) = (B.srel a)
inline_for_extraction
noextract
let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) =
s
inline_for_extraction
noextract
let srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) =
s
let buffer_srel_of_srel_of_buffer_srel (#a: Type) (s: B.srel a) : Lemma
(buffer_srel_of_srel (srel_of_buffer_srel s) == s)
[SMTPat (buffer_srel_of_srel (srel_of_buffer_srel s))]
= ()
noeq
inline_for_extraction
type slice (rrel rel: srel byte) = {
base: B.mbuffer byte (buffer_srel_of_srel rrel) (buffer_srel_of_srel rel);
len: (len: U32.t { U32.v len <= B.length base } );
}
inline_for_extraction
noextract
let make_slice
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(len: U32.t { U32.v len <= B.length b } )
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel))
= {
base = b;
len = len;
}
let live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0 = B.live h s.base
let bytes_of_slice_from (#rrel #rel: _)
(h: HS.mem) (s: slice rrel rel) (pos: U32.t) : GTot bytes =
if (U32.v pos <= U32.v s.len)
then Seq.slice (B.as_seq h s.base) (U32.v pos) (U32.v s.len)
else Seq.empty
let loc_slice_from_to (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : GTot B.loc =
B.loc_buffer_from_to s.base pos pos' | false | false | LowParse.Slice.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 loc_slice_from (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : GTot B.loc | [] | LowParse.Slice.loc_slice_from | {
"file_name": "src/lowparse/LowParse.Slice.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 31,
"end_line": 58,
"start_col": 2,
"start_line": 58
} |
Prims.GTot | val loc_slice_from_to (#rrel #rel: _) (s: slice rrel rel) (pos pos': U32.t) : GTot B.loc | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_slice_from_to (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : GTot B.loc =
B.loc_buffer_from_to s.base pos pos' | val loc_slice_from_to (#rrel #rel: _) (s: slice rrel rel) (pos pos': U32.t) : GTot B.loc
let loc_slice_from_to (#rrel #rel: _) (s: slice rrel rel) (pos pos': U32.t) : GTot B.loc = | false | null | false | B.loc_buffer_from_to s.base pos pos' | {
"checked_file": "LowParse.Slice.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Slice.fst"
} | [
"sometrivial"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.loc_buffer_from_to",
"LowParse.Slice.buffer_srel_of_srel",
"LowParse.Slice.__proj__Mkslice__item__base",
"LowStar.Monotonic.Buffer.loc"
] | [] | module LowParse.Slice
open LowParse.Bytes
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
inline_for_extraction
noextract
type srel (a: Type) = (B.srel a)
inline_for_extraction
noextract
let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) =
s
inline_for_extraction
noextract
let srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) =
s
let buffer_srel_of_srel_of_buffer_srel (#a: Type) (s: B.srel a) : Lemma
(buffer_srel_of_srel (srel_of_buffer_srel s) == s)
[SMTPat (buffer_srel_of_srel (srel_of_buffer_srel s))]
= ()
noeq
inline_for_extraction
type slice (rrel rel: srel byte) = {
base: B.mbuffer byte (buffer_srel_of_srel rrel) (buffer_srel_of_srel rel);
len: (len: U32.t { U32.v len <= B.length base } );
}
inline_for_extraction
noextract
let make_slice
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(len: U32.t { U32.v len <= B.length b } )
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel))
= {
base = b;
len = len;
}
let live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0 = B.live h s.base
let bytes_of_slice_from (#rrel #rel: _)
(h: HS.mem) (s: slice rrel rel) (pos: U32.t) : GTot bytes =
if (U32.v pos <= U32.v s.len)
then Seq.slice (B.as_seq h s.base) (U32.v pos) (U32.v s.len)
else Seq.empty | false | false | LowParse.Slice.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 loc_slice_from_to (#rrel #rel: _) (s: slice rrel rel) (pos pos': U32.t) : GTot B.loc | [] | LowParse.Slice.loc_slice_from_to | {
"file_name": "src/lowparse/LowParse.Slice.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> pos': FStar.UInt32.t
-> Prims.GTot LowStar.Monotonic.Buffer.loc | {
"end_col": 38,
"end_line": 55,
"start_col": 2,
"start_line": 55
} |
Prims.Tot | val make_slice (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (len: U32.t{U32.v len <= B.length b})
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel)) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_slice
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(len: U32.t { U32.v len <= B.length b } )
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel))
= {
base = b;
len = len;
} | val make_slice (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (len: U32.t{U32.v len <= B.length b})
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel))
let make_slice (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (len: U32.t{U32.v len <= B.length b})
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel)) = | false | null | false | { base = b; len = len } | {
"checked_file": "LowParse.Slice.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Slice.fst"
} | [
"total"
] | [
"LowStar.Monotonic.Buffer.srel",
"LowParse.Bytes.byte",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowStar.Monotonic.Buffer.length",
"LowParse.Slice.Mkslice",
"LowParse.Slice.srel_of_buffer_srel",
"LowParse.Slice.slice"
] | [] | module LowParse.Slice
open LowParse.Bytes
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
inline_for_extraction
noextract
type srel (a: Type) = (B.srel a)
inline_for_extraction
noextract
let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) =
s
inline_for_extraction
noextract
let srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) =
s
let buffer_srel_of_srel_of_buffer_srel (#a: Type) (s: B.srel a) : Lemma
(buffer_srel_of_srel (srel_of_buffer_srel s) == s)
[SMTPat (buffer_srel_of_srel (srel_of_buffer_srel s))]
= ()
noeq
inline_for_extraction
type slice (rrel rel: srel byte) = {
base: B.mbuffer byte (buffer_srel_of_srel rrel) (buffer_srel_of_srel rel);
len: (len: U32.t { U32.v len <= B.length base } );
}
inline_for_extraction
noextract
let make_slice
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(len: U32.t { U32.v len <= B.length b } )
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel)) | false | false | LowParse.Slice.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_slice (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (len: U32.t{U32.v len <= B.length b})
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel)) | [] | LowParse.Slice.make_slice | {
"file_name": "src/lowparse/LowParse.Slice.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
b: LowStar.Monotonic.Buffer.mbuffer LowParse.Bytes.byte rrel rel ->
len: FStar.UInt32.t{FStar.UInt32.v len <= LowStar.Monotonic.Buffer.length b}
-> LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel rrel)
(LowParse.Slice.srel_of_buffer_srel rel) | {
"end_col": 12,
"end_line": 43,
"start_col": 2,
"start_line": 42
} |
Prims.GTot | val bytes_of_slice_from (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) (pos: U32.t) : GTot bytes | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bytes_of_slice_from (#rrel #rel: _)
(h: HS.mem) (s: slice rrel rel) (pos: U32.t) : GTot bytes =
if (U32.v pos <= U32.v s.len)
then Seq.slice (B.as_seq h s.base) (U32.v pos) (U32.v s.len)
else Seq.empty | val bytes_of_slice_from (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) (pos: U32.t) : GTot bytes
let bytes_of_slice_from (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) (pos: U32.t) : GTot bytes = | false | null | false | if (U32.v pos <= U32.v s.len)
then Seq.slice (B.as_seq h s.base) (U32.v pos) (U32.v s.len)
else Seq.empty | {
"checked_file": "LowParse.Slice.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Bytes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Slice.fst"
} | [
"sometrivial"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq",
"LowParse.Slice.buffer_srel_of_srel",
"LowParse.Slice.__proj__Mkslice__item__base",
"Prims.bool",
"FStar.Seq.Base.empty",
"LowParse.Bytes.bytes"
] | [] | module LowParse.Slice
open LowParse.Bytes
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
inline_for_extraction
noextract
type srel (a: Type) = (B.srel a)
inline_for_extraction
noextract
let buffer_srel_of_srel (#a: Type) (s: srel a) : Tot (B.srel a) =
s
inline_for_extraction
noextract
let srel_of_buffer_srel (#a: Type) (s: B.srel a) : Tot (srel a) =
s
let buffer_srel_of_srel_of_buffer_srel (#a: Type) (s: B.srel a) : Lemma
(buffer_srel_of_srel (srel_of_buffer_srel s) == s)
[SMTPat (buffer_srel_of_srel (srel_of_buffer_srel s))]
= ()
noeq
inline_for_extraction
type slice (rrel rel: srel byte) = {
base: B.mbuffer byte (buffer_srel_of_srel rrel) (buffer_srel_of_srel rel);
len: (len: U32.t { U32.v len <= B.length base } );
}
inline_for_extraction
noextract
let make_slice
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(len: U32.t { U32.v len <= B.length b } )
: Tot (slice (srel_of_buffer_srel rrel) (srel_of_buffer_srel rel))
= {
base = b;
len = len;
}
let live_slice (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) : GTot Type0 = B.live h s.base
let bytes_of_slice_from (#rrel #rel: _) | false | false | LowParse.Slice.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 bytes_of_slice_from (#rrel #rel: _) (h: HS.mem) (s: slice rrel rel) (pos: U32.t) : GTot bytes | [] | LowParse.Slice.bytes_of_slice_from | {
"file_name": "src/lowparse/LowParse.Slice.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | h: FStar.Monotonic.HyperStack.mem -> s: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t
-> Prims.GTot LowParse.Bytes.bytes | {
"end_col": 16,
"end_line": 52,
"start_col": 2,
"start_line": 50
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.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 = lbuffer uint64 (size 4) | let felem = | false | null | false | lbuffer uint64 (size 4) | {
"checked_file": "Hacl.Impl.P256.Bignum.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Bignum.fsti"
} | [
"total"
] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"Lib.IntTypes.size"
] | [] | module Hacl.Impl.P256.Bignum
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module BD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Impl.P256.Bignum.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 : Type0 | [] | Hacl.Impl.P256.Bignum.felem | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Bignum.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 35,
"end_line": 18,
"start_col": 12,
"start_line": 18
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.