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 valid_ocmp (c: ocmp) (s: state) : bool | [
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_ocmp (c:ocmp) (s:state) : bool =
match c with
| OEq o1 _ -> valid_first_cmp_opr o1
| ONe o1 _ -> valid_first_cmp_opr o1
| OLe o1 _ -> valid_first_cmp_opr o1
| OGe o1 _ -> valid_first_cmp_opr o1
| OLt o1 _ -> valid_first_cmp_opr o1
| OGt o1 _ -> valid_first_cmp_opr o1 | val valid_ocmp (c: ocmp) (s: state) : bool
let valid_ocmp (c: ocmp) (s: state) : bool = | false | null | false | match c with
| OEq o1 _ -> valid_first_cmp_opr o1
| ONe o1 _ -> valid_first_cmp_opr o1
| OLe o1 _ -> valid_first_cmp_opr o1
| OGe o1 _ -> valid_first_cmp_opr o1
| OLt o1 _ -> valid_first_cmp_opr o1
| OGt o1 _ -> valid_first_cmp_opr o1 | {
"checked_file": "Vale.PPC64LE.Semantics_s.fst.checked",
"dependencies": [
"Vale.SHA2.Wrapper.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Semantics_s.fst"
} | [
"total"
] | [
"Vale.PPC64LE.Semantics_s.ocmp",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Machine_s.cmp_opr",
"Vale.PPC64LE.Machine_s.valid_first_cmp_opr",
"Prims.bool"
] | [] | module Vale.PPC64LE.Semantics_s
open FStar.Mul
open FStar.Seq.Base
open Vale.PPC64LE.Machine_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.Arch.Types
open Vale.Def.Sel
open Vale.SHA2.Wrapper
let (.[]) = Map.sel
let (.[]<-) = Map.upd
type ins =
| Move : dst:reg -> src:reg -> ins
| Load64 : dst:reg -> base:reg -> offset:int -> ins
| Store64 : src:reg -> base:reg -> offset:int -> ins
| LoadImm64 : dst:reg -> src:simm16 -> ins
| LoadImmShl64 : dst:reg -> src:simm16 -> ins
| AddLa : dst:reg -> src1:reg -> src2:simm16 -> ins
| Add : dst:reg -> src1:reg -> src2:reg -> ins
| AddImm : dst:reg -> src1:reg -> src2:simm16 -> ins
| AddCarry : dst:reg -> src1:reg -> src2:reg -> ins
| AddExtended : dst:reg -> src1:reg -> src2:reg -> ins
| AddExtendedOV: dst:reg -> src1:reg -> src2:reg -> ins
| Sub : dst:reg -> src1:reg -> src2:reg -> ins
| SubImm : dst:reg -> src1:reg -> src2:nsimm16 -> ins
| MulLow64 : dst:reg -> src1:reg -> src2:reg -> ins
| MulHigh64U : dst:reg -> src1:reg -> src2:reg -> ins
| Xor : dst:reg -> src1:reg -> src2:reg -> ins
| And : dst:reg -> src1:reg -> src2:reg -> ins
| Sr64Imm : dst:reg -> src1:reg -> src2:bits64 -> ins
| Sl64Imm : dst:reg -> src1:reg -> src2:bits64 -> ins
| Sr64 : dst:reg -> src1:reg -> src2:reg -> ins
| Sl64 : dst:reg -> src1:reg -> src2:reg -> ins
| Vmr : dst:vec -> src:vec -> ins
| Mfvsrd : dst:reg -> src:vec -> ins
| Mfvsrld : dst:reg -> src:vec -> ins
| Mtvsrdd : dst:vec -> src1:reg -> src2:reg -> ins
| Mtvsrws : dst:vec -> src:reg -> ins
| Vadduwm : dst:vec -> src1:vec -> src2:vec -> ins
| Vxor : dst:vec -> src1:vec -> src2:vec -> ins
| Vand : dst:vec -> src1:vec -> src2:vec -> ins
| Vslw : dst:vec -> src1:vec -> src2:vec -> ins
| Vsrw : dst:vec -> src1:vec -> src2:vec -> ins
| Vsl : dst:vec -> src1:vec -> src2:vec -> ins
| Vcmpequw : dst:vec -> src1:vec -> src2:vec -> ins
| Vsldoi : dst:vec -> src1:vec -> src2:vec -> count:quad32bytes -> ins
| Vmrghw : dst:vec -> src1:vec -> src2:vec -> ins
| Xxmrghd : dst:vec -> src1:vec -> src2:vec -> ins
| Vsel : dst:vec -> src1:vec -> src2:vec -> sel:vec -> ins
| Vspltw : dst:vec -> src:vec -> uim:nat2 -> ins
| Vspltisw : dst:vec -> src:sim -> ins
| Vspltisb : dst:vec -> src:sim -> ins
| Load128 : dst:vec -> base:reg -> offset:reg -> ins
| Store128 : src:vec -> base:reg -> offset:reg -> ins
| Load128Word4 : dst:vec -> base:reg -> ins
| Load128Word4Index : dst:vec -> base:reg -> offset:reg -> ins
| Store128Word4: src:vec -> base:reg -> ins
| Store128Word4Index: src:vec -> base:reg -> offset:reg -> ins
| Load128Byte16: dst:vec -> base:reg -> ins
| Load128Byte16Index: dst:vec -> base:reg -> offset:reg -> ins
| Store128Byte16: src:vec -> base:reg -> ins
| Store128Byte16Index: src:vec -> base:reg -> offset:reg -> ins
| Vshasigmaw0 : dst:vec -> src:vec -> ins
| Vshasigmaw1 : dst:vec -> src:vec -> ins
| Vshasigmaw2 : dst:vec -> src:vec -> ins
| Vshasigmaw3 : dst:vec -> src:vec -> ins
| Vsbox : dst:vec -> src:vec -> ins
| RotWord : dst:vec -> src1:vec -> src2:vec -> ins
| Vcipher : dst:vec -> src1:vec -> src2:vec -> ins
| Vcipherlast : dst:vec -> src1:vec -> src2:vec -> ins
| Vncipher : dst:vec -> src1:vec -> src2:vec -> ins
| Vncipherlast : dst:vec -> src1:vec -> src2:vec -> ins
| Vpmsumd : dst:vec -> src1:vec -> src2:vec -> ins
| Alloc : n:nat64 -> ins
| Dealloc : n:nat64 -> ins
| StoreStack128: src:vec -> t:taint -> offset:int -> ins
| LoadStack128 : dst:vec -> t:taint -> offset:int -> ins
| StoreStack64 : src:reg -> t:taint -> offset:int -> ins
| LoadStack64 : dst:reg -> t:taint -> offset:int -> ins
| Ghost : (_:unit) -> ins
type ocmp =
| OEq: o1:cmp_opr -> o2:cmp_opr -> ocmp
| ONe: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OLe: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OGe: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OLt: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OGt: o1:cmp_opr -> o2:cmp_opr -> ocmp
type code = precode ins ocmp
type codes = list code
unfold let eval_reg (r:reg) (s:state) : nat64 = s.regs r
unfold let eval_vec (v:vec) (s:state) : quad32 = s.vecs v
unfold let eval_mem (ptr:int) (s:state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:state) (t:taint) : state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let update_mem (ptr:int) (v:nat64) (s:state) : state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(heap_taint s.ms_heap)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128 (ptr:int) (v:quad32) (s:state) : state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(heap_taint s.ms_heap)
}
else s
let update_mem128_and_taint (ptr:int) (v:quad32) (s:state) (t:taint) : state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_r1 mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_r1 mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_r1 mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_r1 mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:state) (t:taint) : state =
let Machine_stack init_r1 mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:state) (t:taint) : state =
let Machine_stack init_r1 mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
valid_addr128 ptr mem
unfold
let valid_src_stack64_and_taint (ptr:int) (s:state) (t:taint) : bool =
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
unfold
let valid_src_stack128_and_taint (ptr:int) (s:state) (t:taint) : bool =
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_src_stack (r:reg) (s:state) : bool =
valid_src_stack64 (eval_reg r s) s.ms_stack
[@va_qattr]
let eval_maddr (m:maddr) (s:state) : int =
eval_reg m.address s + m.offset
let eval_cmp_opr (o:cmp_opr) (s:state) : nat64 =
match o with
| CReg r -> eval_reg r s
| CImm n -> int_to_nat64 n
let eval_ocmp (s:state) (c:ocmp) :bool =
match c with
| OEq o1 o2 -> eval_cmp_opr o1 s = eval_cmp_opr o2 s
| ONe o1 o2 -> eval_cmp_opr o1 s <> eval_cmp_opr o2 s
| OLe o1 o2 -> eval_cmp_opr o1 s <= eval_cmp_opr o2 s
| OGe o1 o2 -> eval_cmp_opr o1 s >= eval_cmp_opr o2 s
| OLt o1 o2 -> eval_cmp_opr o1 s < eval_cmp_opr o2 s
| OGt o1 o2 -> eval_cmp_opr o1 s > eval_cmp_opr o2 s
let eval_cmp_cr0 (s:state) (c:ocmp) : cr0_t =
match c with
| OEq o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| ONe o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OLe o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OGe o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OLt o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OGt o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
unfold
let valid_dst_stack64 (r1:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= r1 && ptr + 8 <= init_r1
unfold
let valid_dst_stack128 (r1:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= r1 && ptr + 16 <= init_r1
let valid_dst_stack64_addr (m:maddr) (s:state) : bool =
valid_dst_stack64 (eval_reg 1 s) (eval_maddr m s) s.ms_stack
let valid_dst_stack128_addr (m:maddr) (s:state) : bool =
valid_dst_stack128 (eval_reg 1 s) (eval_maddr m s) s.ms_stack
let update_reg' (r:reg) (v:nat64) (s:state) : state =
{ s with regs = regs_make (fun (r':reg) -> if r' = r then v else s.regs r') }
let update_vec' (vr:vec) (v:quad32) (s:state) : state =
{ s with vecs = vecs_make (fun (vr':vec) -> if vr' = vr then v else s.vecs vr') }
let update_r1' (new_r1:int) (s:state) : state =
let Machine_stack init_r1 mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_r1 >= init_r1 - 65536 && new_r1 <= init_r1 then
update_reg' 1 new_r1 s
else
s
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_r1 mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_r1 new_mem
let valid_mem (m:maddr) (s:state) : bool =
valid_maddr_offset64 m.offset && valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
let valid_mem64 (r:reg) (i:int) (s:state) : bool =
valid_addr64 (eval_reg r s + i) (heap_get s.ms_heap)
let valid_mem128 (r:reg) (i:reg) (s:state) : bool =
valid_addr128 (eval_reg r s + eval_reg i s) (heap_get s.ms_heap)
let valid_mem128_reg (r:reg) (s:state) : bool =
valid_addr128 (eval_reg r s) (heap_get s.ms_heap)
let valid_mem128' (m:maddr) (s:state) : bool =
valid_maddr_offset128 m.offset && valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
let valid_mem_and_taint (m:maddr) (t:taint) (s:state) : bool =
let ptr = eval_maddr m s in
valid_maddr_offset64 m.offset && valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
let valid_mem128_and_taint (m:maddr) (s:state) (t:taint) : bool =
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | false | true | Vale.PPC64LE.Semantics_s.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 valid_ocmp (c: ocmp) (s: state) : bool | [] | Vale.PPC64LE.Semantics_s.valid_ocmp | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Semantics_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | c: Vale.PPC64LE.Semantics_s.ocmp -> s: Vale.PPC64LE.Machine_s.state -> Prims.bool | {
"end_col": 38,
"end_line": 359,
"start_col": 2,
"start_line": 353
} |
Prims.Tot | val eval_ins (ins: ins) : st unit | [
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let eval_ins (ins:ins) : st unit =
let* s = get in
match ins with
| Move dst src ->
update_reg dst (eval_reg src s)
| Load64 dst base offset ->
check (fun s -> valid_maddr_offset64 offset);*
check (valid_mem64 base offset);*
update_reg dst (eval_mem (eval_reg base s + offset) s)
| Store64 src base offset ->
check (fun s -> valid_maddr_offset64 offset);*
check (valid_mem64 base offset);*
set (update_mem (eval_reg base s + offset) (eval_reg src s) s)
| LoadImm64 dst src ->
update_reg dst (src % pow2_64)
| LoadImmShl64 dst src ->
update_reg dst (ishl64 (src % pow2_64) 16)
| AddLa dst src1 src2 ->
update_reg dst ((eval_reg src1 s + src2) % pow2_64)
| Add dst src1 src2 ->
update_reg dst ((eval_reg src1 s + eval_reg src2 s) % pow2_64)
| AddImm dst src1 src2 ->
update_reg dst ((eval_reg src1 s + int_to_nat64 src2) % pow2_64)
| AddCarry dst src1 src2 ->
let sum = (eval_reg src1 s) + (eval_reg src2 s) in
let new_carry = sum >= pow2_64 in
update_reg dst (sum % pow2_64);*
update_xer (update_xer_ca s.xer new_carry)
| AddExtended dst src1 src2 ->
let old_carry = if xer_ca(s.xer) then 1 else 0 in
let sum = (eval_reg src1 s) + (eval_reg src2 s) + old_carry in
let new_carry = sum >= pow2_64 in
update_reg dst (sum % pow2_64);*
update_xer (update_xer_ca s.xer new_carry)
| AddExtendedOV dst src1 src2 ->
let old_carry = if xer_ov(s.xer) then 1 else 0 in
let sum = (eval_reg src1 s) + (eval_reg src2 s) + old_carry in
let new_carry = sum >= pow2_64 in
update_reg dst (sum % pow2_64);*
update_xer (update_xer_ov s.xer new_carry)
| Sub dst src1 src2 ->
update_reg dst ((eval_reg src1 s - eval_reg src2 s) % pow2_64)
| SubImm dst src1 src2 ->
update_reg dst ((eval_reg src1 s - int_to_nat64 src2) % pow2_64)
| MulLow64 dst src1 src2 ->
update_reg dst ((eval_reg src1 s * eval_reg src2 s) % pow2_64)
| MulHigh64U dst src1 src2 ->
update_reg dst (FStar.UInt.mul_div #64 (eval_reg src1 s) (eval_reg src2 s))
| Xor dst src1 src2 ->
update_reg dst (ixor (eval_reg src1 s) (eval_reg src2 s))
| And dst src1 src2 ->
update_reg dst (iand (eval_reg src1 s) (eval_reg src2 s))
| Sr64Imm dst src1 src2 ->
update_reg dst (ishr (eval_reg src1 s) src2)
| Sl64Imm dst src1 src2 ->
update_reg dst (ishl (eval_reg src1 s) src2)
| Sr64 dst src1 src2 ->
update_reg dst (ishr (eval_reg src1 s) ((eval_reg src2 s) % 64))
| Sl64 dst src1 src2 ->
update_reg dst (ishl (eval_reg src1 s) ((eval_reg src2 s) % 64))
| Vmr dst src ->
update_vec dst (eval_vec src s)
| Mfvsrd dst src ->
let src_q = eval_vec src s in
let src_two = four_to_two_two src_q in
let extracted_nat64 = two_to_nat 32 (two_select src_two 1) in
update_reg dst extracted_nat64
| Mfvsrld dst src ->
let src_q = eval_vec src s in
let src_two = four_to_two_two src_q in
let extracted_nat64 = two_to_nat 32 (two_select src_two 0) in
update_reg dst extracted_nat64
| Mtvsrdd dst src1 src2 ->
let val_src1 = eval_reg src1 s in
let val_src2 = eval_reg src2 s in
update_vec dst (Mkfour
(val_src2 % pow2_32)
(val_src2 / pow2_32)
(val_src1 % pow2_32)
(val_src1 / pow2_32))
| Mtvsrws dst src ->
let val_src = eval_reg src s in
update_vec dst (Mkfour
(val_src % pow2_32)
(val_src % pow2_32)
(val_src % pow2_32)
(val_src % pow2_32))
| Vadduwm dst src1 src2 ->
update_vec dst (add_wrap_quad32 (eval_vec src1 s) (eval_vec src2 s))
| Vxor dst src1 src2 ->
update_vec dst (quad32_xor (eval_vec src1 s) (eval_vec src2 s))
| Vand dst src1 src2 ->
update_vec dst (four_map2 (fun di si -> iand di si) (eval_vec src1 s) (eval_vec src2 s))
| Vslw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst (Mkfour
(ishl src1_q.lo0 (src2_q.lo0 % 32))
(ishl src1_q.lo1 (src2_q.lo1 % 32))
(ishl src1_q.hi2 (src2_q.hi2 % 32))
(ishl src1_q.hi3 (src2_q.hi3 % 32)))
| Vsrw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst (Mkfour
(ishr src1_q.lo0 (src2_q.lo0 % 32))
(ishr src1_q.lo1 (src2_q.lo1 % 32))
(ishr src1_q.hi2 (src2_q.hi2 % 32))
(ishr src1_q.hi3 (src2_q.hi3 % 32)))
| Vsl dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
let sh = (index (nat32_to_be_bytes src2_q.lo0) 3) % 8 in
let chk (v:nat32) (sh:nat8):bool = (let bytes = nat32_to_be_bytes v in
sh = (index bytes 3) % 8 && sh = (index bytes 2) % 8 && sh = (index bytes 1) % 8 && sh = (index bytes 0) % 8) in
check (fun s -> chk src2_q.lo0 sh);*
check (fun s -> chk src2_q.lo1 sh);*
check (fun s -> chk src2_q.hi2 sh);*
check (fun s -> chk src2_q.hi3 sh);*
let l = four_map (fun (i:nat32) -> ishl i sh) src1_q in
let r = four_map (fun (i:nat32) -> ishr i (32 - sh)) src1_q in
let Mkfour r0 r1 r2 r3 = r in
update_vec dst (quad32_xor l (Mkfour 0 r0 r1 r2))
| Vcmpequw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
let eq_val = Mkfour
(eq_result (src1_q.lo0 = src2_q.lo0))
(eq_result (src1_q.lo1 = src2_q.lo1))
(eq_result (src1_q.hi2 = src2_q.hi2))
(eq_result (src1_q.hi3 = src2_q.hi3))
in
update_vec dst eq_val
| Vsldoi dst src1 src2 count ->
check (fun s -> (count = 4 || count = 8 || count = 12));* // We only spec the one very special case we need
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
if count = 4 then update_vec dst (Mkfour src2_q.hi3 src1_q.lo0 src1_q.lo1 src1_q.hi2)
else if count = 8 then update_vec dst (Mkfour src2_q.hi2 src2_q.hi3 src1_q.lo0 src1_q.lo1)
else if count = 12 then update_vec dst (Mkfour src2_q.lo1 src2_q.hi2 src2_q.hi3 src1_q.lo0)
else fail
| Vmrghw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst (Mkfour src2_q.lo1 src1_q.lo1 src2_q.hi3 src1_q.hi3)
| Xxmrghd dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst (Mkfour src2_q.hi2 src2_q.hi3 src1_q.hi2 src1_q.hi3)
| Vsel dst src1 src2 sel ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
let sel_q = eval_vec sel s in
update_vec dst (Mkfour
(isel32 src2_q.lo0 src1_q.lo0 sel_q.lo0)
(isel32 src2_q.lo1 src1_q.lo1 sel_q.lo1)
(isel32 src2_q.hi2 src1_q.hi2 sel_q.hi2)
(isel32 src2_q.hi3 src1_q.hi3 sel_q.hi3))
| Vspltw dst src uim ->
let src_q = eval_vec src s in
if uim = 0 then update_vec dst (Mkfour src_q.hi3 src_q.hi3 src_q.hi3 src_q.hi3)
else if uim = 1 then update_vec dst (Mkfour src_q.hi2 src_q.hi2 src_q.hi2 src_q.hi2)
else if uim = 2 then update_vec dst (Mkfour src_q.lo1 src_q.lo1 src_q.lo1 src_q.lo1)
else update_vec dst (Mkfour src_q.lo0 src_q.lo0 src_q.lo0 src_q.lo0)
| Vspltisw dst src ->
let src_nat32 = int_to_nat32 src in
update_vec dst (Mkfour src_nat32 src_nat32 src_nat32 src_nat32)
| Vspltisb dst src ->
let src_nat8 = int_to_nat8 src in
let src_nat32 = be_bytes_to_nat32 (four_to_seq_BE (Mkfour src_nat8 src_nat8 src_nat8 src_nat8)) in
update_vec dst (Mkfour src_nat32 src_nat32 src_nat32 src_nat32)
| Load128 dst base offset ->
check (valid_mem128 base offset);*
update_vec dst (eval_mem128 (eval_reg base s + eval_reg offset s) s)
| Store128 src base offset ->
check (valid_mem128 base offset);*
set (update_mem128 (eval_reg base s + eval_reg offset s) (eval_vec src s) s)
| Load128Word4 dst base ->
check (valid_mem128_reg base);*
let src_q = eval_mem128 (eval_reg base s) s in
update_vec dst (Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0)
| Load128Word4Index dst base offset ->
check (fun s -> offset <> 0);*
check (valid_mem128 base offset);*
let src_q = eval_mem128 (eval_reg base s + eval_reg offset s) s in
update_vec dst (Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0)
| Store128Word4 src base ->
check (valid_mem128_reg base);*
let src_q = eval_vec src s in
set (update_mem128 (eval_reg base s) (Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0) s)
| Store128Word4Index src base offset ->
check (fun s -> offset <> 0);*
check (valid_mem128 base offset);*
let src_q = eval_vec src s in
set (update_mem128 (eval_reg base s + eval_reg offset s) (Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0) s)
| Load128Byte16 dst base ->
check (valid_mem128_reg base);*
update_vec dst (reverse_bytes_quad32 (eval_mem128 (eval_reg base s) s))
| Load128Byte16Index dst base offset ->
check (fun s -> offset <> 0);*
check (valid_mem128 base offset);*
update_vec dst (reverse_bytes_quad32 (eval_mem128 (eval_reg base s + eval_reg offset s) s))
| Store128Byte16 src base ->
check (valid_mem128_reg base);*
set (update_mem128 (eval_reg base s) (reverse_bytes_quad32 (eval_vec src s)) s)
| Store128Byte16Index src base offset ->
check (fun s -> offset <> 0);*
check (valid_mem128 base offset);*
set (update_mem128 (eval_reg base s + eval_reg offset s) (reverse_bytes_quad32 (eval_vec src s)) s)
| Vshasigmaw0 dst src ->
let src_q = eval_vec src s in
update_vec dst (Mkfour
(sigma256_0_0 src_q.lo0)
(sigma256_0_0 src_q.lo1)
(sigma256_0_0 src_q.hi2)
(sigma256_0_0 src_q.hi3))
| Vshasigmaw1 dst src ->
let src_q = eval_vec src s in
update_vec dst (Mkfour
(sigma256_0_1 src_q.lo0)
(sigma256_0_1 src_q.lo1)
(sigma256_0_1 src_q.hi2)
(sigma256_0_1 src_q.hi3))
| Vshasigmaw2 dst src ->
let src_q = eval_vec src s in
update_vec dst (Mkfour
(sigma256_1_0 src_q.lo0)
(sigma256_1_0 src_q.lo1)
(sigma256_1_0 src_q.hi2)
(sigma256_1_0 src_q.hi3))
| Vshasigmaw3 dst src ->
let src_q = eval_vec src s in
update_vec dst (Mkfour
(sigma256_1_1 src_q.lo0)
(sigma256_1_1 src_q.lo1)
(sigma256_1_1 src_q.hi2)
(sigma256_1_1 src_q.hi3))
| Vsbox dst src ->
let src_q = eval_vec src s in
update_vec dst (Mkfour
(Vale.AES.AES_BE_s.sub_word src_q.lo0)
(Vale.AES.AES_BE_s.sub_word src_q.lo1)
(Vale.AES.AES_BE_s.sub_word src_q.hi2)
(Vale.AES.AES_BE_s.sub_word src_q.hi3))
| RotWord dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
check (fun s -> (src2_q.lo0 = 8 && src2_q.lo1 = 8 && src2_q.hi2 = 8 && src2_q.hi3 = 8));*
update_vec dst (Mkfour
(Vale.AES.AES_BE_s.rot_word src1_q.lo0)
(Vale.AES.AES_BE_s.rot_word src1_q.lo1)
(Vale.AES.AES_BE_s.rot_word src1_q.hi2)
(Vale.AES.AES_BE_s.rot_word src1_q.hi3))
| Vcipher dst src1 src2 ->
update_vec dst (quad32_xor (Vale.AES.AES_BE_s.mix_columns (Vale.AES.AES_BE_s.shift_rows (Vale.AES.AES_BE_s.sub_bytes (eval_vec src1 s)))) (eval_vec src2 s))
| Vcipherlast dst src1 src2 ->
update_vec dst (quad32_xor (Vale.AES.AES_BE_s.shift_rows (Vale.AES.AES_BE_s.sub_bytes (eval_vec src1 s))) (eval_vec src2 s))
| Vncipher dst src1 src2 ->
update_vec dst (Vale.AES.AES_BE_s.inv_mix_columns (quad32_xor (Vale.AES.AES_BE_s.inv_sub_bytes (Vale.AES.AES_BE_s.inv_shift_rows (eval_vec src1 s))) (eval_vec src2 s)))
| Vncipherlast dst src1 src2 ->
update_vec dst (quad32_xor (Vale.AES.AES_BE_s.inv_sub_bytes (Vale.AES.AES_BE_s.inv_shift_rows (eval_vec src1 s))) (eval_vec src2 s))
| Vpmsumd dst src1 src2 ->
let Mkfour a0 a1 a2 a3 = eval_vec src1 s in
let Mkfour b0 b1 b2 b3 = eval_vec src2 s in
let x0 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo a0 a1) in
let x1 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo a2 a3) in
let y0 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo b0 b1) in
let y1 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo b2 b3) in
let sum = Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul x0 y0) (Vale.Math.Poly2_s.mul x1 y1) in
update_vec dst (Vale.Math.Poly2.Bits_s.to_quad32 sum)
| Alloc n ->
check (fun s -> n % 16 = 0);*
update_r1 (eval_reg 1 s - n)
| Dealloc n ->
let old_r1 = eval_reg 1 s in
let new_r1 = old_r1 + n in
update_r1 new_r1;*
// The deallocated stack memory should now be considered invalid
free_stack old_r1 new_r1
| StoreStack128 src t offset ->
check (fun s -> valid_maddr_offset128 offset);*
let r1_pos = eval_reg 1 s + offset in
check (fun s -> r1_pos <= s.ms_stack.initial_r1 - 16);*
set (update_stack128_and_taint r1_pos (eval_vec src s) s t)
| LoadStack128 dst t offset ->
check (fun s -> valid_maddr_offset128 offset);*
let r1_pos = eval_reg 1 s + offset in
check (fun s -> r1_pos + 16 <= s.ms_stack.initial_r1);*
check (fun s -> valid_src_stack128_and_taint r1_pos s t);*
update_vec dst (eval_stack128 r1_pos s.ms_stack)
| StoreStack64 src t offset ->
check (fun s -> valid_maddr_offset64 offset);*
let r1_pos = eval_reg 1 s + offset in
check (fun s -> r1_pos <= s.ms_stack.initial_r1 - 8);*
set (update_stack_and_taint r1_pos (eval_reg src s) s t)
| LoadStack64 dst t offset ->
check (fun s -> valid_maddr_offset64 offset);*
let r1_pos = eval_reg 1 s + offset in
check (fun s -> r1_pos + 8 <= s.ms_stack.initial_r1);*
check (fun s -> valid_src_stack64_and_taint r1_pos s t);*
update_reg dst (eval_stack r1_pos s.ms_stack)
| Ghost _ ->
set s | val eval_ins (ins: ins) : st unit
let eval_ins (ins: ins) : st unit = | false | null | false | let* s = get in
match ins with
| Move dst src -> update_reg dst (eval_reg src s)
| Load64 dst base offset ->
let* _ = check (fun s -> valid_maddr_offset64 offset) in
let* _ = check (valid_mem64 base offset) in
update_reg dst (eval_mem (eval_reg base s + offset) s)
| Store64 src base offset ->
let* _ = check (fun s -> valid_maddr_offset64 offset) in
let* _ = check (valid_mem64 base offset) in
set (update_mem (eval_reg base s + offset) (eval_reg src s) s)
| LoadImm64 dst src -> update_reg dst (src % pow2_64)
| LoadImmShl64 dst src -> update_reg dst (ishl64 (src % pow2_64) 16)
| AddLa dst src1 src2 -> update_reg dst ((eval_reg src1 s + src2) % pow2_64)
| Add dst src1 src2 -> update_reg dst ((eval_reg src1 s + eval_reg src2 s) % pow2_64)
| AddImm dst src1 src2 -> update_reg dst ((eval_reg src1 s + int_to_nat64 src2) % pow2_64)
| AddCarry dst src1 src2 ->
let sum = (eval_reg src1 s) + (eval_reg src2 s) in
let new_carry = sum >= pow2_64 in
let* _ = update_reg dst (sum % pow2_64) in
update_xer (update_xer_ca s.xer new_carry)
| AddExtended dst src1 src2 ->
let old_carry = if xer_ca (s.xer) then 1 else 0 in
let sum = (eval_reg src1 s) + (eval_reg src2 s) + old_carry in
let new_carry = sum >= pow2_64 in
let* _ = update_reg dst (sum % pow2_64) in
update_xer (update_xer_ca s.xer new_carry)
| AddExtendedOV dst src1 src2 ->
let old_carry = if xer_ov (s.xer) then 1 else 0 in
let sum = (eval_reg src1 s) + (eval_reg src2 s) + old_carry in
let new_carry = sum >= pow2_64 in
let* _ = update_reg dst (sum % pow2_64) in
update_xer (update_xer_ov s.xer new_carry)
| Sub dst src1 src2 -> update_reg dst ((eval_reg src1 s - eval_reg src2 s) % pow2_64)
| SubImm dst src1 src2 -> update_reg dst ((eval_reg src1 s - int_to_nat64 src2) % pow2_64)
| MulLow64 dst src1 src2 -> update_reg dst ((eval_reg src1 s * eval_reg src2 s) % pow2_64)
| MulHigh64U dst src1 src2 ->
update_reg dst (FStar.UInt.mul_div #64 (eval_reg src1 s) (eval_reg src2 s))
| Xor dst src1 src2 -> update_reg dst (ixor (eval_reg src1 s) (eval_reg src2 s))
| And dst src1 src2 -> update_reg dst (iand (eval_reg src1 s) (eval_reg src2 s))
| Sr64Imm dst src1 src2 -> update_reg dst (ishr (eval_reg src1 s) src2)
| Sl64Imm dst src1 src2 -> update_reg dst (ishl (eval_reg src1 s) src2)
| Sr64 dst src1 src2 -> update_reg dst (ishr (eval_reg src1 s) ((eval_reg src2 s) % 64))
| Sl64 dst src1 src2 -> update_reg dst (ishl (eval_reg src1 s) ((eval_reg src2 s) % 64))
| Vmr dst src -> update_vec dst (eval_vec src s)
| Mfvsrd dst src ->
let src_q = eval_vec src s in
let src_two = four_to_two_two src_q in
let extracted_nat64 = two_to_nat 32 (two_select src_two 1) in
update_reg dst extracted_nat64
| Mfvsrld dst src ->
let src_q = eval_vec src s in
let src_two = four_to_two_two src_q in
let extracted_nat64 = two_to_nat 32 (two_select src_two 0) in
update_reg dst extracted_nat64
| Mtvsrdd dst src1 src2 ->
let val_src1 = eval_reg src1 s in
let val_src2 = eval_reg src2 s in
update_vec dst
(Mkfour (val_src2 % pow2_32) (val_src2 / pow2_32) (val_src1 % pow2_32) (val_src1 / pow2_32))
| Mtvsrws dst src ->
let val_src = eval_reg src s in
update_vec dst
(Mkfour (val_src % pow2_32) (val_src % pow2_32) (val_src % pow2_32) (val_src % pow2_32))
| Vadduwm dst src1 src2 -> update_vec dst (add_wrap_quad32 (eval_vec src1 s) (eval_vec src2 s))
| Vxor dst src1 src2 -> update_vec dst (quad32_xor (eval_vec src1 s) (eval_vec src2 s))
| Vand dst src1 src2 ->
update_vec dst (four_map2 (fun di si -> iand di si) (eval_vec src1 s) (eval_vec src2 s))
| Vslw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst
(Mkfour (ishl src1_q.lo0 (src2_q.lo0 % 32))
(ishl src1_q.lo1 (src2_q.lo1 % 32))
(ishl src1_q.hi2 (src2_q.hi2 % 32))
(ishl src1_q.hi3 (src2_q.hi3 % 32)))
| Vsrw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst
(Mkfour (ishr src1_q.lo0 (src2_q.lo0 % 32))
(ishr src1_q.lo1 (src2_q.lo1 % 32))
(ishr src1_q.hi2 (src2_q.hi2 % 32))
(ishr src1_q.hi3 (src2_q.hi3 % 32)))
| Vsl dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
let sh = (index (nat32_to_be_bytes src2_q.lo0) 3) % 8 in
let chk (v: nat32) (sh: nat8) : bool =
(let bytes = nat32_to_be_bytes v in
sh = (index bytes 3) % 8 && sh = (index bytes 2) % 8 && sh = (index bytes 1) % 8 &&
sh = (index bytes 0) % 8)
in
let* _ = check (fun s -> chk src2_q.lo0 sh) in
let* _ = check (fun s -> chk src2_q.lo1 sh) in
let* _ = check (fun s -> chk src2_q.hi2 sh) in
let* _ = check (fun s -> chk src2_q.hi3 sh) in
let l = four_map (fun (i: nat32) -> ishl i sh) src1_q in
let r = four_map (fun (i: nat32) -> ishr i (32 - sh)) src1_q in
let Mkfour r0 r1 r2 r3 = r in
update_vec dst (quad32_xor l (Mkfour 0 r0 r1 r2))
| Vcmpequw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
let eq_result (b: bool) : nat32 = if b then 0xFFFFFFFF else 0 in
let eq_val =
Mkfour (eq_result (src1_q.lo0 = src2_q.lo0))
(eq_result (src1_q.lo1 = src2_q.lo1))
(eq_result (src1_q.hi2 = src2_q.hi2))
(eq_result (src1_q.hi3 = src2_q.hi3))
in
update_vec dst eq_val
| Vsldoi dst src1 src2 count ->
let* _ = check (fun s -> (count = 4 || count = 8 || count = 12)) in
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
if count = 4
then update_vec dst (Mkfour src2_q.hi3 src1_q.lo0 src1_q.lo1 src1_q.hi2)
else
if count = 8
then update_vec dst (Mkfour src2_q.hi2 src2_q.hi3 src1_q.lo0 src1_q.lo1)
else
if count = 12
then update_vec dst (Mkfour src2_q.lo1 src2_q.hi2 src2_q.hi3 src1_q.lo0)
else fail
| Vmrghw dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst (Mkfour src2_q.lo1 src1_q.lo1 src2_q.hi3 src1_q.hi3)
| Xxmrghd dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
update_vec dst (Mkfour src2_q.hi2 src2_q.hi3 src1_q.hi2 src1_q.hi3)
| Vsel dst src1 src2 sel ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
let sel_q = eval_vec sel s in
update_vec dst
(Mkfour (isel32 src2_q.lo0 src1_q.lo0 sel_q.lo0)
(isel32 src2_q.lo1 src1_q.lo1 sel_q.lo1)
(isel32 src2_q.hi2 src1_q.hi2 sel_q.hi2)
(isel32 src2_q.hi3 src1_q.hi3 sel_q.hi3))
| Vspltw dst src uim ->
let src_q = eval_vec src s in
if uim = 0
then update_vec dst (Mkfour src_q.hi3 src_q.hi3 src_q.hi3 src_q.hi3)
else
if uim = 1
then update_vec dst (Mkfour src_q.hi2 src_q.hi2 src_q.hi2 src_q.hi2)
else
if uim = 2
then update_vec dst (Mkfour src_q.lo1 src_q.lo1 src_q.lo1 src_q.lo1)
else update_vec dst (Mkfour src_q.lo0 src_q.lo0 src_q.lo0 src_q.lo0)
| Vspltisw dst src ->
let src_nat32 = int_to_nat32 src in
update_vec dst (Mkfour src_nat32 src_nat32 src_nat32 src_nat32)
| Vspltisb dst src ->
let src_nat8 = int_to_nat8 src in
let src_nat32 = be_bytes_to_nat32 (four_to_seq_BE (Mkfour src_nat8 src_nat8 src_nat8 src_nat8)) in
update_vec dst (Mkfour src_nat32 src_nat32 src_nat32 src_nat32)
| Load128 dst base offset ->
let* _ = check (valid_mem128 base offset) in
update_vec dst (eval_mem128 (eval_reg base s + eval_reg offset s) s)
| Store128 src base offset ->
let* _ = check (valid_mem128 base offset) in
set (update_mem128 (eval_reg base s + eval_reg offset s) (eval_vec src s) s)
| Load128Word4 dst base ->
let* _ = check (valid_mem128_reg base) in
let src_q = eval_mem128 (eval_reg base s) s in
update_vec dst (Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0)
| Load128Word4Index dst base offset ->
let* _ = check (fun s -> offset <> 0) in
let* _ = check (valid_mem128 base offset) in
let src_q = eval_mem128 (eval_reg base s + eval_reg offset s) s in
update_vec dst (Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0)
| Store128Word4 src base ->
let* _ = check (valid_mem128_reg base) in
let src_q = eval_vec src s in
set (update_mem128 (eval_reg base s) (Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0) s)
| Store128Word4Index src base offset ->
let* _ = check (fun s -> offset <> 0) in
let* _ = check (valid_mem128 base offset) in
let src_q = eval_vec src s in
set (update_mem128 (eval_reg base s + eval_reg offset s)
(Mkfour src_q.hi3 src_q.hi2 src_q.lo1 src_q.lo0)
s)
| Load128Byte16 dst base ->
let* _ = check (valid_mem128_reg base) in
update_vec dst (reverse_bytes_quad32 (eval_mem128 (eval_reg base s) s))
| Load128Byte16Index dst base offset ->
let* _ = check (fun s -> offset <> 0) in
let* _ = check (valid_mem128 base offset) in
update_vec dst (reverse_bytes_quad32 (eval_mem128 (eval_reg base s + eval_reg offset s) s))
| Store128Byte16 src base ->
let* _ = check (valid_mem128_reg base) in
set (update_mem128 (eval_reg base s) (reverse_bytes_quad32 (eval_vec src s)) s)
| Store128Byte16Index src base offset ->
let* _ = check (fun s -> offset <> 0) in
let* _ = check (valid_mem128 base offset) in
set (update_mem128 (eval_reg base s + eval_reg offset s) (reverse_bytes_quad32 (eval_vec src s)) s
)
| Vshasigmaw0 dst src ->
let src_q = eval_vec src s in
update_vec dst
(Mkfour (sigma256_0_0 src_q.lo0)
(sigma256_0_0 src_q.lo1)
(sigma256_0_0 src_q.hi2)
(sigma256_0_0 src_q.hi3))
| Vshasigmaw1 dst src ->
let src_q = eval_vec src s in
update_vec dst
(Mkfour (sigma256_0_1 src_q.lo0)
(sigma256_0_1 src_q.lo1)
(sigma256_0_1 src_q.hi2)
(sigma256_0_1 src_q.hi3))
| Vshasigmaw2 dst src ->
let src_q = eval_vec src s in
update_vec dst
(Mkfour (sigma256_1_0 src_q.lo0)
(sigma256_1_0 src_q.lo1)
(sigma256_1_0 src_q.hi2)
(sigma256_1_0 src_q.hi3))
| Vshasigmaw3 dst src ->
let src_q = eval_vec src s in
update_vec dst
(Mkfour (sigma256_1_1 src_q.lo0)
(sigma256_1_1 src_q.lo1)
(sigma256_1_1 src_q.hi2)
(sigma256_1_1 src_q.hi3))
| Vsbox dst src ->
let src_q = eval_vec src s in
update_vec dst
(Mkfour (Vale.AES.AES_BE_s.sub_word src_q.lo0)
(Vale.AES.AES_BE_s.sub_word src_q.lo1)
(Vale.AES.AES_BE_s.sub_word src_q.hi2)
(Vale.AES.AES_BE_s.sub_word src_q.hi3))
| RotWord dst src1 src2 ->
let src1_q = eval_vec src1 s in
let src2_q = eval_vec src2 s in
let* _ =
check (fun s -> (src2_q.lo0 = 8 && src2_q.lo1 = 8 && src2_q.hi2 = 8 && src2_q.hi3 = 8))
in
update_vec dst
(Mkfour (Vale.AES.AES_BE_s.rot_word src1_q.lo0)
(Vale.AES.AES_BE_s.rot_word src1_q.lo1)
(Vale.AES.AES_BE_s.rot_word src1_q.hi2)
(Vale.AES.AES_BE_s.rot_word src1_q.hi3))
| Vcipher dst src1 src2 ->
update_vec dst
(quad32_xor (Vale.AES.AES_BE_s.mix_columns (Vale.AES.AES_BE_s.shift_rows (Vale.AES.AES_BE_s.sub_bytes
(eval_vec src1 s))))
(eval_vec src2 s))
| Vcipherlast dst src1 src2 ->
update_vec dst
(quad32_xor (Vale.AES.AES_BE_s.shift_rows (Vale.AES.AES_BE_s.sub_bytes (eval_vec src1 s)))
(eval_vec src2 s))
| Vncipher dst src1 src2 ->
update_vec dst
(Vale.AES.AES_BE_s.inv_mix_columns (quad32_xor (Vale.AES.AES_BE_s.inv_sub_bytes (Vale.AES.AES_BE_s.inv_shift_rows
(eval_vec src1 s)))
(eval_vec src2 s)))
| Vncipherlast dst src1 src2 ->
update_vec dst
(quad32_xor (Vale.AES.AES_BE_s.inv_sub_bytes (Vale.AES.AES_BE_s.inv_shift_rows (eval_vec src1 s)
))
(eval_vec src2 s))
| Vpmsumd dst src1 src2 ->
let Mkfour a0 a1 a2 a3 = eval_vec src1 s in
let Mkfour b0 b1 b2 b3 = eval_vec src2 s in
let x0 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo a0 a1) in
let x1 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo a2 a3) in
let y0 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo b0 b1) in
let y1 = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo b2 b3) in
let sum = Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul x0 y0) (Vale.Math.Poly2_s.mul x1 y1) in
update_vec dst (Vale.Math.Poly2.Bits_s.to_quad32 sum)
| Alloc n ->
let* _ = check (fun s -> n % 16 = 0) in
update_r1 (eval_reg 1 s - n)
| Dealloc n ->
let old_r1 = eval_reg 1 s in
let new_r1 = old_r1 + n in
let* _ = update_r1 new_r1 in
free_stack old_r1 new_r1
| StoreStack128 src t offset ->
let* _ = check (fun s -> valid_maddr_offset128 offset) in
let r1_pos = eval_reg 1 s + offset in
let* _ = check (fun s -> r1_pos <= s.ms_stack.initial_r1 - 16) in
set (update_stack128_and_taint r1_pos (eval_vec src s) s t)
| LoadStack128 dst t offset ->
let* _ = check (fun s -> valid_maddr_offset128 offset) in
let r1_pos = eval_reg 1 s + offset in
let* _ = check (fun s -> r1_pos + 16 <= s.ms_stack.initial_r1) in
let* _ = check (fun s -> valid_src_stack128_and_taint r1_pos s t) in
update_vec dst (eval_stack128 r1_pos s.ms_stack)
| StoreStack64 src t offset ->
let* _ = check (fun s -> valid_maddr_offset64 offset) in
let r1_pos = eval_reg 1 s + offset in
let* _ = check (fun s -> r1_pos <= s.ms_stack.initial_r1 - 8) in
set (update_stack_and_taint r1_pos (eval_reg src s) s t)
| LoadStack64 dst t offset ->
let* _ = check (fun s -> valid_maddr_offset64 offset) in
let r1_pos = eval_reg 1 s + offset in
let* _ = check (fun s -> r1_pos + 8 <= s.ms_stack.initial_r1) in
let* _ = check (fun s -> valid_src_stack64_and_taint r1_pos s t) in
update_reg dst (eval_stack r1_pos s.ms_stack)
| Ghost _ -> set s | {
"checked_file": "Vale.PPC64LE.Semantics_s.fst.checked",
"dependencies": [
"Vale.SHA2.Wrapper.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Semantics_s.fst"
} | [
"total"
] | [
"Vale.PPC64LE.Semantics_s.ins",
"Vale.PPC64LE.Semantics_s.op_let_Star",
"Vale.PPC64LE.Machine_s.state",
"Prims.unit",
"Vale.PPC64LE.Semantics_s.get",
"Vale.PPC64LE.Machine_s.reg",
"Vale.PPC64LE.Semantics_s.update_reg",
"Vale.PPC64LE.Semantics_s.eval_reg",
"Prims.int",
"Vale.PPC64LE.Semantics_s.check",
"Vale.PPC64LE.Machine_s.valid_maddr_offset64",
"Prims.bool",
"Vale.PPC64LE.Semantics_s.valid_mem64",
"Vale.PPC64LE.Semantics_s.eval_mem",
"Prims.op_Addition",
"Vale.PPC64LE.Semantics_s.st",
"Vale.PPC64LE.Semantics_s.set",
"Vale.PPC64LE.Semantics_s.update_mem",
"Vale.PPC64LE.Machine_s.simm16",
"Prims.op_Modulus",
"Vale.Def.Words_s.pow2_64",
"Vale.Arch.Types.ishl64",
"Vale.PPC64LE.Machine_s.int_to_nat64",
"Vale.PPC64LE.Semantics_s.update_xer",
"Vale.PPC64LE.Semantics_s.update_xer_ca",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer",
"Prims.op_GreaterThanOrEqual",
"Vale.PPC64LE.Semantics_s.xer_ca",
"Vale.PPC64LE.Semantics_s.update_xer_ov",
"Vale.PPC64LE.Semantics_s.xer_ov",
"Prims.op_Subtraction",
"Vale.PPC64LE.Machine_s.nsimm16",
"FStar.Mul.op_Star",
"FStar.UInt.mul_div",
"Vale.Def.Types_s.ixor",
"Vale.Def.Types_s.iand",
"Vale.PPC64LE.Machine_s.bits64",
"Vale.Def.Types_s.ishr",
"Vale.Def.Types_s.ishl",
"Vale.PPC64LE.Machine_s.vec",
"Vale.PPC64LE.Semantics_s.update_vec",
"Vale.PPC64LE.Semantics_s.eval_vec",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Prims.op_Multiply",
"Vale.Def.Words.Two_s.two_to_nat",
"Vale.Def.Words.Two_s.two_select",
"Vale.Def.Words_s.two",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Four_s.four_to_two_two",
"Vale.Def.Types_s.quad32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.pow2_32",
"Prims.op_Division",
"Vale.Def.Words_s.nat64",
"Vale.Arch.Types.add_wrap_quad32",
"Vale.Def.Types_s.quad32_xor",
"Vale.Def.Words.Four_s.four_map2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Words_s.four",
"Vale.Def.Words.Four_s.four_map",
"Vale.Def.Words_s.nat8",
"Vale.Def.Types_s.nat8",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"FStar.Seq.Base.index",
"Vale.Def.Words.Seq_s.seq4",
"Prims.eq2",
"Vale.Def.Types_s.be_bytes_to_nat32",
"Vale.Def.Types_s.nat32_to_be_bytes",
"Vale.PPC64LE.Machine_s.quad32bytes",
"Prims.op_BarBar",
"Vale.PPC64LE.Semantics_s.fail",
"Vale.Def.Sel.isel32",
"Vale.Def.Words_s.nat2",
"Vale.PPC64LE.Machine_s.sim",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Vale.PPC64LE.Machine_s.int_to_nat32",
"Vale.Def.Words.Seq_s.four_to_seq_BE",
"Vale.PPC64LE.Machine_s.int_to_nat8",
"Vale.PPC64LE.Semantics_s.valid_mem128",
"Vale.PPC64LE.Semantics_s.eval_mem128",
"Vale.PPC64LE.Semantics_s.update_mem128",
"Vale.PPC64LE.Semantics_s.valid_mem128_reg",
"Prims.op_disEquality",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.SHA2.Wrapper.sigma256_0_0",
"Vale.SHA2.Wrapper.sigma256_0_1",
"Vale.SHA2.Wrapper.sigma256_1_0",
"Vale.SHA2.Wrapper.sigma256_1_1",
"Vale.AES.AES_common_s.sub_word",
"Vale.AES.AES_BE_s.rot_word",
"Vale.AES.AES_BE_s.mix_columns",
"Vale.AES.AES_BE_s.shift_rows",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_BE_s.inv_mix_columns",
"Vale.AES.AES_common_s.inv_sub_bytes",
"Vale.AES.AES_BE_s.inv_shift_rows",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2_s.add",
"Vale.Math.Poly2_s.mul",
"Vale.Math.Poly2.Bits_s.of_double32",
"Vale.Def.Words_s.Mktwo",
"Vale.Def.Types_s.nat64",
"Vale.PPC64LE.Semantics_s.update_r1",
"Vale.PPC64LE.Semantics_s.free_stack",
"Vale.Arch.HeapTypes_s.taint",
"Vale.PPC64LE.Machine_s.valid_maddr_offset128",
"Vale.PPC64LE.Machine_s.__proj__Machine_stack__item__initial_r1",
"Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack",
"Vale.PPC64LE.Semantics_s.update_stack128_and_taint",
"Vale.PPC64LE.Semantics_s.valid_src_stack128_and_taint",
"Vale.PPC64LE.Semantics_s.eval_stack128",
"Vale.PPC64LE.Semantics_s.update_stack_and_taint",
"Vale.PPC64LE.Semantics_s.valid_src_stack64_and_taint",
"Vale.PPC64LE.Semantics_s.eval_stack"
] | [] | module Vale.PPC64LE.Semantics_s
open FStar.Mul
open FStar.Seq.Base
open Vale.PPC64LE.Machine_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.Arch.Types
open Vale.Def.Sel
open Vale.SHA2.Wrapper
let (.[]) = Map.sel
let (.[]<-) = Map.upd
type ins =
| Move : dst:reg -> src:reg -> ins
| Load64 : dst:reg -> base:reg -> offset:int -> ins
| Store64 : src:reg -> base:reg -> offset:int -> ins
| LoadImm64 : dst:reg -> src:simm16 -> ins
| LoadImmShl64 : dst:reg -> src:simm16 -> ins
| AddLa : dst:reg -> src1:reg -> src2:simm16 -> ins
| Add : dst:reg -> src1:reg -> src2:reg -> ins
| AddImm : dst:reg -> src1:reg -> src2:simm16 -> ins
| AddCarry : dst:reg -> src1:reg -> src2:reg -> ins
| AddExtended : dst:reg -> src1:reg -> src2:reg -> ins
| AddExtendedOV: dst:reg -> src1:reg -> src2:reg -> ins
| Sub : dst:reg -> src1:reg -> src2:reg -> ins
| SubImm : dst:reg -> src1:reg -> src2:nsimm16 -> ins
| MulLow64 : dst:reg -> src1:reg -> src2:reg -> ins
| MulHigh64U : dst:reg -> src1:reg -> src2:reg -> ins
| Xor : dst:reg -> src1:reg -> src2:reg -> ins
| And : dst:reg -> src1:reg -> src2:reg -> ins
| Sr64Imm : dst:reg -> src1:reg -> src2:bits64 -> ins
| Sl64Imm : dst:reg -> src1:reg -> src2:bits64 -> ins
| Sr64 : dst:reg -> src1:reg -> src2:reg -> ins
| Sl64 : dst:reg -> src1:reg -> src2:reg -> ins
| Vmr : dst:vec -> src:vec -> ins
| Mfvsrd : dst:reg -> src:vec -> ins
| Mfvsrld : dst:reg -> src:vec -> ins
| Mtvsrdd : dst:vec -> src1:reg -> src2:reg -> ins
| Mtvsrws : dst:vec -> src:reg -> ins
| Vadduwm : dst:vec -> src1:vec -> src2:vec -> ins
| Vxor : dst:vec -> src1:vec -> src2:vec -> ins
| Vand : dst:vec -> src1:vec -> src2:vec -> ins
| Vslw : dst:vec -> src1:vec -> src2:vec -> ins
| Vsrw : dst:vec -> src1:vec -> src2:vec -> ins
| Vsl : dst:vec -> src1:vec -> src2:vec -> ins
| Vcmpequw : dst:vec -> src1:vec -> src2:vec -> ins
| Vsldoi : dst:vec -> src1:vec -> src2:vec -> count:quad32bytes -> ins
| Vmrghw : dst:vec -> src1:vec -> src2:vec -> ins
| Xxmrghd : dst:vec -> src1:vec -> src2:vec -> ins
| Vsel : dst:vec -> src1:vec -> src2:vec -> sel:vec -> ins
| Vspltw : dst:vec -> src:vec -> uim:nat2 -> ins
| Vspltisw : dst:vec -> src:sim -> ins
| Vspltisb : dst:vec -> src:sim -> ins
| Load128 : dst:vec -> base:reg -> offset:reg -> ins
| Store128 : src:vec -> base:reg -> offset:reg -> ins
| Load128Word4 : dst:vec -> base:reg -> ins
| Load128Word4Index : dst:vec -> base:reg -> offset:reg -> ins
| Store128Word4: src:vec -> base:reg -> ins
| Store128Word4Index: src:vec -> base:reg -> offset:reg -> ins
| Load128Byte16: dst:vec -> base:reg -> ins
| Load128Byte16Index: dst:vec -> base:reg -> offset:reg -> ins
| Store128Byte16: src:vec -> base:reg -> ins
| Store128Byte16Index: src:vec -> base:reg -> offset:reg -> ins
| Vshasigmaw0 : dst:vec -> src:vec -> ins
| Vshasigmaw1 : dst:vec -> src:vec -> ins
| Vshasigmaw2 : dst:vec -> src:vec -> ins
| Vshasigmaw3 : dst:vec -> src:vec -> ins
| Vsbox : dst:vec -> src:vec -> ins
| RotWord : dst:vec -> src1:vec -> src2:vec -> ins
| Vcipher : dst:vec -> src1:vec -> src2:vec -> ins
| Vcipherlast : dst:vec -> src1:vec -> src2:vec -> ins
| Vncipher : dst:vec -> src1:vec -> src2:vec -> ins
| Vncipherlast : dst:vec -> src1:vec -> src2:vec -> ins
| Vpmsumd : dst:vec -> src1:vec -> src2:vec -> ins
| Alloc : n:nat64 -> ins
| Dealloc : n:nat64 -> ins
| StoreStack128: src:vec -> t:taint -> offset:int -> ins
| LoadStack128 : dst:vec -> t:taint -> offset:int -> ins
| StoreStack64 : src:reg -> t:taint -> offset:int -> ins
| LoadStack64 : dst:reg -> t:taint -> offset:int -> ins
| Ghost : (_:unit) -> ins
type ocmp =
| OEq: o1:cmp_opr -> o2:cmp_opr -> ocmp
| ONe: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OLe: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OGe: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OLt: o1:cmp_opr -> o2:cmp_opr -> ocmp
| OGt: o1:cmp_opr -> o2:cmp_opr -> ocmp
type code = precode ins ocmp
type codes = list code
unfold let eval_reg (r:reg) (s:state) : nat64 = s.regs r
unfold let eval_vec (v:vec) (s:state) : quad32 = s.vecs v
unfold let eval_mem (ptr:int) (s:state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:state) (t:taint) : state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let update_mem (ptr:int) (v:nat64) (s:state) : state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(heap_taint s.ms_heap)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128 (ptr:int) (v:quad32) (s:state) : state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(heap_taint s.ms_heap)
}
else s
let update_mem128_and_taint (ptr:int) (v:quad32) (s:state) (t:taint) : state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_r1 mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_r1 mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_r1 mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_r1 mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:state) (t:taint) : state =
let Machine_stack init_r1 mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:state) (t:taint) : state =
let Machine_stack init_r1 mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
valid_addr128 ptr mem
unfold
let valid_src_stack64_and_taint (ptr:int) (s:state) (t:taint) : bool =
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
unfold
let valid_src_stack128_and_taint (ptr:int) (s:state) (t:taint) : bool =
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_src_stack (r:reg) (s:state) : bool =
valid_src_stack64 (eval_reg r s) s.ms_stack
[@va_qattr]
let eval_maddr (m:maddr) (s:state) : int =
eval_reg m.address s + m.offset
let eval_cmp_opr (o:cmp_opr) (s:state) : nat64 =
match o with
| CReg r -> eval_reg r s
| CImm n -> int_to_nat64 n
let eval_ocmp (s:state) (c:ocmp) :bool =
match c with
| OEq o1 o2 -> eval_cmp_opr o1 s = eval_cmp_opr o2 s
| ONe o1 o2 -> eval_cmp_opr o1 s <> eval_cmp_opr o2 s
| OLe o1 o2 -> eval_cmp_opr o1 s <= eval_cmp_opr o2 s
| OGe o1 o2 -> eval_cmp_opr o1 s >= eval_cmp_opr o2 s
| OLt o1 o2 -> eval_cmp_opr o1 s < eval_cmp_opr o2 s
| OGt o1 o2 -> eval_cmp_opr o1 s > eval_cmp_opr o2 s
let eval_cmp_cr0 (s:state) (c:ocmp) : cr0_t =
match c with
| OEq o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| ONe o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OLe o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OGe o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OLt o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
| OGt o1 o2 -> get_cr0 ((eval_cmp_opr o1 s - eval_cmp_opr o2 s) % pow2_64)
unfold
let valid_dst_stack64 (r1:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= r1 && ptr + 8 <= init_r1
unfold
let valid_dst_stack128 (r1:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_r1 mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= r1 && ptr + 16 <= init_r1
let valid_dst_stack64_addr (m:maddr) (s:state) : bool =
valid_dst_stack64 (eval_reg 1 s) (eval_maddr m s) s.ms_stack
let valid_dst_stack128_addr (m:maddr) (s:state) : bool =
valid_dst_stack128 (eval_reg 1 s) (eval_maddr m s) s.ms_stack
let update_reg' (r:reg) (v:nat64) (s:state) : state =
{ s with regs = regs_make (fun (r':reg) -> if r' = r then v else s.regs r') }
let update_vec' (vr:vec) (v:quad32) (s:state) : state =
{ s with vecs = vecs_make (fun (vr':vec) -> if vr' = vr then v else s.vecs vr') }
let update_r1' (new_r1:int) (s:state) : state =
let Machine_stack init_r1 mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_r1 >= init_r1 - 65536 && new_r1 <= init_r1 then
update_reg' 1 new_r1 s
else
s
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_r1 mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_r1 new_mem
let valid_mem (m:maddr) (s:state) : bool =
valid_maddr_offset64 m.offset && valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
let valid_mem64 (r:reg) (i:int) (s:state) : bool =
valid_addr64 (eval_reg r s + i) (heap_get s.ms_heap)
let valid_mem128 (r:reg) (i:reg) (s:state) : bool =
valid_addr128 (eval_reg r s + eval_reg i s) (heap_get s.ms_heap)
let valid_mem128_reg (r:reg) (s:state) : bool =
valid_addr128 (eval_reg r s) (heap_get s.ms_heap)
let valid_mem128' (m:maddr) (s:state) : bool =
valid_maddr_offset128 m.offset && valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
let valid_mem_and_taint (m:maddr) (t:taint) (s:state) : bool =
let ptr = eval_maddr m s in
valid_maddr_offset64 m.offset && valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
let valid_mem128_and_taint (m:maddr) (s:state) (t:taint) : bool =
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
let valid_ocmp (c:ocmp) (s:state) : bool =
match c with
| OEq o1 _ -> valid_first_cmp_opr o1
| ONe o1 _ -> valid_first_cmp_opr o1
| OLe o1 _ -> valid_first_cmp_opr o1
| OGe o1 _ -> valid_first_cmp_opr o1
| OLt o1 _ -> valid_first_cmp_opr o1
| OGt o1 _ -> valid_first_cmp_opr o1
let xer_ov (xer:xer_t) : bool =
xer.ov
let xer_ca (xer:xer_t) : bool =
xer.ca
let update_xer_ov (xer:xer_t) (new_xer_ov:bool) : (new_xer:xer_t{xer_ov new_xer == new_xer_ov}) =
{ xer with ov = new_xer_ov }
let update_xer_ca (xer:xer_t) (new_xer_ca:bool) : (new_xer:xer_t{xer_ca new_xer == new_xer_ca}) =
{ xer with ca = new_xer_ca }
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = state -> a & state
unfold
let return (#a:Type) (x:a) :st a =
fun s -> x, s
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) :st b =
fun s0 ->
let x, s1 = m s0 in
let y, s2 = f x s1 in
y, {s2 with ok=s0.ok && s1.ok && s2.ok}
unfold
let get :st state =
fun s -> s, s
unfold
let set (s:state) :st unit =
fun _ -> (), s
unfold
let fail :st unit =
fun s -> (), {s with ok=false}
unfold
let check (valid: state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let run (f:st unit) (s:state) : state = snd (f s)
let update_reg (r:reg) (v:nat64) :st unit =
let* s = get in
set (update_reg' r v s)
let update_vec (vr:vec) (v:quad32) :st unit =
let* s = get in
set (update_vec' vr v s)
let update_xer (new_xer:xer_t) :st unit =
let* s = get in
set ( { s with xer = new_xer } )
let update_cr0 (new_cr0:cr0_t) :st unit =
let* s = get in
set ( { s with cr0 = new_cr0 } )
unfold
let update_r1 (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_r1 - 65536);*
check (fun s -> i <= s.ms_stack.initial_r1);*
let* s = get in
set (update_r1' i s)
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
// Core definition of instruction semantics | false | true | Vale.PPC64LE.Semantics_s.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 eval_ins (ins: ins) : st unit | [] | Vale.PPC64LE.Semantics_s.eval_ins | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Semantics_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ins: Vale.PPC64LE.Semantics_s.ins -> Vale.PPC64LE.Semantics_s.st Prims.unit | {
"end_col": 9,
"end_line": 809,
"start_col": 2,
"start_line": 440
} |
Prims.Tot | val remove_between (s:S.set int) (start:int) (finish:int): S.set int | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let remove_between s start finish =
if finish <= start then s
else remove_between' s start finish | val remove_between (s:S.set int) (start:int) (finish:int): S.set int
let remove_between s start finish = | false | null | false | if finish <= start then s else remove_between' s start finish | {
"checked_file": "Vale.Lib.Set.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.Set.fst"
} | [
"total"
] | [
"FStar.Set.set",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"Vale.Lib.Set.remove_between'"
] | [] | module Vale.Lib.Set
open FStar.Mul
friend FStar.Map
let rec remove_between' s (start:int) (finish:int{start <= finish}) : Tot (s':S.set int{ forall i.
((start <= i /\ i < finish) ==> not (S.mem i s')) /\
((i < start \/ finish <= i) ==> S.mem i s' = S.mem i s)})
(decreases %[finish - start]) =
if finish = start then s
else remove_between' (S.intersect s (S.complement (S.singleton start))) (start + 1) finish | false | true | Vale.Lib.Set.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 remove_between (s:S.set int) (start:int) (finish:int): S.set int | [] | Vale.Lib.Set.remove_between | {
"file_name": "vale/specs/defs/Vale.Lib.Set.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Set.set Prims.int -> start: Prims.int -> finish: Prims.int -> FStar.Set.set Prims.int | {
"end_col": 37,
"end_line": 15,
"start_col": 2,
"start_line": 14
} |
Prims.Tot | val remove_between' (s: _) (start: int) (finish: int{start <= finish})
: Tot
(s':
S.set int
{ forall i.
((start <= i /\ i < finish) ==> not (S.mem i s')) /\
((i < start \/ finish <= i) ==> S.mem i s' = S.mem i s) })
(decreases %[finish - start]) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec remove_between' s (start:int) (finish:int{start <= finish}) : Tot (s':S.set int{ forall i.
((start <= i /\ i < finish) ==> not (S.mem i s')) /\
((i < start \/ finish <= i) ==> S.mem i s' = S.mem i s)})
(decreases %[finish - start]) =
if finish = start then s
else remove_between' (S.intersect s (S.complement (S.singleton start))) (start + 1) finish | val remove_between' (s: _) (start: int) (finish: int{start <= finish})
: Tot
(s':
S.set int
{ forall i.
((start <= i /\ i < finish) ==> not (S.mem i s')) /\
((i < start \/ finish <= i) ==> S.mem i s' = S.mem i s) })
(decreases %[finish - start])
let rec remove_between' s (start: int) (finish: int{start <= finish})
: Tot
(s':
S.set int
{ forall i.
((start <= i /\ i < finish) ==> not (S.mem i s')) /\
((i < start \/ finish <= i) ==> S.mem i s' = S.mem i s) })
(decreases %[finish - start]) = | false | null | false | if finish = start
then s
else remove_between' (S.intersect s (S.complement (S.singleton start))) (start + 1) finish | {
"checked_file": "Vale.Lib.Set.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.Set.fst"
} | [
"total",
""
] | [
"FStar.Set.set",
"Prims.int",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.bool",
"Vale.Lib.Set.remove_between'",
"FStar.Set.intersect",
"FStar.Set.complement",
"FStar.Set.singleton",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.l_and",
"Prims.l_imp",
"Prims.op_LessThan",
"Prims.op_Negation",
"FStar.Set.mem",
"Prims.l_or"
] | [] | module Vale.Lib.Set
open FStar.Mul
friend FStar.Map
let rec remove_between' s (start:int) (finish:int{start <= finish}) : Tot (s':S.set int{ forall i.
((start <= i /\ i < finish) ==> not (S.mem i s')) /\
((i < start \/ finish <= i) ==> S.mem i s' = S.mem i s)}) | false | false | Vale.Lib.Set.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 remove_between' (s: _) (start: int) (finish: int{start <= finish})
: Tot
(s':
S.set int
{ forall i.
((start <= i /\ i < finish) ==> not (S.mem i s')) /\
((i < start \/ finish <= i) ==> S.mem i s' = S.mem i s) })
(decreases %[finish - start]) | [
"recursion"
] | Vale.Lib.Set.remove_between' | {
"file_name": "vale/specs/defs/Vale.Lib.Set.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Set.set Prims.int -> start: Prims.int -> finish: Prims.int{start <= finish}
-> Prims.Tot
(s':
FStar.Set.set Prims.int
{ forall (i: Prims.int).
(start <= i /\ i < finish ==> Prims.op_Negation (FStar.Set.mem i s')) /\
(i < start \/ finish <= i ==> FStar.Set.mem i s' = FStar.Set.mem i s) }) | {
"end_col": 92,
"end_line": 11,
"start_col": 2,
"start_line": 10
} |
Prims.Tot | val parse_bounded_integer_bare (i: integer_size) : Tot (bare_parser (bounded_integer i)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": false,
"full_module": "LowParse.Tot.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Tot",
"short_module": null
},
{
"abbrev": false,
"full_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_bounded_integer_bare
(i: integer_size)
: Tot (bare_parser (bounded_integer i))
= fun input ->
parse_bounded_integer_spec i input;
if Seq.length input < i
then None
else
let input' = Seq.slice input 0 i in
let _ = E.lemma_be_to_n_is_bounded input' in
let y = U32.uint_to_t (E.be_to_n input') in
Some (y, i) | val parse_bounded_integer_bare (i: integer_size) : Tot (bare_parser (bounded_integer i))
let parse_bounded_integer_bare (i: integer_size) : Tot (bare_parser (bounded_integer i)) = | false | null | false | fun input ->
parse_bounded_integer_spec i input;
if Seq.length input < i
then None
else
let input' = Seq.slice input 0 i in
let _ = E.lemma_be_to_n_is_bounded input' in
let y = U32.uint_to_t (E.be_to_n input') in
Some (y, i) | {
"checked_file": "LowParse.Tot.BoundedInt.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Tot.Int.fst.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Tot.BoundedInt.fst"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Bytes.bytes",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Base.consumed_length",
"Prims.bool",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.UInt32.t",
"FStar.UInt32.uint_to_t",
"FStar.Endianness.be_to_n",
"Prims.unit",
"FStar.Endianness.lemma_be_to_n_is_bounded",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"FStar.Pervasives.Native.option",
"LowParse.Spec.BoundedInt.parse_bounded_integer_spec",
"LowParse.Tot.Base.bare_parser"
] | [] | module LowParse.Tot.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Tot.Int
module E = FStar.Endianness
module U32 = FStar.UInt32
let parse_bounded_integer_bare
(i: integer_size) | false | false | LowParse.Tot.BoundedInt.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_bounded_integer_bare (i: integer_size) : Tot (bare_parser (bounded_integer i)) | [] | LowParse.Tot.BoundedInt.parse_bounded_integer_bare | {
"file_name": "src/lowparse/LowParse.Tot.BoundedInt.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Tot.Base.bare_parser (LowParse.Spec.BoundedInt.bounded_integer i) | {
"end_col": 15,
"end_line": 19,
"start_col": 2,
"start_line": 11
} |
Prims.Tot | val parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": false,
"full_module": "LowParse.Tot.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Tot",
"short_module": null
},
{
"abbrev": false,
"full_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_bounded_integer
i
=
Classical.forall_intro (parse_bounded_integer_spec i);
parser_kind_prop_ext
(parse_bounded_integer_kind i)
(parse_bounded_integer i)
(parse_bounded_integer_bare i);
parse_bounded_integer_bare i | val parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
let parse_bounded_integer i = | false | null | false | Classical.forall_intro (parse_bounded_integer_spec i);
parser_kind_prop_ext (parse_bounded_integer_kind i)
(parse_bounded_integer i)
(parse_bounded_integer_bare i);
parse_bounded_integer_bare i | {
"checked_file": "LowParse.Tot.BoundedInt.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Tot.Int.fst.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Tot.BoundedInt.fst"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Tot.BoundedInt.parse_bounded_integer_bare",
"Prims.unit",
"LowParse.Spec.Base.parser_kind_prop_ext",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"FStar.Classical.forall_intro",
"LowParse.Bytes.bytes",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"FStar.Pervasives.Native.None",
"Prims.bool",
"Prims.l_False",
"Prims.l_and",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Endianness.be_to_n",
"FStar.Seq.Base.slice",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.BoundedInt.parse_bounded_integer_spec",
"LowParse.Tot.Base.parser"
] | [] | module LowParse.Tot.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Tot.Int
module E = FStar.Endianness
module U32 = FStar.UInt32
let parse_bounded_integer_bare
(i: integer_size)
: Tot (bare_parser (bounded_integer i))
= fun input ->
parse_bounded_integer_spec i input;
if Seq.length input < i
then None
else
let input' = Seq.slice input 0 i in
let _ = E.lemma_be_to_n_is_bounded input' in
let y = U32.uint_to_t (E.be_to_n input') in
Some (y, i)
val parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
let parse_bounded_integer
i | false | false | LowParse.Tot.BoundedInt.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_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) | [] | LowParse.Tot.BoundedInt.parse_bounded_integer | {
"file_name": "src/lowparse/LowParse.Tot.BoundedInt.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Tot.Base.parser (LowParse.Spec.BoundedInt.parse_bounded_integer_kind i)
(LowParse.Spec.BoundedInt.bounded_integer i) | {
"end_col": 30,
"end_line": 33,
"start_col": 2,
"start_line": 28
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let felem = lbuffer uint64 5ul | let felem = | false | null | false | lbuffer uint64 5ul | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20" | false | true | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val felem : Type0 | [] | Hacl.Impl.Curve25519.Field51.felem | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 30,
"end_line": 25,
"start_col": 12,
"start_line": 25
} |
|
Prims.GTot | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_felem =
C.f51_as_felem | let as_felem = | false | null | false | C.f51_as_felem | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"sometrivial"
] | [
"Hacl.Impl.Curve25519.Fields.Core.f51_as_felem"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_felem : h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 | [] | Hacl.Impl.Curve25519.Field51.as_felem | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 | {
"end_col": 16,
"end_line": 68,
"start_col": 2,
"start_line": 68
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let felem_wide = lbuffer uint128 5ul | let felem_wide = | false | null | false | lbuffer uint128 5ul | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint128",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul | false | true | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val felem_wide : Type0 | [] | Hacl.Impl.Curve25519.Field51.felem_wide | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 36,
"end_line": 27,
"start_col": 17,
"start_line": 27
} |
|
Prims.GTot | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_nat = C.f51_as_nat | let as_nat = | false | null | false | C.f51_as_nat | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"sometrivial"
] | [
"Hacl.Impl.Curve25519.Fields.Core.f51_as_nat"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_nat : h: FStar.Monotonic.HyperStack.mem ->
e: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Prims.nat | [] | Hacl.Impl.Curve25519.Field51.as_nat | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
e: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Prims.nat | {
"end_col": 25,
"end_line": 30,
"start_col": 13,
"start_line": 30
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let felem2 = lbuffer uint64 10ul | let felem2 = | false | null | false | lbuffer uint64 10ul | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20" | false | true | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val felem2 : Type0 | [] | Hacl.Impl.Curve25519.Field51.felem2 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 32,
"end_line": 26,
"start_col": 13,
"start_line": 26
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let felem_fits =
C.f51_felem_fits | let felem_fits = | false | null | false | C.f51_felem_fits | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract | false | true | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val felem_fits : h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51 ->
m: Hacl.Spec.Curve25519.Field51.Definition.scale64_5
-> Type0 | [] | Hacl.Impl.Curve25519.Field51.felem_fits | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51 ->
m: Hacl.Spec.Curve25519.Field51.Definition.scale64_5
-> Type0 | {
"end_col": 18,
"end_line": 53,
"start_col": 2,
"start_line": 53
} |
|
Prims.GTot | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_inv_t =
C.f51_mul_inv_t | let mul_inv_t = | false | null | false | C.f51_mul_inv_t | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"sometrivial"
] | [
"Hacl.Impl.Curve25519.Fields.Core.f51_mul_inv_t"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_inv_t : h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Type0 | [] | Hacl.Impl.Curve25519.Field51.mul_inv_t | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Type0 | {
"end_col": 17,
"end_line": 72,
"start_col": 2,
"start_line": 72
} |
|
Prims.GTot | val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let feval_wideh h f = (wide_as_nat h f) % P.prime | val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = | false | null | false | (wide_as_nat h f) % P.prime | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Field51.felem_wide",
"Prims.op_Modulus",
"Hacl.Impl.Curve25519.Field51.wide_as_nat",
"Spec.Curve25519.prime",
"Spec.Curve25519.elem"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem | [] | Hacl.Impl.Curve25519.Field51.feval_wideh | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Curve25519.Field51.felem_wide
-> Prims.GTot Spec.Curve25519.elem | {
"end_col": 49,
"end_line": 49,
"start_col": 22,
"start_line": 49
} |
Prims.GTot | val fevalh: h:mem -> f:felem -> GTot P.elem | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fevalh h f = (as_nat h f) % P.prime | val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = | false | null | false | (as_nat h f) % P.prime | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Field51.felem",
"Prims.op_Modulus",
"Hacl.Impl.Curve25519.Field51.as_nat",
"Spec.Curve25519.prime",
"Spec.Curve25519.elem"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fevalh: h:mem -> f:felem -> GTot P.elem | [] | Hacl.Impl.Curve25519.Field51.fevalh | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Curve25519.Field51.felem
-> Prims.GTot Spec.Curve25519.elem | {
"end_col": 39,
"end_line": 45,
"start_col": 17,
"start_line": 45
} |
Prims.GTot | val wide_as_nat: h:mem -> e:felem_wide -> GTot nat | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4) | val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e = | false | null | false | let s = as_seq h e in
let s0 = s.[ 0 ] in
let s1 = s.[ 1 ] in
let s2 = s.[ 2 ] in
let s3 = s.[ 3 ] in
let s4 = s.[ 4 ] in
S.wide_as_nat5 (s0, s1, s2, s3, s4) | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Field51.felem_wide",
"Hacl.Spec.Curve25519.Field51.Definition.wide_as_nat5",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.uint128",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Prims.eq2",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Sequence.op_String_Access",
"FStar.UInt32.__uint_to_t",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.nat"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val wide_as_nat: h:mem -> e:felem_wide -> GTot nat | [] | Hacl.Impl.Curve25519.Field51.wide_as_nat | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.Impl.Curve25519.Field51.felem_wide
-> Prims.GTot Prims.nat | {
"end_col": 37,
"end_line": 41,
"start_col": 21,
"start_line": 34
} |
Prims.Tot | val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0 | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m | val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m = | false | null | false | let s = as_seq h f in
let s0 = s.[ 0 ] in
let s1 = s.[ 1 ] in
let s2 = s.[ 2 ] in
let s3 = s.[ 3 ] in
let s4 = s.[ 4 ] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Field51.felem_wide",
"Hacl.Spec.Curve25519.Field51.Definition.scale128_5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.uint128",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Prims.eq2",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Sequence.op_String_Access",
"FStar.UInt32.__uint_to_t",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract | false | true | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0 | [] | Hacl.Impl.Curve25519.Field51.felem_wide_fits | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Field51.felem_wide ->
m: Hacl.Spec.Curve25519.Field51.Definition.scale128_5
-> Type0 | {
"end_col": 43,
"end_line": 64,
"start_col": 27,
"start_line": 57
} |
FStar.HyperStack.ST.Stack | val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0 | val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f = | true | null | false | f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0 | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [] | [
"Hacl.Impl.Curve25519.Field51.felem",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Prims.unit"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0) | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0) | [] | Hacl.Impl.Curve25519.Field51.set_zero | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Impl.Curve25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 18,
"end_line": 95,
"start_col": 2,
"start_line": 91
} |
FStar.HyperStack.ST.Stack | val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0 | val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f = | true | null | false | f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0 | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [] | [
"Hacl.Impl.Curve25519.Field51.felem",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Prims.unit"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1) | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1) | [] | Hacl.Impl.Curve25519.Field51.set_one | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Impl.Curve25519.Field51.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 18,
"end_line": 109,
"start_col": 2,
"start_line": 105
} |
Prims.Tot | val fsqr: C.(fsqr_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsqr out f _ =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (o0,o1,o2,o3,o4) = fsqr5 (f0,f1,f2,f3,f4) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4 | val fsqr: C.(fsqr_t M51 True)
let fsqr out f _ = | false | null | false | let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let o0, o1, o2, o3, o4 = fsqr5 (f0, f1, f2, f3, f4) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4 | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide",
"Lib.IntTypes.uint64",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.mul_inv_t",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Spec.Curve25519.fmul",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.fsqr5",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True)
[@ CInline]
let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fmul2: C.(fmul2_t M51 True)
#set-options "--z3rlimit 100"
[@ CInline]
let fmul2 out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let ((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) =
fmul25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24)
(f30,f31,f32,f33,f34) (f40,f41,f42,f43,f44) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
val fmul1: C.(fmul1_t M51 True)
[@ CInline]
let fmul1 out f1 f2 =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let (o0,o1,o2,o3,o4) = fmul15 (f10,f11,f12,f13,f14) f2 in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr: C.(fsqr_t M51 True) | false | true | Hacl.Impl.Curve25519.Field51.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 fsqr: C.(fsqr_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.fsqr | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fsqr_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 17,
"end_line": 274,
"start_col": 18,
"start_line": 263
} |
FStar.HyperStack.ST.StackInline | val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create_felem () = create 5ul (u64 0) | val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = | true | null | false | create 5ul (u64 0) | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [] | [
"Prims.unit",
"Lib.Buffer.create",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Field51.felem"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\ | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0) | [] | Hacl.Impl.Curve25519.Field51.create_felem | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> FStar.HyperStack.ST.StackInline Hacl.Impl.Curve25519.Field51.felem | {
"end_col": 40,
"end_line": 81,
"start_col": 22,
"start_line": 81
} |
Prims.Tot | val fmul1: C.(fmul1_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul1 out f1 f2 =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let (o0,o1,o2,o3,o4) = fmul15 (f10,f11,f12,f13,f14) f2 in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4 | val fmul1: C.(fmul1_t M51 True)
let fmul1 out f1 f2 = | false | null | false | let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let o0, o1, o2, o3, o4 = fmul15 (f10, f11, f12, f13, f14) f2 in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4 | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Lib.IntTypes.uint64",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.fmul15",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True)
[@ CInline]
let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fmul2: C.(fmul2_t M51 True)
#set-options "--z3rlimit 100"
[@ CInline]
let fmul2 out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let ((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) =
fmul25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24)
(f30,f31,f32,f33,f34) (f40,f41,f42,f43,f44) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
val fmul1: C.(fmul1_t M51 True) | false | true | Hacl.Impl.Curve25519.Field51.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 fmul1: C.(fmul1_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.fmul1 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fmul1_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 17,
"end_line": 259,
"start_col": 21,
"start_line": 248
} |
Prims.Tot | val fsub: C.(fsub_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) | val fsub: C.(fsub_t M51 True)
let fsub out f1 f2 = | false | null | false | let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Spec.Curve25519.Field51.lemma_fsub",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.uint64",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.u64",
"Lib.IntTypes.int_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True) | false | true | Hacl.Impl.Curve25519.Field51.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsub: C.(fsub_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.fsub | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fsub_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 64,
"end_line": 176,
"start_col": 20,
"start_line": 160
} |
FStar.HyperStack.ST.Stack | val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2) | val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 = | true | null | false | f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2) | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [] | [
"Hacl.Impl.Curve25519.Field51.felem",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.uint64",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.op_Array_Access"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2) | false | false | Hacl.Impl.Curve25519.Field51.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2) | [] | Hacl.Impl.Curve25519.Field51.copy_felem | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f1: Hacl.Impl.Curve25519.Field51.felem -> f2: Hacl.Impl.Curve25519.Field51.felem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 45,
"end_line": 128,
"start_col": 2,
"start_line": 122
} |
FStar.HyperStack.ST.Stack | val load_felem:
f:felem
-> u64s:lbuffer uint64 4ul
-> Stack unit
(requires fun h ->
live h u64s /\ live h f /\ disjoint u64s f /\
v (as_seq h u64s).[3] < pow2 63)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
//felem_fits h1 f (1, 1, 1, 1, 1) /\
mul_inv_t h1 f /\
as_nat h1 f == BSeq.nat_from_intseq_le (as_seq h0 u64s)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_felem f u64s =
let h0 = ST.get () in
let f0l = u64s.(0ul) &. S.mask51 in
let f0h = u64s.(0ul) >>. 51ul in
let f1l = ((u64s.(1ul) &. u64 0x3fffffffff)) <<. 13ul in
let f1h = u64s.(1ul) >>. 38ul in
let f2l = (u64s.(2ul) &. u64 0x1ffffff) <<. 26ul in
let f2h = u64s.(2ul) >>. 25ul in
let f3l = (u64s.(3ul) &. u64 0xfff) <<. 39ul in
let f3h = u64s.(3ul) >>. 12ul in
f.(0ul) <- f0l;
f.(1ul) <- f0h |. f1l;
f.(2ul) <- f1h |. f2l;
f.(3ul) <- f2h |. f3l;
f.(4ul) <- f3h;
Lemmas.lemma_load_felem (as_seq h0 u64s) | val load_felem:
f:felem
-> u64s:lbuffer uint64 4ul
-> Stack unit
(requires fun h ->
live h u64s /\ live h f /\ disjoint u64s f /\
v (as_seq h u64s).[3] < pow2 63)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
//felem_fits h1 f (1, 1, 1, 1, 1) /\
mul_inv_t h1 f /\
as_nat h1 f == BSeq.nat_from_intseq_le (as_seq h0 u64s))
let load_felem f u64s = | true | null | false | let h0 = ST.get () in
let f0l = u64s.(0ul) &. S.mask51 in
let f0h = u64s.(0ul) >>. 51ul in
let f1l = ((u64s.(1ul) &. u64 0x3fffffffff)) <<. 13ul in
let f1h = u64s.(1ul) >>. 38ul in
let f2l = (u64s.(2ul) &. u64 0x1ffffff) <<. 26ul in
let f2h = u64s.(2ul) >>. 25ul in
let f3l = (u64s.(3ul) &. u64 0xfff) <<. 39ul in
let f3h = u64s.(3ul) >>. 12ul in
f.(0ul) <- f0l;
f.(1ul) <- f0h |. f1l;
f.(2ul) <- f1h |. f2l;
f.(3ul) <- f2h |. f3l;
f.(4ul) <- f3h;
Lemmas.lemma_load_felem (as_seq h0 u64s) | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [] | [
"Hacl.Impl.Curve25519.Field51.felem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_load_felem",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.Buffer.op_Array_Access",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.u64",
"Hacl.Spec.Curve25519.Field51.Definition.mask51",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True)
[@ CInline]
let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fmul2: C.(fmul2_t M51 True)
#set-options "--z3rlimit 100"
[@ CInline]
let fmul2 out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let ((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) =
fmul25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24)
(f30,f31,f32,f33,f34) (f40,f41,f42,f43,f44) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
val fmul1: C.(fmul1_t M51 True)
[@ CInline]
let fmul1 out f1 f2 =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let (o0,o1,o2,o3,o4) = fmul15 (f10,f11,f12,f13,f14) f2 in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr: C.(fsqr_t M51 True)
[@ CInline]
let fsqr out f _ =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (o0,o1,o2,o3,o4) = fsqr5 (f0,f1,f2,f3,f4) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr2: C.(fsqr2_t M51 True)
[@ CInline]
let fsqr2 out f _ =
let f10 = f.(0ul) in
let f11 = f.(1ul) in
let f12 = f.(2ul) in
let f13 = f.(3ul) in
let f14 = f.(4ul) in
let f20 = f.(5ul) in
let f21 = f.(6ul) in
let f22 = f.(7ul) in
let f23 = f.(8ul) in
let f24 = f.(9ul) in
let ((o10,o11,o12,o13,o14),(o20,o21,o22,o23,o24)) =
fsqr25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
inline_for_extraction noextract
val load_felem:
f:felem
-> u64s:lbuffer uint64 4ul
-> Stack unit
(requires fun h ->
live h u64s /\ live h f /\ disjoint u64s f /\
v (as_seq h u64s).[3] < pow2 63)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
//felem_fits h1 f (1, 1, 1, 1, 1) /\
mul_inv_t h1 f /\ | false | false | Hacl.Impl.Curve25519.Field51.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 load_felem:
f:felem
-> u64s:lbuffer uint64 4ul
-> Stack unit
(requires fun h ->
live h u64s /\ live h f /\ disjoint u64s f /\
v (as_seq h u64s).[3] < pow2 63)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
//felem_fits h1 f (1, 1, 1, 1, 1) /\
mul_inv_t h1 f /\
as_nat h1 f == BSeq.nat_from_intseq_le (as_seq h0 u64s)) | [] | Hacl.Impl.Curve25519.Field51.load_felem | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Impl.Curve25519.Field51.felem -> u64s: Lib.Buffer.lbuffer Lib.IntTypes.uint64 4ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 42,
"end_line": 333,
"start_col": 23,
"start_line": 318
} |
Prims.Tot | val fadd: C.(fadd_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime | val fadd: C.(fadd_t M51 True)
let fadd out f1 f2 = | false | null | false | let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r (as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"Prims.op_Modulus",
"Hacl.Impl.Curve25519.Field51.as_nat",
"Spec.Curve25519.prime",
"Prims.unit",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True) | false | true | Hacl.Impl.Curve25519.Field51.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fadd: C.(fadd_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.fadd | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fadd_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 51,
"end_line": 156,
"start_col": 20,
"start_line": 134
} |
Prims.Tot | val cswap2: C.(cswap2_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cswap2 bit p1 p2 =
let h0 = ST.get () in
let mask = u64 0 -. bit in
[@ inline_let]
let inv h1 (i:nat{i <= 10}) =
(forall (k:nat{k < i}).
if v bit = 1
then (as_seq h1 p1).[k] == (as_seq h0 p2).[k] /\ (as_seq h1 p2).[k] == (as_seq h0 p1).[k]
else (as_seq h1 p1).[k] == (as_seq h0 p1).[k] /\ (as_seq h1 p2).[k] == (as_seq h0 p2).[k]) /\
(forall (k:nat{i <= k /\ k < 10}).
(as_seq h1 p1).[k] == (as_seq h0 p1).[k] /\ (as_seq h1 p2).[k] == (as_seq h0 p2).[k]) /\
modifies (loc p1 |+| loc p2) h0 h1 in
Lib.Loops.for 0ul 10ul inv
(fun i ->
let dummy = mask &. (p1.(i) ^. p2.(i)) in
p1.(i) <- p1.(i) ^. dummy;
p2.(i) <- p2.(i) ^. dummy;
Lemmas.lemma_cswap2_step bit ((as_seq h0 p1).[v i]) ((as_seq h0 p2).[v i])
);
let h1 = ST.get () in
Lib.Sequence.eq_intro (as_seq h1 p1) (if v bit = 1 then as_seq h0 p2 else as_seq h0 p1);
Lib.Sequence.eq_intro (as_seq h1 p2) (if v bit = 1 then as_seq h0 p1 else as_seq h0 p2) | val cswap2: C.(cswap2_t M51 True)
let cswap2 bit p1 p2 = | false | null | false | let h0 = ST.get () in
let mask = u64 0 -. bit in
[@@ inline_let ]let inv h1 (i: nat{i <= 10}) =
(forall (k: nat{k < i}).
if v bit = 1
then
(as_seq h1 p1).[ k ] == (as_seq h0 p2).[ k ] /\ (as_seq h1 p2).[ k ] == (as_seq h0 p1).[ k ]
else
(as_seq h1 p1).[ k ] == (as_seq h0 p1).[ k ] /\ (as_seq h1 p2).[ k ] == (as_seq h0 p2).[ k ]
) /\
(forall (k: nat{i <= k /\ k < 10}).
(as_seq h1 p1).[ k ] == (as_seq h0 p1).[ k ] /\ (as_seq h1 p2).[ k ] == (as_seq h0 p2).[ k ]) /\
modifies (loc p1 |+| loc p2) h0 h1
in
Lib.Loops.for 0ul
10ul
inv
(fun i ->
let dummy = mask &. (p1.(i) ^. p2.(i)) in
p1.(i) <- p1.(i) ^. dummy;
p2.(i) <- p2.(i) ^. dummy;
Lemmas.lemma_cswap2_step bit ((as_seq h0 p1).[ v i ]) ((as_seq h0 p2).[ v i ]));
let h1 = ST.get () in
Lib.Sequence.eq_intro (as_seq h1 p1) (if v bit = 1 then as_seq h0 p2 else as_seq h0 p1);
Lib.Sequence.eq_intro (as_seq h1 p2) (if v bit = 1 then as_seq h0 p1 else as_seq h0 p2) | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint64",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Lib.Sequence.eq_intro",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Lib.Sequence.lseq",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Loops.for",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.op_LessThan",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_cswap2_step",
"Lib.Sequence.op_String_Access",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Hat_Dot",
"Lib.Buffer.op_Array_Access",
"Lib.IntTypes.op_Amp_Dot",
"Prims.nat",
"Prims.logical",
"Prims.l_Forall",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True)
[@ CInline]
let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fmul2: C.(fmul2_t M51 True)
#set-options "--z3rlimit 100"
[@ CInline]
let fmul2 out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let ((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) =
fmul25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24)
(f30,f31,f32,f33,f34) (f40,f41,f42,f43,f44) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
val fmul1: C.(fmul1_t M51 True)
[@ CInline]
let fmul1 out f1 f2 =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let (o0,o1,o2,o3,o4) = fmul15 (f10,f11,f12,f13,f14) f2 in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr: C.(fsqr_t M51 True)
[@ CInline]
let fsqr out f _ =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (o0,o1,o2,o3,o4) = fsqr5 (f0,f1,f2,f3,f4) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr2: C.(fsqr2_t M51 True)
[@ CInline]
let fsqr2 out f _ =
let f10 = f.(0ul) in
let f11 = f.(1ul) in
let f12 = f.(2ul) in
let f13 = f.(3ul) in
let f14 = f.(4ul) in
let f20 = f.(5ul) in
let f21 = f.(6ul) in
let f22 = f.(7ul) in
let f23 = f.(8ul) in
let f24 = f.(9ul) in
let ((o10,o11,o12,o13,o14),(o20,o21,o22,o23,o24)) =
fsqr25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
inline_for_extraction noextract
val load_felem:
f:felem
-> u64s:lbuffer uint64 4ul
-> Stack unit
(requires fun h ->
live h u64s /\ live h f /\ disjoint u64s f /\
v (as_seq h u64s).[3] < pow2 63)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
//felem_fits h1 f (1, 1, 1, 1, 1) /\
mul_inv_t h1 f /\
as_nat h1 f == BSeq.nat_from_intseq_le (as_seq h0 u64s))
let load_felem f u64s =
let h0 = ST.get () in
let f0l = u64s.(0ul) &. S.mask51 in
let f0h = u64s.(0ul) >>. 51ul in
let f1l = ((u64s.(1ul) &. u64 0x3fffffffff)) <<. 13ul in
let f1h = u64s.(1ul) >>. 38ul in
let f2l = (u64s.(2ul) &. u64 0x1ffffff) <<. 26ul in
let f2h = u64s.(2ul) >>. 25ul in
let f3l = (u64s.(3ul) &. u64 0xfff) <<. 39ul in
let f3h = u64s.(3ul) >>. 12ul in
f.(0ul) <- f0l;
f.(1ul) <- f0h |. f1l;
f.(2ul) <- f1h |. f2l;
f.(3ul) <- f2h |. f3l;
f.(4ul) <- f3h;
Lemmas.lemma_load_felem (as_seq h0 u64s)
val store_felem:
u64s:lbuffer uint64 4ul
-> f:felem
-> Stack unit
(requires fun h ->
live h f /\ live h u64s /\ mul_inv_t h f)
(ensures fun h0 _ h1 ->
modifies (loc u64s) h0 h1 /\
as_seq h1 u64s == BSeq.nat_to_intseq_le 4 (fevalh h0 f))
let store_felem u64s f =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (o0, o1, o2, o3) = store_felem5 (f0, f1, f2, f3, f4) in
u64s.(0ul) <- o0;
u64s.(1ul) <- o1;
u64s.(2ul) <- o2;
u64s.(3ul) <- o3;
let h1 = ST.get () in
Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4 (as_seq h1 u64s);
BSeq.lemma_nat_from_to_intseq_le_preserves_value 4 (as_seq h1 u64s)
val cswap2: C.(cswap2_t M51 True) | false | true | Hacl.Impl.Curve25519.Field51.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 cswap2: C.(cswap2_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.cswap2 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.cswap2_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 89,
"end_line": 384,
"start_col": 22,
"start_line": 361
} |
FStar.HyperStack.ST.Stack | val store_felem:
u64s:lbuffer uint64 4ul
-> f:felem
-> Stack unit
(requires fun h ->
live h f /\ live h u64s /\ mul_inv_t h f)
(ensures fun h0 _ h1 ->
modifies (loc u64s) h0 h1 /\
as_seq h1 u64s == BSeq.nat_to_intseq_le 4 (fevalh h0 f)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_felem u64s f =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (o0, o1, o2, o3) = store_felem5 (f0, f1, f2, f3, f4) in
u64s.(0ul) <- o0;
u64s.(1ul) <- o1;
u64s.(2ul) <- o2;
u64s.(3ul) <- o3;
let h1 = ST.get () in
Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4 (as_seq h1 u64s);
BSeq.lemma_nat_from_to_intseq_le_preserves_value 4 (as_seq h1 u64s) | val store_felem:
u64s:lbuffer uint64 4ul
-> f:felem
-> Stack unit
(requires fun h ->
live h f /\ live h u64s /\ mul_inv_t h f)
(ensures fun h0 _ h1 ->
modifies (loc u64s) h0 h1 /\
as_seq h1 u64s == BSeq.nat_to_intseq_le 4 (fevalh h0 f))
let store_felem u64s f = | true | null | false | let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let o0, o1, o2, o3 = store_felem5 (f0, f1, f2, f3, f4) in
u64s.(0ul) <- o0;
u64s.(1ul) <- o1;
u64s.(2ul) <- o2;
u64s.(3ul) <- o3;
let h1 = ST.get () in
Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4 (as_seq h1 u64s);
BSeq.lemma_nat_from_to_intseq_le_preserves_value 4 (as_seq h1 u64s) | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Curve25519.Field51.felem",
"Lib.ByteSequence.lemma_nat_from_to_intseq_le_preserves_value",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.int_t",
"Hacl.Spec.Curve25519.Field51.store_felem5",
"FStar.Pervasives.Native.Mktuple5",
"Lib.Buffer.op_Array_Access"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True)
[@ CInline]
let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fmul2: C.(fmul2_t M51 True)
#set-options "--z3rlimit 100"
[@ CInline]
let fmul2 out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let ((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) =
fmul25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24)
(f30,f31,f32,f33,f34) (f40,f41,f42,f43,f44) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
val fmul1: C.(fmul1_t M51 True)
[@ CInline]
let fmul1 out f1 f2 =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let (o0,o1,o2,o3,o4) = fmul15 (f10,f11,f12,f13,f14) f2 in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr: C.(fsqr_t M51 True)
[@ CInline]
let fsqr out f _ =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (o0,o1,o2,o3,o4) = fsqr5 (f0,f1,f2,f3,f4) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr2: C.(fsqr2_t M51 True)
[@ CInline]
let fsqr2 out f _ =
let f10 = f.(0ul) in
let f11 = f.(1ul) in
let f12 = f.(2ul) in
let f13 = f.(3ul) in
let f14 = f.(4ul) in
let f20 = f.(5ul) in
let f21 = f.(6ul) in
let f22 = f.(7ul) in
let f23 = f.(8ul) in
let f24 = f.(9ul) in
let ((o10,o11,o12,o13,o14),(o20,o21,o22,o23,o24)) =
fsqr25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
inline_for_extraction noextract
val load_felem:
f:felem
-> u64s:lbuffer uint64 4ul
-> Stack unit
(requires fun h ->
live h u64s /\ live h f /\ disjoint u64s f /\
v (as_seq h u64s).[3] < pow2 63)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
//felem_fits h1 f (1, 1, 1, 1, 1) /\
mul_inv_t h1 f /\
as_nat h1 f == BSeq.nat_from_intseq_le (as_seq h0 u64s))
let load_felem f u64s =
let h0 = ST.get () in
let f0l = u64s.(0ul) &. S.mask51 in
let f0h = u64s.(0ul) >>. 51ul in
let f1l = ((u64s.(1ul) &. u64 0x3fffffffff)) <<. 13ul in
let f1h = u64s.(1ul) >>. 38ul in
let f2l = (u64s.(2ul) &. u64 0x1ffffff) <<. 26ul in
let f2h = u64s.(2ul) >>. 25ul in
let f3l = (u64s.(3ul) &. u64 0xfff) <<. 39ul in
let f3h = u64s.(3ul) >>. 12ul in
f.(0ul) <- f0l;
f.(1ul) <- f0h |. f1l;
f.(2ul) <- f1h |. f2l;
f.(3ul) <- f2h |. f3l;
f.(4ul) <- f3h;
Lemmas.lemma_load_felem (as_seq h0 u64s)
val store_felem:
u64s:lbuffer uint64 4ul
-> f:felem
-> Stack unit
(requires fun h ->
live h f /\ live h u64s /\ mul_inv_t h f)
(ensures fun h0 _ h1 ->
modifies (loc u64s) h0 h1 /\ | false | false | Hacl.Impl.Curve25519.Field51.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 store_felem:
u64s:lbuffer uint64 4ul
-> f:felem
-> Stack unit
(requires fun h ->
live h f /\ live h u64s /\ mul_inv_t h f)
(ensures fun h0 _ h1 ->
modifies (loc u64s) h0 h1 /\
as_seq h1 u64s == BSeq.nat_to_intseq_le 4 (fevalh h0 f)) | [] | Hacl.Impl.Curve25519.Field51.store_felem | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | u64s: Lib.Buffer.lbuffer Lib.IntTypes.uint64 4ul -> f: Hacl.Impl.Curve25519.Field51.felem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 69,
"end_line": 357,
"start_col": 24,
"start_line": 344
} |
Prims.Tot | val fmul: C.(fmul_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4 | val fmul: C.(fmul_t M51 True)
let fmul out f1 f2 _ = | false | null | false | let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let o0, o1, o2, o3, o4 = fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4 | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Lib.IntTypes.uint64",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.mul_inv_t",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Spec.Curve25519.fmul",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.fmul5",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True) | false | true | Hacl.Impl.Curve25519.Field51.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul: C.(fmul_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.fmul | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fmul_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 17,
"end_line": 199,
"start_col": 22,
"start_line": 180
} |
Prims.Tot | val fsqr2: C.(fsqr2_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsqr2 out f _ =
let f10 = f.(0ul) in
let f11 = f.(1ul) in
let f12 = f.(2ul) in
let f13 = f.(3ul) in
let f14 = f.(4ul) in
let f20 = f.(5ul) in
let f21 = f.(6ul) in
let f22 = f.(7ul) in
let f23 = f.(8ul) in
let f24 = f.(9ul) in
let ((o10,o11,o12,o13,o14),(o20,o21,o22,o23,o24)) =
fsqr25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24 | val fsqr2: C.(fsqr2_t M51 True)
let fsqr2 out f _ = | false | null | false | let f10 = f.(0ul) in
let f11 = f.(1ul) in
let f12 = f.(2ul) in
let f13 = f.(3ul) in
let f14 = f.(4ul) in
let f20 = f.(5ul) in
let f21 = f.(6ul) in
let f22 = f.(7ul) in
let f23 = f.(8ul) in
let f24 = f.(9ul) in
let (o10, o11, o12, o13, o14), (o20, o21, o22, o23, o24) =
fsqr25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24 | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Lib.IntTypes.uint64",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.fsqr25",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True)
[@ CInline]
let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fmul2: C.(fmul2_t M51 True)
#set-options "--z3rlimit 100"
[@ CInline]
let fmul2 out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let ((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) =
fmul25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24)
(f30,f31,f32,f33,f34) (f40,f41,f42,f43,f44) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24
val fmul1: C.(fmul1_t M51 True)
[@ CInline]
let fmul1 out f1 f2 =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let (o0,o1,o2,o3,o4) = fmul15 (f10,f11,f12,f13,f14) f2 in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr: C.(fsqr_t M51 True)
[@ CInline]
let fsqr out f _ =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (o0,o1,o2,o3,o4) = fsqr5 (f0,f1,f2,f3,f4) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fsqr2: C.(fsqr2_t M51 True) | false | true | Hacl.Impl.Curve25519.Field51.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 fsqr2: C.(fsqr2_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.fsqr2 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fsqr2_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 18,
"end_line": 303,
"start_col": 19,
"start_line": 278
} |
Prims.Tot | val fmul2: C.(fmul2_t M51 True) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul2 out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let ((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) =
fmul25 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24)
(f30,f31,f32,f33,f34) (f40,f41,f42,f43,f44) in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24 | val fmul2: C.(fmul2_t M51 True)
let fmul2 out f1 f2 _ = | false | null | false | let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let f30 = f1.(5ul) in
let f31 = f1.(6ul) in
let f32 = f1.(7ul) in
let f33 = f1.(8ul) in
let f34 = f1.(9ul) in
let f40 = f2.(5ul) in
let f41 = f2.(6ul) in
let f42 = f2.(7ul) in
let f43 = f2.(8ul) in
let f44 = f2.(9ul) in
let (o10, o11, o12, o13, o14), (o20, o21, o22, o23, o24) =
fmul25 (f10, f11, f12, f13, f14)
(f20, f21, f22, f23, f24)
(f30, f31, f32, f33, f34)
(f40, f41, f42, f43, f44)
in
out.(0ul) <- o10;
out.(1ul) <- o11;
out.(2ul) <- o12;
out.(3ul) <- o13;
out.(4ul) <- o14;
out.(5ul) <- o20;
out.(6ul) <- o21;
out.(7ul) <- o22;
out.(8ul) <- o23;
out.(9ul) <- o24 | {
"checked_file": "Hacl.Impl.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Lemmas.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Lib.IntTypes.uint64",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.fmul25",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Impl.Curve25519.Field51
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Curve25519.Field51
include Hacl.Spec.Curve25519.Field51.Definition
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.Field51.Definition
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Lemmas = Hacl.Spec.Curve25519.Field51.Lemmas
module C = Hacl.Impl.Curve25519.Fields.Core
#reset-options "--z3rlimit 20"
let felem = lbuffer uint64 5ul
let felem2 = lbuffer uint64 10ul
let felem_wide = lbuffer uint128 5ul
noextract
let as_nat = C.f51_as_nat
noextract
val wide_as_nat: h:mem -> e:felem_wide -> GTot nat
let wide_as_nat h e =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.wide_as_nat5 (s0, s1, s2, s3, s4)
noextract
val fevalh: h:mem -> f:felem -> GTot P.elem
let fevalh h f = (as_nat h f) % P.prime
noextract
val feval_wideh: h:mem -> f:felem_wide -> GTot P.elem
let feval_wideh h f = (wide_as_nat h f) % P.prime
noextract
let felem_fits =
C.f51_felem_fits
noextract
val felem_wide_fits: h:mem -> f:felem_wide -> m:S.scale128_5 -> Type0
let felem_wide_fits h f m =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
S.felem_wide_fits5 (s0, s1, s2, s3, s4) m
noextract
let as_felem =
C.f51_as_felem
noextract
let mul_inv_t =
C.f51_mul_inv_t
inline_for_extraction noextract
val create_felem: unit
-> StackInline felem
(requires fun _ -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 5 (u64 0)) /\
as_nat h1 f == 0)
let create_felem () = create 5ul (u64 0)
inline_for_extraction noextract
val set_zero:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 0)
let set_zero f =
f.(0ul) <- u64 0;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val set_one:
f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
as_nat h1 f == 1)
let set_one f =
f.(0ul) <- u64 1;
f.(1ul) <- u64 0;
f.(2ul) <- u64 0;
f.(3ul) <- u64 0;
f.(4ul) <- u64 0
inline_for_extraction noextract
val copy_felem:
f1:felem
-> f2:felem
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_seq h1 f1 == as_seq h0 f2)
let copy_felem f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul);
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 f1) (as_seq h1 f2)
#set-options "--max_fuel 0 --max_ifuel 0"
val fadd: C.(fadd_t M51 True)
[@ CInline]
let fadd out f1 f2 =
let h0 = ST.get () in
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! f20;
out.(1ul) <- f11 +! f21;
out.(2ul) <- f12 +! f22;
out.(3ul) <- f13 +! f23;
out.(4ul) <- f14 +! f24;
let h1 = ST.get () in
assert (as_nat h1 out == as_nat h0 f1 + as_nat h0 f2);
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat h0 f1) (as_nat h0 f2) P.prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat h0 f1 % P.prime) (as_nat h0 f2) P.prime
val fsub: C.(fsub_t M51 True)
[@ CInline]
let fsub out f1 f2 =
let f10 = f1.(0ul) in
let f20 = f2.(0ul) in
let f11 = f1.(1ul) in
let f21 = f2.(1ul) in
let f12 = f1.(2ul) in
let f22 = f2.(2ul) in
let f13 = f1.(3ul) in
let f23 = f2.(3ul) in
let f14 = f1.(4ul) in
let f24 = f2.(4ul) in
out.(0ul) <- f10 +! u64 0x3fffffffffff68 -! f20;
out.(1ul) <- f11 +! u64 0x3ffffffffffff8 -! f21;
out.(2ul) <- f12 +! u64 0x3ffffffffffff8 -! f22;
out.(3ul) <- f13 +! u64 0x3ffffffffffff8 -! f23;
out.(4ul) <- f14 +! u64 0x3ffffffffffff8 -! f24;
lemma_fsub (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24)
val fmul: C.(fmul_t M51 True)
[@ CInline]
let fmul out f1 f2 _ =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fmul5 (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
val fmul2: C.(fmul2_t M51 True)
#set-options "--z3rlimit 100" | false | true | Hacl.Impl.Curve25519.Field51.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 fmul2: C.(fmul2_t M51 True) | [] | Hacl.Impl.Curve25519.Field51.fmul2 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.Curve25519.Fields.Core.fmul2_t Hacl.Impl.Curve25519.Fields.Core.M51 Prims.l_True | {
"end_col": 18,
"end_line": 244,
"start_col": 23,
"start_line": 205
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha224_init4 = init #SHA2_224 #M128 | let sha224_init4 = | false | null | false | init #SHA2_224 #M128 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.init",
"Spec.Hash.Definitions.SHA2_224",
"Hacl.Spec.SHA2.Vec.M128"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha224_init4 : Hacl.Impl.SHA2.Generic.init_vec_t Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha224_init4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.init_vec_t Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 58,
"end_line": 23,
"start_col": 38,
"start_line": 23
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_init4 = init #SHA2_256 #M128 | let sha256_init4 = | false | null | false | init #SHA2_256 #M128 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.init",
"Spec.Hash.Definitions.SHA2_256",
"Hacl.Spec.SHA2.Vec.M128"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_finish4 = finish #SHA2_224 #M128
val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3))
let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224 #M128 sha224_init4 sha224_update_nblocks4 sha224_update_last4 sha224_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3) | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha256_init4 : Hacl.Impl.SHA2.Generic.init_vec_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha256_init4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.init_vec_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 58,
"end_line": 59,
"start_col": 38,
"start_line": 59
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4 | let sha224_update_nblocks4 = | false | null | false | update_nblocks #SHA2_224 #M128 sha224_update4 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.update_nblocks",
"Spec.Hash.Definitions.SHA2_224",
"Hacl.Spec.SHA2.Vec.M128",
"Hacl.SHA2.Vec128.sha224_update4"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128 | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha224_update_nblocks4 : Hacl.Impl.SHA2.Generic.update_nblocks_vec_t' Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha224_update_nblocks4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.update_nblocks_vec_t' Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 93,
"end_line": 25,
"start_col": 48,
"start_line": 25
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha224_finish4 = finish #SHA2_224 #M128 | let sha224_finish4 = | false | null | false | finish #SHA2_224 #M128 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.finish",
"Spec.Hash.Definitions.SHA2_224",
"Hacl.Spec.SHA2.Vec.M128"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4 | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha224_finish4 : Hacl.Impl.SHA2.Generic.finish_vec_t Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha224_finish4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.finish_vec_t Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 62,
"end_line": 27,
"start_col": 40,
"start_line": 27
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha224_update4 = update #SHA2_224 #M128 | let sha224_update4 = | false | null | false | update #SHA2_224 #M128 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.update",
"Spec.Hash.Definitions.SHA2_224",
"Hacl.Spec.SHA2.Vec.M128"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha224_update4 : Hacl.Impl.SHA2.Generic.update_vec_t Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha224_update4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.update_vec_t Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 62,
"end_line": 24,
"start_col": 40,
"start_line": 24
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4 | let sha224_update_last4 = | false | null | false | update_last #SHA2_224 #M128 sha224_update4 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.update_last",
"Spec.Hash.Definitions.SHA2_224",
"Hacl.Spec.SHA2.Vec.M128",
"Hacl.SHA2.Vec128.sha224_update4"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128 | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha224_update_last4 : Hacl.Impl.SHA2.Generic.update_last_vec_t' Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha224_update_last4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.update_last_vec_t' Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 87,
"end_line": 26,
"start_col": 45,
"start_line": 26
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_update_last4 = update_last #SHA2_256 #M128 sha256_update4 | let sha256_update_last4 = | false | null | false | update_last #SHA2_256 #M128 sha256_update4 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.update_last",
"Spec.Hash.Definitions.SHA2_256",
"Hacl.Spec.SHA2.Vec.M128",
"Hacl.SHA2.Vec128.sha256_update4"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_finish4 = finish #SHA2_224 #M128
val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3))
let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224 #M128 sha224_init4 sha224_update_nblocks4 sha224_update_last4 sha224_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3)
[@CInline] private let sha256_init4 = init #SHA2_256 #M128
[@CInline] private let sha256_update4 = update #SHA2_256 #M128 | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha256_update_last4 : Hacl.Impl.SHA2.Generic.update_last_vec_t' Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha256_update_last4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.update_last_vec_t' Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 87,
"end_line": 62,
"start_col": 45,
"start_line": 62
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_update_nblocks4 = update_nblocks #SHA2_256 #M128 sha256_update4 | let sha256_update_nblocks4 = | false | null | false | update_nblocks #SHA2_256 #M128 sha256_update4 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.update_nblocks",
"Spec.Hash.Definitions.SHA2_256",
"Hacl.Spec.SHA2.Vec.M128",
"Hacl.SHA2.Vec128.sha256_update4"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_finish4 = finish #SHA2_224 #M128
val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3))
let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224 #M128 sha224_init4 sha224_update_nblocks4 sha224_update_last4 sha224_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3)
[@CInline] private let sha256_init4 = init #SHA2_256 #M128 | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha256_update_nblocks4 : Hacl.Impl.SHA2.Generic.update_nblocks_vec_t' Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha256_update_nblocks4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.update_nblocks_vec_t' Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 93,
"end_line": 61,
"start_col": 48,
"start_line": 61
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_update4 = update #SHA2_256 #M128 | let sha256_update4 = | false | null | false | update #SHA2_256 #M128 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.update",
"Spec.Hash.Definitions.SHA2_256",
"Hacl.Spec.SHA2.Vec.M128"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_finish4 = finish #SHA2_224 #M128
val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3))
let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224 #M128 sha224_init4 sha224_update_nblocks4 sha224_update_last4 sha224_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3) | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha256_update4 : Hacl.Impl.SHA2.Generic.update_vec_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha256_update4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.update_vec_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 62,
"end_line": 60,
"start_col": 40,
"start_line": 60
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_finish4 = finish #SHA2_256 #M128 | let sha256_finish4 = | false | null | false | finish #SHA2_256 #M128 | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [
"total"
] | [
"Hacl.Impl.SHA2.Generic.finish",
"Spec.Hash.Definitions.SHA2_256",
"Hacl.Spec.SHA2.Vec.M128"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_finish4 = finish #SHA2_224 #M128
val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3))
let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224 #M128 sha224_init4 sha224_update_nblocks4 sha224_update_last4 sha224_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3)
[@CInline] private let sha256_init4 = init #SHA2_256 #M128
[@CInline] private let sha256_update4 = update #SHA2_256 #M128
[@CInline] private let sha256_update_nblocks4 = update_nblocks #SHA2_256 #M128 sha256_update4 | false | true | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha256_finish4 : Hacl.Impl.SHA2.Generic.finish_vec_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | [] | Hacl.SHA2.Vec128.sha256_finish4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.SHA2.Generic.finish_vec_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M128 | {
"end_col": 62,
"end_line": 63,
"start_col": 40,
"start_line": 63
} |
|
FStar.HyperStack.ST.Stack | val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224 #M128 sha224_init4 sha224_update_nblocks4 sha224_update_last4 sha224_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3) | val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3))
let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 = | true | null | false | let ib = ntup4 (input0, (input1, (input2, input3))) in
let rb = ntup4 (dst0, (dst1, (dst2, dst3))) in
let h0 = ST.get () in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224
#M128
sha224_init4
sha224_update_nblocks4
sha224_update_last4
sha224_finish4
rb
input_len
ib;
let h1 = ST.get () in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(| 1 |) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(| 2 |) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(| 3 |) == as_seq h1 dst3) | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_len",
"Spec.Hash.Definitions.SHA2_224",
"Lib.MultiBuffer.op_Lens_Access",
"FStar.Seq.Properties.lseq",
"Hacl.Spec.SHA2.Vec.lanes",
"Hacl.Spec.SHA2.Vec.M128",
"Lib.MultiBuffer.as_seq_multi",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Spec.SHA2.Equiv.hash_agile_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.SHA2.Generic.hash",
"Hacl.SHA2.Vec128.sha224_init4",
"Hacl.SHA2.Vec128.sha224_update_nblocks4",
"Hacl.SHA2.Vec128.sha224_update_last4",
"Hacl.SHA2.Vec128.sha224_finish4",
"Lib.MultiBuffer.loc_multi4",
"Lib.MultiBuffer.internally_disjoint",
"Lib.MultiBuffer.live_multi",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.NTuple.ntup4",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_finish4 = finish #SHA2_224 #M128
val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3)) | false | false | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3)) | [] | Hacl.SHA2.Vec128.sha224_4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul ->
dst1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul ->
dst2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul ->
dst3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul ->
input_len: Lib.IntTypes.size_t ->
input0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len ->
input1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len ->
input2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len ->
input3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 55,
"end_line": 56,
"start_col": 72,
"start_line": 42
} |
FStar.HyperStack.ST.Stack | val sha256_4 (dst0 dst1 dst2 dst3: lbuffer uint8 32ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_256 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_256 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_256 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_256 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_256 (as_seq h0 input3)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_256 #M128 sha256_init4 sha256_update_nblocks4 sha256_update_last4 sha256_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3) | val sha256_4 (dst0 dst1 dst2 dst3: lbuffer uint8 32ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_256 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_256 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_256 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_256 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_256 (as_seq h0 input3))
let sha256_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 = | true | null | false | let ib = ntup4 (input0, (input1, (input2, input3))) in
let rb = ntup4 (dst0, (dst1, (dst2, dst3))) in
let h0 = ST.get () in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_256
#M128
sha256_init4
sha256_update_nblocks4
sha256_update_last4
sha256_finish4
rb
input_len
ib;
let h1 = ST.get () in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(| 1 |) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(| 2 |) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(| 3 |) == as_seq h1 dst3) | {
"checked_file": "Hacl.SHA2.Vec128.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.Impl.SHA2.Generic.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.SHA2.Vec128.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_len",
"Spec.Hash.Definitions.SHA2_256",
"Lib.MultiBuffer.op_Lens_Access",
"FStar.Seq.Properties.lseq",
"Hacl.Spec.SHA2.Vec.lanes",
"Hacl.Spec.SHA2.Vec.M128",
"Lib.MultiBuffer.as_seq_multi",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Spec.SHA2.Equiv.hash_agile_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.SHA2.Generic.hash",
"Hacl.SHA2.Vec128.sha256_init4",
"Hacl.SHA2.Vec128.sha256_update_nblocks4",
"Hacl.SHA2.Vec128.sha256_update_last4",
"Hacl.SHA2.Vec128.sha256_finish4",
"Lib.MultiBuffer.loc_multi4",
"Lib.MultiBuffer.internally_disjoint",
"Lib.MultiBuffer.live_multi",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.NTuple.ntup4",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2"
] | [] | module Hacl.SHA2.Vec128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.MultiBuffer
open Spec.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
module Spec = Spec.Agile.Hash
module SpecVec = Hacl.Spec.SHA2.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline] private let sha224_init4 = init #SHA2_224 #M128
[@CInline] private let sha224_update4 = update #SHA2_224 #M128
[@CInline] private let sha224_update_nblocks4 = update_nblocks #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_update_last4 = update_last #SHA2_224 #M128 sha224_update4
[@CInline] private let sha224_finish4 = finish #SHA2_224 #M128
val sha224_4 (dst0 dst1 dst2 dst3: lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3))
let sha224_4 dst0 dst1 dst2 dst3 input_len input0 input1 input2 input3 =
let ib = ntup4 (input0,(input1,(input2,input3))) in
let rb = ntup4 (dst0,(dst1,(dst2,dst3))) in
let h0 = ST.get() in
assert (live_multi h0 ib);
assert (live_multi h0 rb);
assert (internally_disjoint rb);
loc_multi4 rb;
hash #SHA2_224 #M128 sha224_init4 sha224_update_nblocks4 sha224_update_last4 sha224_finish4 rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M128 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0);
assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1);
assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2);
assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3)
[@CInline] private let sha256_init4 = init #SHA2_256 #M128
[@CInline] private let sha256_update4 = update #SHA2_256 #M128
[@CInline] private let sha256_update_nblocks4 = update_nblocks #SHA2_256 #M128 sha256_update4
[@CInline] private let sha256_update_last4 = update_last #SHA2_256 #M128 sha256_update4
[@CInline] private let sha256_finish4 = finish #SHA2_256 #M128
val sha256_4 (dst0 dst1 dst2 dst3: lbuffer uint8 32ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_256 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_256 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_256 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_256 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_256 (as_seq h0 input3)) | false | false | Hacl.SHA2.Vec128.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha256_4 (dst0 dst1 dst2 dst3: lbuffer uint8 32ul) (input_len:size_t) (input0 input1 input2 input3: lbuffer uint8 input_len) :
Stack unit
(requires fun h0 -> v input_len `less_than_max_input_length` SHA2_256 /\
live4 h0 input0 input1 input2 input3 /\
live4 h0 dst0 dst1 dst2 dst3 /\
internally_disjoint4 dst0 dst1 dst2 dst3)
(ensures fun h0 _ h1 -> modifies (loc dst0 |+| loc dst1 |+| loc dst2 |+| loc dst3) h0 h1 /\
as_seq h1 dst0 == Spec.hash SHA2_256 (as_seq h0 input0) /\
as_seq h1 dst1 == Spec.hash SHA2_256 (as_seq h0 input1) /\
as_seq h1 dst2 == Spec.hash SHA2_256 (as_seq h0 input2) /\
as_seq h1 dst3 == Spec.hash SHA2_256 (as_seq h0 input3)) | [] | Hacl.SHA2.Vec128.sha256_4 | {
"file_name": "code/sha2-mb/Hacl.SHA2.Vec128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
dst1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
dst2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
dst3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
input_len: Lib.IntTypes.size_t ->
input0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len ->
input1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len ->
input2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len ->
input3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 55,
"end_line": 91,
"start_col": 72,
"start_line": 77
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let within_bounds sw x = norm (within_bounds' sw x) | let within_bounds sw x = | false | null | false | norm (within_bounds' sw x) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.int",
"FStar.Integers.norm",
"FStar.Integers.within_bounds'"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val within_bounds : sw: FStar.Integers.signed_width -> x: Prims.int -> Type0 | [] | FStar.Integers.within_bounds | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | sw: FStar.Integers.signed_width -> x: Prims.int -> Type0 | {
"end_col": 51,
"end_line": 86,
"start_col": 25,
"start_line": 86
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x | let norm (#a: Type) (x: a) = | false | null | false | norm [iota; delta_attr [`%mark_for_norm]] x | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.iota",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = () | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val norm : x: a -> a | [] | FStar.Integers.norm | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> a | {
"end_col": 70,
"end_line": 24,
"start_col": 27,
"start_line": 24
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cast_ok #from to (x:int_t from) = within_bounds to (v x) | let cast_ok #from to (x: int_t from) = | false | null | false | within_bounds to (v x) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"FStar.Integers.within_bounds",
"FStar.Integers.v"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cast_ok : to: FStar.Integers.signed_width -> x: FStar.Integers.int_t from -> Type0 | [] | FStar.Integers.cast_ok | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | to: FStar.Integers.signed_width -> x: FStar.Integers.int_t from -> Type0 | {
"end_col": 60,
"end_line": 143,
"start_col": 38,
"start_line": 143
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_16 = int_t (Unsigned W16) | let uint_16 = | false | null | false | int_t (Unsigned W16) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Unsigned",
"FStar.Integers.W16"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_16 : Type0 | [] | FStar.Integers.uint_16 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 35,
"end_line": 525,
"start_col": 15,
"start_line": 525
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let f_nat (x:nat) (y:nat) = x + y | let f_nat (x y: nat) = | false | null | false | x + y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.nat",
"FStar.Integers.op_Plus",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
//////////////////////////////////////////////////////////////////////////////// | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val f_nat : x: FStar.Integers.nat -> y: FStar.Integers.nat
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | [] | FStar.Integers.f_nat | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.nat -> y: FStar.Integers.nat
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | {
"end_col": 33,
"end_line": 581,
"start_col": 28,
"start_line": 581
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let f_nat_int_pos (x:nat) (y:int) (z:pos) = x + y + z | let f_nat_int_pos (x: nat) (y: int) (z: pos) = | false | null | false | x + y + z | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.nat",
"FStar.Integers.int",
"FStar.Integers.pos",
"FStar.Integers.op_Plus",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val f_nat_int_pos : x: FStar.Integers.nat -> y: FStar.Integers.int -> z: FStar.Integers.pos
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | [] | FStar.Integers.f_nat_int_pos | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.nat -> y: FStar.Integers.int -> z: FStar.Integers.pos
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | {
"end_col": 53,
"end_line": 582,
"start_col": 44,
"start_line": 582
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat = i:int{ i >= 0 } | let nat = | false | null | false | i: int{i >= 0} | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int",
"Prims.b2t",
"FStar.Integers.op_Greater_Equals",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat : Type0 | [] | FStar.Integers.nat | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 25,
"end_line": 571,
"start_col": 10,
"start_line": 571
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let int_128 = int_t (Signed W128) | let int_128 = | false | null | false | int_t (Signed W128) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.W128"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val int_128 : Type0 | [] | FStar.Integers.int_128 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 33,
"end_line": 557,
"start_col": 14,
"start_line": 557
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let int = int_t (Signed Winfinite) | let int = | false | null | false | int_t (Signed Winfinite) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val int : Type0 | [] | FStar.Integers.int | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 40,
"end_line": 537,
"start_col": 16,
"start_line": 537
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_8 = int_t (Unsigned W8) | let uint_8 = | false | null | false | int_t (Unsigned W8) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Unsigned",
"FStar.Integers.W8"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_8 : Type0 | [] | FStar.Integers.uint_8 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 34,
"end_line": 521,
"start_col": 15,
"start_line": 521
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y)) | let ok
#sw
(op: (int_t (Signed Winfinite) -> int_t (Signed Winfinite) -> int_t (Signed Winfinite)))
(x: int_t sw)
(y: int_t sw)
= | false | null | false | within_bounds sw (op (v x) (v y)) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.within_bounds",
"FStar.Integers.v"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ok : op:
(
_: FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) ->
_: FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite)
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite)) ->
x: FStar.Integers.int_t sw ->
y: FStar.Integers.int_t sw
-> Type0 | [] | FStar.Integers.ok | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
op:
(
_: FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) ->
_: FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite)
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite)) ->
x: FStar.Integers.int_t sw ->
y: FStar.Integers.int_t sw
-> Type0 | {
"end_col": 38,
"end_line": 567,
"start_col": 5,
"start_line": 567
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let j (x:Prims.int) (y:Prims.nat) = x - y | let j (x: Prims.int) (y: Prims.nat) = | false | null | false | x - y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"Prims.int",
"Prims.nat",
"FStar.Integers.op_Subtraction",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y
let f_nat (x:nat) (y:nat) = x + y
let f_nat_int_pos (x:nat) (y:int) (z:pos) = x + y + z
let f_uint_8 (x:uint_8) (y:uint_8{ok (+) x y}) = x + y
let f_int_16 (x:int_16) (y:int_16{ok (+) x y}) = x + y
let g (x:uint_32) (y:uint_32{ok ( * ) y y /\ ok (+) x (y * y)}) = x + y * y
let h (x:Prims.nat) (y:Prims.nat): nat = u x + u y | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val j : x: Prims.int -> y: Prims.nat
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | [] | FStar.Integers.j | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.int -> y: Prims.nat
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | {
"end_col": 41,
"end_line": 588,
"start_col": 36,
"start_line": 588
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pos = i:nat{ 0 < i } | let pos = | false | null | false | i: nat{0 < i} | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.nat",
"Prims.b2t",
"FStar.Integers.op_Less",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pos : Type0 | [] | FStar.Integers.pos | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 24,
"end_line": 575,
"start_col": 10,
"start_line": 575
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_64 = int_t (Unsigned W64) | let uint_64 = | false | null | false | int_t (Unsigned W64) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Unsigned",
"FStar.Integers.W64"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_64 : Type0 | [] | FStar.Integers.uint_64 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 35,
"end_line": 533,
"start_col": 15,
"start_line": 533
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let f_uint_8 (x:uint_8) (y:uint_8{ok (+) x y}) = x + y | let f_uint_8 (x: uint_8) (y: uint_8{ok ( + ) x y}) = | false | null | false | x + y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.uint_8",
"FStar.Integers.ok",
"FStar.Integers.Unsigned",
"FStar.Integers.W8",
"FStar.Integers.op_Plus",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y
let f_nat (x:nat) (y:nat) = x + y | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val f_uint_8 : x: FStar.Integers.uint_8 -> y: FStar.Integers.uint_8{FStar.Integers.ok FStar.Integers.op_Plus x y}
-> FStar.Integers.int_t (FStar.Integers.Unsigned FStar.Integers.W8) | [] | FStar.Integers.f_uint_8 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.uint_8 -> y: FStar.Integers.uint_8{FStar.Integers.ok FStar.Integers.op_Plus x y}
-> FStar.Integers.int_t (FStar.Integers.Unsigned FStar.Integers.W8) | {
"end_col": 54,
"end_line": 583,
"start_col": 49,
"start_line": 583
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_32 = int_t (Unsigned W32) | let uint_32 = | false | null | false | int_t (Unsigned W32) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Unsigned",
"FStar.Integers.W32"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_32 : Type0 | [] | FStar.Integers.uint_32 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 35,
"end_line": 529,
"start_col": 15,
"start_line": 529
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let f_int (x:int) (y:int) = x + y | let f_int (x y: int) = | false | null | false | x + y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int",
"FStar.Integers.op_Plus",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val f_int : x: FStar.Integers.int -> y: FStar.Integers.int
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | [] | FStar.Integers.f_int | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int -> y: FStar.Integers.int
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | {
"end_col": 33,
"end_line": 580,
"start_col": 28,
"start_line": 580
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let int_16 = int_t (Signed W16) | let int_16 = | false | null | false | int_t (Signed W16) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.W16"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val int_16 : Type0 | [] | FStar.Integers.int_16 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 32,
"end_line": 545,
"start_col": 14,
"start_line": 545
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let int_8 = int_t (Signed W8) | let int_8 = | false | null | false | int_t (Signed W8) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.W8"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val int_8 : Type0 | [] | FStar.Integers.int_8 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 31,
"end_line": 541,
"start_col": 14,
"start_line": 541
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let int_32 = int_t (Signed W32) | let int_32 = | false | null | false | int_t (Signed W32) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.W32"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val int_32 : Type0 | [] | FStar.Integers.int_32 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 32,
"end_line": 549,
"start_col": 14,
"start_line": 549
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let int_64 = int_t (Signed W64) | let int_64 = | false | null | false | int_t (Signed W64) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.W64"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val int_64 : Type0 | [] | FStar.Integers.int_64 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 32,
"end_line": 553,
"start_col": 14,
"start_line": 553
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let i (x:Prims.nat) (y:Prims.nat) = x + y | let i (x y: Prims.nat) = | false | null | false | x + y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"Prims.nat",
"FStar.Integers.op_Plus",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y
let f_nat (x:nat) (y:nat) = x + y
let f_nat_int_pos (x:nat) (y:int) (z:pos) = x + y + z
let f_uint_8 (x:uint_8) (y:uint_8{ok (+) x y}) = x + y
let f_int_16 (x:int_16) (y:int_16{ok (+) x y}) = x + y
let g (x:uint_32) (y:uint_32{ok ( * ) y y /\ ok (+) x (y * y)}) = x + y * y | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val i : x: Prims.nat -> y: Prims.nat
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | [] | FStar.Integers.i | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.nat -> y: Prims.nat
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | {
"end_col": 41,
"end_line": 587,
"start_col": 36,
"start_line": 587
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let f_int_16 (x:int_16) (y:int_16{ok (+) x y}) = x + y | let f_int_16 (x: int_16) (y: int_16{ok ( + ) x y}) = | false | null | false | x + y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.int_16",
"FStar.Integers.ok",
"FStar.Integers.Signed",
"FStar.Integers.W16",
"FStar.Integers.op_Plus",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y
let f_nat (x:nat) (y:nat) = x + y
let f_nat_int_pos (x:nat) (y:int) (z:pos) = x + y + z | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val f_int_16 : x: FStar.Integers.int_16 -> y: FStar.Integers.int_16{FStar.Integers.ok FStar.Integers.op_Plus x y}
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.W16) | [] | FStar.Integers.f_int_16 | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_16 -> y: FStar.Integers.int_16{FStar.Integers.ok FStar.Integers.op_Plus x y}
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.W16) | {
"end_col": 54,
"end_line": 584,
"start_col": 49,
"start_line": 584
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fixed_width = w:width{w <> Winfinite} | let fixed_width = | false | null | false | w: width{w <> Winfinite} | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.width",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Integers.Winfinite"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fixed_width : Type0 | [] | FStar.Integers.fixed_width | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 41,
"end_line": 43,
"start_col": 18,
"start_line": 43
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y) | let modulo sw (x: int) (y: pos{Signed? sw ==> y % 2 = 0}) = | false | null | false | match sw with
| Unsigned _ -> x % y
| _ -> let open FStar.Int in x @% y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.int",
"Prims.pos",
"Prims.l_imp",
"Prims.b2t",
"FStar.Integers.uu___is_Signed",
"Prims.op_Equality",
"Prims.op_Modulus",
"FStar.Integers.fixed_width",
"FStar.Int.op_At_Percent"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modulo : sw: FStar.Integers.signed_width -> x: Prims.int -> y: Prims.pos{Signed? sw ==> y % 2 = 0}
-> Prims.int | [] | FStar.Integers.modulo | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | sw: FStar.Integers.signed_width -> x: Prims.int -> y: Prims.pos{Signed? sw ==> y % 2 = 0}
-> Prims.int | {
"end_col": 27,
"end_line": 184,
"start_col": 2,
"start_line": 182
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v | let nat_of_fixed_width (w: fixed_width) = | false | null | false | match nat_of_width w with | Some v -> v | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.fixed_width",
"FStar.Integers.nat_of_width",
"Prims.int"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm] | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_of_fixed_width : w: FStar.Integers.fixed_width -> Prims.int | [] | FStar.Integers.nat_of_fixed_width | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | w: FStar.Integers.fixed_width -> Prims.int | {
"end_col": 15,
"end_line": 48,
"start_col": 2,
"start_line": 47
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None | let nat_of_width = | false | null | false | function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.width",
"FStar.Pervasives.Native.Some",
"Prims.int",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_of_width : _: FStar.Integers.width -> FStar.Pervasives.Native.option Prims.int | [] | FStar.Integers.nat_of_width | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: FStar.Integers.width -> FStar.Pervasives.Native.option Prims.int | {
"end_col": 21,
"end_line": 41,
"start_col": 19,
"start_line": 35
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let width_of_sw = function
| Signed w -> w
| Unsigned w -> w | let width_of_sw = | false | null | false | function
| Signed w -> w
| Unsigned w -> w | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.width",
"FStar.Integers.fixed_width"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val width_of_sw : _: FStar.Integers.signed_width -> FStar.Integers.width | [] | FStar.Integers.width_of_sw | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: FStar.Integers.signed_width -> FStar.Integers.width | {
"end_col": 19,
"end_line": 57,
"start_col": 18,
"start_line": 55
} |
|
Prims.Tot | val op_Greater (#sw: _) (x y: int_t sw) : bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y) | val op_Greater (#sw: _) (x y: int_t sw) : bool
let op_Greater #sw (x: int_t sw) (y: int_t sw) : bool = | false | null | false | match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> let open FStar.UInt8 in x >^ y
| Unsigned W16 -> let open FStar.UInt16 in x >^ y
| Unsigned W32 -> let open FStar.UInt32 in x >^ y
| Unsigned W64 -> let open FStar.UInt64 in x >^ y
| Unsigned W128 -> let open FStar.UInt128 in x >^ y
| Signed W8 -> let open FStar.Int8 in x >^ y
| Signed W16 -> let open FStar.Int16 in x >^ y
| Signed W32 -> let open FStar.Int32 in x >^ y
| Signed W64 -> let open FStar.Int64 in x >^ y
| Signed W128 -> let open FStar.Int128 in x >^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.op_GreaterThan",
"FStar.UInt8.op_Greater_Hat",
"FStar.UInt16.op_Greater_Hat",
"FStar.UInt32.op_Greater_Hat",
"FStar.UInt64.op_Greater_Hat",
"FStar.UInt128.op_Greater_Hat",
"FStar.Int8.op_Greater_Hat",
"FStar.Int16.op_Greater_Hat",
"FStar.Int32.op_Greater_Hat",
"FStar.Int64.op_Greater_Hat",
"FStar.Int128.op_Greater_Hat",
"Prims.bool"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater (#sw: _) (x y: int_t sw) : bool | [] | FStar.Integers.op_Greater | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> Prims.bool | {
"end_col": 42,
"end_line": 332,
"start_col": 4,
"start_line": 321
} |
Prims.Tot | val op_Subtraction_Question (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y) | val op_Subtraction_Question (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw)
let op_Subtraction_Question (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) = | false | null | false | let Unsigned w = sw in
match w with
| W8 -> let open FStar.UInt8 in x -?^ y
| W16 -> let open FStar.UInt16 in x -?^ y
| W32 -> let open FStar.UInt32 in x -?^ y
| W64 -> let open FStar.UInt64 in x -?^ y
| W128 -> let open FStar.UInt128 in x -?^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.b2t",
"FStar.Integers.uu___is_Unsigned",
"FStar.Integers.int_t",
"FStar.Integers.fixed_width",
"FStar.UInt8.op_Subtraction_Question_Hat",
"FStar.UInt16.op_Subtraction_Question_Hat",
"FStar.UInt32.op_Subtraction_Question_Hat",
"FStar.UInt64.op_Subtraction_Question_Hat",
"FStar.UInt128.op_Subtraction_Question_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Question (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) | [] | FStar.Integers.op_Subtraction_Question | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> FStar.Integers.int_t sw | {
"end_col": 37,
"end_line": 235,
"start_col": 3,
"start_line": 229
} |
Prims.Tot | val op_Subtraction_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y) | val op_Subtraction_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw)
let op_Subtraction_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) = | false | null | false | let Unsigned w = sw in
match w with
| W8 -> let open FStar.UInt8 in x -%^ y
| W16 -> let open FStar.UInt16 in x -%^ y
| W32 -> let open FStar.UInt32 in x -%^ y
| W64 -> let open FStar.UInt64 in x -%^ y
| W128 -> let open FStar.UInt128 in x -%^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.b2t",
"FStar.Integers.uu___is_Unsigned",
"FStar.Integers.int_t",
"FStar.Integers.fixed_width",
"FStar.UInt8.op_Subtraction_Percent_Hat",
"FStar.UInt16.op_Subtraction_Percent_Hat",
"FStar.UInt32.op_Subtraction_Percent_Hat",
"FStar.UInt64.op_Subtraction_Percent_Hat",
"FStar.UInt128.op_Subtraction_Percent_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) | [] | FStar.Integers.op_Subtraction_Percent | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> FStar.Integers.int_t sw | {
"end_col": 37,
"end_line": 251,
"start_col": 3,
"start_line": 245
} |
Prims.Tot | val v (#sw: _) (x: int_t sw) : Tot (y: int_t (Signed Winfinite) {within_bounds sw y}) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x) | val v (#sw: _) (x: int_t sw) : Tot (y: int_t (Signed Winfinite) {within_bounds sw y})
let v #sw (x: int_t sw) : Tot (y: int_t (Signed Winfinite) {within_bounds sw y}) = | false | null | false | match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"FStar.Integers.fixed_width",
"FStar.UInt8.v",
"FStar.UInt16.v",
"FStar.UInt32.v",
"FStar.UInt64.v",
"FStar.UInt128.v",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.within_bounds",
"FStar.Integers.width",
"FStar.Int8.v",
"FStar.Int16.v",
"FStar.Int32.v",
"FStar.Int64.v",
"FStar.Int128.v"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val v (#sw: _) (x: int_t sw) : Tot (y: int_t (Signed Winfinite) {within_bounds sw y}) | [] | FStar.Integers.v | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw
-> y:
FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite)
{FStar.Integers.within_bounds sw y} | {
"end_col": 34,
"end_line": 108,
"start_col": 4,
"start_line": 93
} |
Prims.Tot | val op_Plus_Question (#w: fixed_width) (x y: int_t (Unsigned w)) : Tot (int_t (Unsigned w)) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y) | val op_Plus_Question (#w: fixed_width) (x y: int_t (Unsigned w)) : Tot (int_t (Unsigned w))
let op_Plus_Question (#w: fixed_width) (x y: int_t (Unsigned w)) : Tot (int_t (Unsigned w)) = | false | null | false | match w with
| W8 -> let open FStar.UInt8 in x +?^ y
| W16 -> let open FStar.UInt16 in x +?^ y
| W32 -> let open FStar.UInt32 in x +?^ y
| W64 -> let open FStar.UInt64 in x +?^ y
| W128 -> let open FStar.UInt128 in x +?^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.fixed_width",
"FStar.Integers.int_t",
"FStar.Integers.Unsigned",
"FStar.UInt8.op_Plus_Question_Hat",
"FStar.UInt16.op_Plus_Question_Hat",
"FStar.UInt32.op_Plus_Question_Hat",
"FStar.UInt64.op_Plus_Question_Hat",
"FStar.UInt128.op_Plus_Question_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w)) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Plus_Question (#w: fixed_width) (x y: int_t (Unsigned w)) : Tot (int_t (Unsigned w)) | [] | FStar.Integers.op_Plus_Question | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t (FStar.Integers.Unsigned w) ->
y: FStar.Integers.int_t (FStar.Integers.Unsigned w)
-> FStar.Integers.int_t (FStar.Integers.Unsigned w) | {
"end_col": 37,
"end_line": 177,
"start_col": 4,
"start_line": 172
} |
Prims.Tot | val op_Star_Percent (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y) | val op_Star_Percent (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw)
let op_Star_Percent (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw) = | false | null | false | let Unsigned w = sw in
match w with
| W8 -> let open FStar.UInt8 in x *%^ y
| W16 -> let open FStar.UInt16 in x *%^ y
| W32 -> let open FStar.UInt32 in x *%^ y
| W64 -> let open FStar.UInt64 in x *%^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.l_and",
"Prims.b2t",
"FStar.Integers.uu___is_Unsigned",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.W128",
"FStar.Integers.int_t",
"FStar.Integers.fixed_width",
"FStar.UInt8.op_Star_Percent_Hat",
"FStar.UInt16.op_Star_Percent_Hat",
"FStar.UInt32.op_Star_Percent_Hat",
"FStar.UInt64.op_Star_Percent_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star_Percent (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw) | [] | FStar.Integers.op_Star_Percent | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> FStar.Integers.int_t sw | {
"end_col": 35,
"end_line": 315,
"start_col": 3,
"start_line": 310
} |
Prims.Tot | val op_Less (#sw: _) (x y: int_t sw) : bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y) | val op_Less (#sw: _) (x y: int_t sw) : bool
let op_Less #sw (x: int_t sw) (y: int_t sw) : bool = | false | null | false | match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> let open FStar.UInt8 in x <^ y
| Unsigned W16 -> let open FStar.UInt16 in x <^ y
| Unsigned W32 -> let open FStar.UInt32 in x <^ y
| Unsigned W64 -> let open FStar.UInt64 in x <^ y
| Unsigned W128 -> let open FStar.UInt128 in x <^ y
| Signed W8 -> let open FStar.Int8 in x <^ y
| Signed W16 -> let open FStar.Int16 in x <^ y
| Signed W32 -> let open FStar.Int32 in x <^ y
| Signed W64 -> let open FStar.Int64 in x <^ y
| Signed W128 -> let open FStar.Int128 in x <^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.op_LessThan",
"FStar.UInt8.op_Less_Hat",
"FStar.UInt16.op_Less_Hat",
"FStar.UInt32.op_Less_Hat",
"FStar.UInt64.op_Less_Hat",
"FStar.UInt128.op_Less_Hat",
"FStar.Int8.op_Less_Hat",
"FStar.Int16.op_Less_Hat",
"FStar.Int32.op_Less_Hat",
"FStar.Int64.op_Less_Hat",
"FStar.Int128.op_Less_Hat",
"Prims.bool"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less (#sw: _) (x y: int_t sw) : bool | [] | FStar.Integers.op_Less | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> Prims.bool | {
"end_col": 42,
"end_line": 367,
"start_col": 4,
"start_line": 356
} |
Prims.Tot | val op_Star_Question (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y) | val op_Star_Question (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw)
let op_Star_Question (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw) = | false | null | false | let Unsigned w = sw in
match w with
| W8 -> let open FStar.UInt8 in x *?^ y
| W16 -> let open FStar.UInt16 in x *?^ y
| W32 -> let open FStar.UInt32 in x *?^ y
| W64 -> let open FStar.UInt64 in x *?^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.l_and",
"Prims.b2t",
"FStar.Integers.uu___is_Unsigned",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.W128",
"FStar.Integers.int_t",
"FStar.Integers.fixed_width",
"FStar.UInt8.op_Star_Question_Hat",
"FStar.UInt16.op_Star_Question_Hat",
"FStar.UInt32.op_Star_Question_Hat",
"FStar.UInt64.op_Star_Question_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star_Question (#sw: _{Unsigned? sw /\ width_of_sw sw <> W128}) (x y: int_t sw)
: Tot (int_t sw) | [] | FStar.Integers.op_Star_Question | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> FStar.Integers.int_t sw | {
"end_col": 35,
"end_line": 301,
"start_col": 3,
"start_line": 296
} |
Prims.Tot | val op_Plus_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y) | val op_Plus_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw)
let op_Plus_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) = | false | null | false | let Unsigned w = sw in
match w with
| W8 -> let open FStar.UInt8 in x +%^ y
| W16 -> let open FStar.UInt16 in x +%^ y
| W32 -> let open FStar.UInt32 in x +%^ y
| W64 -> let open FStar.UInt64 in x +%^ y
| W128 -> let open FStar.UInt128 in x +%^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.b2t",
"FStar.Integers.uu___is_Unsigned",
"FStar.Integers.int_t",
"FStar.Integers.fixed_width",
"FStar.UInt8.op_Plus_Percent_Hat",
"FStar.UInt16.op_Plus_Percent_Hat",
"FStar.UInt32.op_Plus_Percent_Hat",
"FStar.UInt64.op_Plus_Percent_Hat",
"FStar.UInt128.op_Plus_Percent_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Plus_Percent (#sw: _{Unsigned? sw}) (x y: int_t sw) : Tot (int_t sw) | [] | FStar.Integers.op_Plus_Percent | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> FStar.Integers.int_t sw | {
"end_col": 37,
"end_line": 199,
"start_col": 3,
"start_line": 193
} |
Prims.Tot | val op_Minus (#sw: _{Signed? sw}) (x: int_t sw {within_bounds sw (0 - v x)}) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x) | val op_Minus (#sw: _{Signed? sw}) (x: int_t sw {within_bounds sw (0 - v x)}) : Tot (int_t sw)
let op_Minus (#sw: _{Signed? sw}) (x: int_t sw {within_bounds sw (0 - v x)}) : Tot (int_t sw) = | false | null | false | let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> let open FStar.Int8 in 0y -^ x
| W16 -> let open FStar.Int16 in 0s -^ x
| W32 -> let open FStar.Int32 in 0l -^ x
| W64 -> let open FStar.Int64 in 0L -^ x
| W128 -> let open FStar.Int128 in int_to_t 0 -^ x | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.b2t",
"FStar.Integers.uu___is_Signed",
"FStar.Integers.int_t",
"FStar.Integers.within_bounds",
"FStar.Integers.op_Subtraction",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.v",
"FStar.Integers.width",
"FStar.Int8.op_Subtraction_Hat",
"FStar.Int8.__int_to_t",
"FStar.Int16.op_Subtraction_Hat",
"FStar.Int16.__int_to_t",
"FStar.Int32.op_Subtraction_Hat",
"FStar.Int32.__int_to_t",
"FStar.Int64.op_Subtraction_Hat",
"FStar.Int64.__int_to_t",
"FStar.Int128.op_Subtraction_Hat",
"FStar.Int128.int_to_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Minus (#sw: _{Signed? sw}) (x: int_t sw {within_bounds sw (0 - v x)}) : Tot (int_t sw) | [] | FStar.Integers.op_Minus | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw {FStar.Integers.within_bounds sw (0 - FStar.Integers.v x)}
-> FStar.Integers.int_t sw | {
"end_col": 44,
"end_line": 267,
"start_col": 3,
"start_line": 260
} |
Prims.Tot | val op_Greater_Equals (#sw: _) (x y: int_t sw) : bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y) | val op_Greater_Equals (#sw: _) (x y: int_t sw) : bool
let op_Greater_Equals #sw (x: int_t sw) (y: int_t sw) : bool = | false | null | false | match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> let open FStar.UInt8 in x >=^ y
| Unsigned W16 -> let open FStar.UInt16 in x >=^ y
| Unsigned W32 -> let open FStar.UInt32 in x >=^ y
| Unsigned W64 -> let open FStar.UInt64 in x >=^ y
| Unsigned W128 -> let open FStar.UInt128 in x >=^ y
| Signed W8 -> let open FStar.Int8 in x >=^ y
| Signed W16 -> let open FStar.Int16 in x >=^ y
| Signed W32 -> let open FStar.Int32 in x >=^ y
| Signed W64 -> let open FStar.Int64 in x >=^ y
| Signed W128 -> let open FStar.Int128 in x >=^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt8.op_Greater_Equals_Hat",
"FStar.UInt16.op_Greater_Equals_Hat",
"FStar.UInt32.op_Greater_Equals_Hat",
"FStar.UInt64.op_Greater_Equals_Hat",
"FStar.UInt128.op_Greater_Equals_Hat",
"FStar.Int8.op_Greater_Equals_Hat",
"FStar.Int16.op_Greater_Equals_Hat",
"FStar.Int32.op_Greater_Equals_Hat",
"FStar.Int64.op_Greater_Equals_Hat",
"FStar.Int128.op_Greater_Equals_Hat",
"Prims.bool"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Equals (#sw: _) (x y: int_t sw) : bool | [] | FStar.Integers.op_Greater_Equals | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> Prims.bool | {
"end_col": 43,
"end_line": 349,
"start_col": 4,
"start_line": 338
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let k (x:Prims.int) (y:Prims.int) = x * y | let k (x y: Prims.int) = | false | null | false | x * y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"Prims.int",
"FStar.Integers.op_Star",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y
let f_nat (x:nat) (y:nat) = x + y
let f_nat_int_pos (x:nat) (y:int) (z:pos) = x + y + z
let f_uint_8 (x:uint_8) (y:uint_8{ok (+) x y}) = x + y
let f_int_16 (x:int_16) (y:int_16{ok (+) x y}) = x + y
let g (x:uint_32) (y:uint_32{ok ( * ) y y /\ ok (+) x (y * y)}) = x + y * y
let h (x:Prims.nat) (y:Prims.nat): nat = u x + u y
let i (x:Prims.nat) (y:Prims.nat) = x + y | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val k : x: Prims.int -> y: Prims.int
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | [] | FStar.Integers.k | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.int -> y: Prims.int
-> FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite) | {
"end_col": 41,
"end_line": 589,
"start_col": 36,
"start_line": 589
} |
|
Prims.Tot | val op_Hat_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y) | val op_Hat_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw)
let op_Hat_Hat #sw (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) = | false | null | false | match sw with
| Unsigned W8 -> let open FStar.UInt8 in x ^^ y
| Unsigned W16 -> let open FStar.UInt16 in x ^^ y
| Unsigned W32 -> let open FStar.UInt32 in x ^^ y
| Unsigned W64 -> let open FStar.UInt64 in x ^^ y
| Unsigned W128 -> let open FStar.UInt128 in x ^^ y
| Signed W8 -> let open FStar.Int8 in x ^^ y
| Signed W16 -> let open FStar.Int16 in x ^^ y
| Signed W32 -> let open FStar.Int32 in x ^^ y
| Signed W64 -> let open FStar.Int64 in x ^^ y
| Signed W128 -> let open FStar.Int128 in x ^^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.Winfinite",
"FStar.UInt8.op_Hat_Hat",
"FStar.UInt16.op_Hat_Hat",
"FStar.UInt32.op_Hat_Hat",
"FStar.UInt64.op_Hat_Hat",
"FStar.UInt128.op_Hat_Hat",
"FStar.Int8.op_Hat_Hat",
"FStar.Int16.op_Hat_Hat",
"FStar.Int32.op_Hat_Hat",
"FStar.Int64.op_Hat_Hat",
"FStar.Int128.op_Hat_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Hat_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) | [] | FStar.Integers.op_Hat_Hat | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y: FStar.Integers.int_t sw {FStar.Integers.width_of_sw sw <> FStar.Integers.Winfinite}
-> FStar.Integers.int_t sw | {
"end_col": 44,
"end_line": 447,
"start_col": 6,
"start_line": 437
} |
Prims.Tot | val op_Amp_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y) | val op_Amp_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw)
let op_Amp_Hat #sw (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) = | false | null | false | match sw with
| Unsigned W8 -> let open FStar.UInt8 in x &^ y
| Unsigned W16 -> let open FStar.UInt16 in x &^ y
| Unsigned W32 -> let open FStar.UInt32 in x &^ y
| Unsigned W64 -> let open FStar.UInt64 in x &^ y
| Unsigned W128 -> let open FStar.UInt128 in x &^ y
| Signed W8 -> let open FStar.Int8 in x &^ y
| Signed W16 -> let open FStar.Int16 in x &^ y
| Signed W32 -> let open FStar.Int32 in x &^ y
| Signed W64 -> let open FStar.Int64 in x &^ y
| Signed W128 -> let open FStar.Int128 in x &^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.Winfinite",
"FStar.UInt8.op_Amp_Hat",
"FStar.UInt16.op_Amp_Hat",
"FStar.UInt32.op_Amp_Hat",
"FStar.UInt64.op_Amp_Hat",
"FStar.UInt128.op_Amp_Hat",
"FStar.Int8.op_Amp_Hat",
"FStar.Int16.op_Amp_Hat",
"FStar.Int32.op_Amp_Hat",
"FStar.Int64.op_Amp_Hat",
"FStar.Int128.op_Amp_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Amp_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) | [] | FStar.Integers.op_Amp_Hat | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y: FStar.Integers.int_t sw {FStar.Integers.width_of_sw sw <> FStar.Integers.Winfinite}
-> FStar.Integers.int_t sw | {
"end_col": 44,
"end_line": 464,
"start_col": 6,
"start_line": 454
} |
Prims.Tot | val h (x y: Prims.nat) : nat | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let h (x:Prims.nat) (y:Prims.nat): nat = u x + u y | val h (x y: Prims.nat) : nat
let h (x y: Prims.nat) : nat = | false | null | false | u x + u y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"Prims.nat",
"FStar.Integers.op_Plus",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.u",
"FStar.Integers.nat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y
let f_nat (x:nat) (y:nat) = x + y
let f_nat_int_pos (x:nat) (y:int) (z:pos) = x + y + z
let f_uint_8 (x:uint_8) (y:uint_8{ok (+) x y}) = x + y
let f_int_16 (x:int_16) (y:int_16{ok (+) x y}) = x + y | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val h (x y: Prims.nat) : nat | [] | FStar.Integers.h | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.nat -> y: Prims.nat -> FStar.Integers.nat | {
"end_col": 51,
"end_line": 586,
"start_col": 42,
"start_line": 586
} |
Prims.Tot | val u (#sw: _) (x: int_t (Signed Winfinite) {within_bounds sw x})
: Tot (y: int_t sw {norm (v x == v y)}) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x) | val u (#sw: _) (x: int_t (Signed Winfinite) {within_bounds sw x})
: Tot (y: int_t sw {norm (v x == v y)})
let u #sw (x: int_t (Signed Winfinite) {within_bounds sw x}) : Tot (y: int_t sw {norm (v x == v y)}) = | false | null | false | match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.within_bounds",
"FStar.Integers.fixed_width",
"FStar.UInt8.uint_to_t",
"FStar.UInt16.uint_to_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt64.uint_to_t",
"FStar.UInt128.uint_to_t",
"FStar.Integers.norm",
"Prims.eq2",
"Prims.l_or",
"FStar.Integers.v",
"FStar.Integers.width",
"FStar.Int8.int_to_t",
"FStar.Int16.int_to_t",
"FStar.Int32.int_to_t",
"FStar.Int64.int_to_t",
"FStar.Int128.int_to_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u (#sw: _) (x: int_t (Signed Winfinite) {within_bounds sw x})
: Tot (y: int_t sw {norm (v x == v y)}) | [] | FStar.Integers.u | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x:
FStar.Integers.int_t (FStar.Integers.Signed FStar.Integers.Winfinite)
{FStar.Integers.within_bounds sw x}
-> y: FStar.Integers.int_t sw {FStar.Integers.norm (FStar.Integers.v x == FStar.Integers.v y)} | {
"end_col": 41,
"end_line": 131,
"start_col": 4,
"start_line": 116
} |
Prims.Tot | val op_Plus (#sw: _) (x: int_t sw) (y: int_t sw {within_bounds sw (v x + v y)}) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y) | val op_Plus (#sw: _) (x: int_t sw) (y: int_t sw {within_bounds sw (v x + v y)}) : Tot (int_t sw)
let op_Plus #sw (x: int_t sw) (y: int_t sw {within_bounds sw (v x + v y)}) : Tot (int_t sw) = | false | null | false | match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> let open FStar.UInt8 in x +^ y
| Unsigned W16 -> let open FStar.UInt16 in x +^ y
| Unsigned W32 -> let open FStar.UInt32 in x +^ y
| Unsigned W64 -> let open FStar.UInt64 in x +^ y
| Unsigned W128 -> let open FStar.UInt128 in x +^ y
| Signed W8 -> let open FStar.Int8 in x +^ y
| Signed W16 -> let open FStar.Int16 in x +^ y
| Signed W32 -> let open FStar.Int32 in x +^ y
| Signed W64 -> let open FStar.Int64 in x +^ y
| Signed W128 -> let open FStar.Int128 in x +^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"FStar.Integers.within_bounds",
"Prims.op_Addition",
"FStar.Integers.v",
"FStar.UInt8.op_Plus_Hat",
"FStar.UInt16.op_Plus_Hat",
"FStar.UInt32.op_Plus_Hat",
"FStar.UInt64.op_Plus_Hat",
"FStar.UInt128.op_Plus_Hat",
"FStar.Int8.op_Plus_Hat",
"FStar.Int16.op_Plus_Hat",
"FStar.Int32.op_Plus_Hat",
"FStar.Int64.op_Plus_Hat",
"FStar.Int128.op_Plus_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Plus (#sw: _) (x: int_t sw) (y: int_t sw {within_bounds sw (v x + v y)}) : Tot (int_t sw) | [] | FStar.Integers.op_Plus | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y:
FStar.Integers.int_t sw
{FStar.Integers.within_bounds sw (FStar.Integers.v x + FStar.Integers.v y)}
-> FStar.Integers.int_t sw | {
"end_col": 42,
"end_line": 163,
"start_col": 4,
"start_line": 152
} |
Prims.Tot | val op_Bar_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y) | val op_Bar_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw)
let op_Bar_Hat #sw (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) = | false | null | false | match sw with
| Unsigned W8 -> let open FStar.UInt8 in x |^ y
| Unsigned W16 -> let open FStar.UInt16 in x |^ y
| Unsigned W32 -> let open FStar.UInt32 in x |^ y
| Unsigned W64 -> let open FStar.UInt64 in x |^ y
| Unsigned W128 -> let open FStar.UInt128 in x |^ y
| Signed W8 -> let open FStar.Int8 in x |^ y
| Signed W16 -> let open FStar.Int16 in x |^ y
| Signed W32 -> let open FStar.Int32 in x |^ y
| Signed W64 -> let open FStar.Int64 in x |^ y
| Signed W128 -> let open FStar.Int128 in x |^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.Winfinite",
"FStar.UInt8.op_Bar_Hat",
"FStar.UInt16.op_Bar_Hat",
"FStar.UInt32.op_Bar_Hat",
"FStar.UInt64.op_Bar_Hat",
"FStar.UInt128.op_Bar_Hat",
"FStar.Int8.op_Bar_Hat",
"FStar.Int16.op_Bar_Hat",
"FStar.Int32.op_Bar_Hat",
"FStar.Int64.op_Bar_Hat",
"FStar.Int128.op_Bar_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Bar_Hat (#sw: _) (x: int_t sw) (y: int_t sw {width_of_sw sw <> Winfinite}) : Tot (int_t sw) | [] | FStar.Integers.op_Bar_Hat | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y: FStar.Integers.int_t sw {FStar.Integers.width_of_sw sw <> FStar.Integers.Winfinite}
-> FStar.Integers.int_t sw | {
"end_col": 44,
"end_line": 481,
"start_col": 6,
"start_line": 471
} |
Prims.Tot | val op_Subtraction (#sw: _) (x: int_t sw) (y: int_t sw {within_bounds sw (v x - v y)})
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y) | val op_Subtraction (#sw: _) (x: int_t sw) (y: int_t sw {within_bounds sw (v x - v y)})
: Tot (int_t sw)
let op_Subtraction #sw (x: int_t sw) (y: int_t sw {within_bounds sw (v x - v y)}) : Tot (int_t sw) = | false | null | false | match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> let open FStar.UInt8 in x -^ y
| Unsigned W16 -> let open FStar.UInt16 in x -^ y
| Unsigned W32 -> let open FStar.UInt32 in x -^ y
| Unsigned W64 -> let open FStar.UInt64 in x -^ y
| Unsigned W128 -> let open FStar.UInt128 in x -^ y
| Signed W8 -> let open FStar.Int8 in x -^ y
| Signed W16 -> let open FStar.Int16 in x -^ y
| Signed W32 -> let open FStar.Int32 in x -^ y
| Signed W64 -> let open FStar.Int64 in x -^ y
| Signed W128 -> let open FStar.Int128 in x -^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"FStar.Integers.within_bounds",
"Prims.op_Subtraction",
"FStar.Integers.v",
"FStar.UInt8.op_Subtraction_Hat",
"FStar.UInt16.op_Subtraction_Hat",
"FStar.UInt32.op_Subtraction_Hat",
"FStar.UInt64.op_Subtraction_Hat",
"FStar.UInt128.op_Subtraction_Hat",
"FStar.Int8.op_Subtraction_Hat",
"FStar.Int16.op_Subtraction_Hat",
"FStar.Int32.op_Subtraction_Hat",
"FStar.Int64.op_Subtraction_Hat",
"FStar.Int128.op_Subtraction_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction (#sw: _) (x: int_t sw) (y: int_t sw {within_bounds sw (v x - v y)})
: Tot (int_t sw) | [] | FStar.Integers.op_Subtraction | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y:
FStar.Integers.int_t sw
{FStar.Integers.within_bounds sw (FStar.Integers.v x - FStar.Integers.v y)}
-> FStar.Integers.int_t sw | {
"end_col": 42,
"end_line": 219,
"start_col": 4,
"start_line": 208
} |
Prims.Tot | val op_Star
(#sw: signed_width{width_of_sw sw <> W128})
(x: int_t sw)
(y: int_t sw {within_bounds sw (v x * v y)})
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y) | val op_Star
(#sw: signed_width{width_of_sw sw <> W128})
(x: int_t sw)
(y: int_t sw {within_bounds sw (v x * v y)})
: Tot (int_t sw)
let op_Star
(#sw: signed_width{width_of_sw sw <> W128})
(x: int_t sw)
(y: int_t sw {within_bounds sw (v x * v y)})
: Tot (int_t sw) = | false | null | false | match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> let open FStar.UInt8 in x *^ y
| Unsigned W16 -> let open FStar.UInt16 in x *^ y
| Unsigned W32 -> let open FStar.UInt32 in x *^ y
| Unsigned W64 -> let open FStar.UInt64 in x *^ y
| Signed W8 -> let open FStar.Int8 in x *^ y
| Signed W16 -> let open FStar.Int16 in x *^ y
| Signed W32 -> let open FStar.Int32 in x *^ y
| Signed W64 -> let open FStar.Int64 in x *^ y
| Signed W128 -> let open FStar.Int128 in x *^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.W128",
"FStar.Integers.int_t",
"FStar.Integers.within_bounds",
"FStar.Mul.op_Star",
"FStar.Integers.v",
"FStar.UInt8.op_Star_Hat",
"FStar.UInt16.op_Star_Hat",
"FStar.UInt32.op_Star_Hat",
"FStar.UInt64.op_Star_Hat",
"FStar.Int8.op_Star_Hat",
"FStar.Int16.op_Star_Hat",
"FStar.Int32.op_Star_Hat",
"FStar.Int64.op_Star_Hat",
"FStar.Int128.op_Star_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star
(#sw: signed_width{width_of_sw sw <> W128})
(x: int_t sw)
(y: int_t sw {within_bounds sw (v x * v y)})
: Tot (int_t sw) | [] | FStar.Integers.op_Star | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y:
FStar.Integers.int_t sw
{FStar.Integers.within_bounds sw (FStar.Integers.v x * FStar.Integers.v y)}
-> FStar.Integers.int_t sw | {
"end_col": 42,
"end_line": 287,
"start_col": 4,
"start_line": 277
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g (x:uint_32) (y:uint_32{ok ( * ) y y /\ ok (+) x (y * y)}) = x + y * y | let g (x: uint_32) (y: uint_32{ok ( * ) y y /\ ok ( + ) x (y * y)}) = | false | null | false | x + y * y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.uint_32",
"Prims.l_and",
"FStar.Integers.ok",
"FStar.Integers.Unsigned",
"FStar.Integers.W32",
"FStar.Integers.op_Star",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.op_Plus",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y)
[@@mark_for_norm]
unfold
let uint_8 = int_t (Unsigned W8)
[@@mark_for_norm]
unfold
let uint_16 = int_t (Unsigned W16)
[@@mark_for_norm]
unfold
let uint_32 = int_t (Unsigned W32)
[@@mark_for_norm]
unfold
let uint_64 = int_t (Unsigned W64)
[@@mark_for_norm]
unfold
let int = int_t (Signed Winfinite)
[@@mark_for_norm]
unfold
let int_8 = int_t (Signed W8)
[@@mark_for_norm]
unfold
let int_16 = int_t (Signed W16)
[@@mark_for_norm]
unfold
let int_32 = int_t (Signed W32)
[@@mark_for_norm]
unfold
let int_64 = int_t (Signed W64)
[@@mark_for_norm]
unfold
let int_128 = int_t (Signed W128)
[@@mark_for_norm]
unfold
let ok #sw
(op:(int_t (Signed Winfinite)
-> int_t (Signed Winfinite)
-> int_t (Signed Winfinite)))
(x:int_t sw)
(y:int_t sw)
= within_bounds sw (op (v x) (v y))
[@@mark_for_norm]
unfold
let nat = i:int{ i >= 0 }
[@@mark_for_norm]
unfold
let pos = i:nat{ 0 < i }
////////////////////////////////////////////////////////////////////////////////
//Test
////////////////////////////////////////////////////////////////////////////////
let f_int (x:int) (y:int) = x + y
let f_nat (x:nat) (y:nat) = x + y
let f_nat_int_pos (x:nat) (y:int) (z:pos) = x + y + z
let f_uint_8 (x:uint_8) (y:uint_8{ok (+) x y}) = x + y | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val g : x: FStar.Integers.uint_32 ->
y:
FStar.Integers.uint_32
{ FStar.Integers.ok FStar.Integers.op_Star y y /\
FStar.Integers.ok FStar.Integers.op_Plus x (y * y) }
-> FStar.Integers.int_t (FStar.Integers.Unsigned FStar.Integers.W32) | [] | FStar.Integers.g | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.uint_32 ->
y:
FStar.Integers.uint_32
{ FStar.Integers.ok FStar.Integers.op_Star y y /\
FStar.Integers.ok FStar.Integers.op_Plus x (y * y) }
-> FStar.Integers.int_t (FStar.Integers.Unsigned FStar.Integers.W32) | {
"end_col": 75,
"end_line": 585,
"start_col": 66,
"start_line": 585
} |
|
Prims.Tot | val op_Greater_Greater_Hat
(#sw: _)
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x >>^ y)
| Unsigned W16 -> FStar.UInt16.(x >>^ y)
| Unsigned W32 -> FStar.UInt32.(x >>^ y)
| Unsigned W64 -> FStar.UInt64.(x >>^ y)
| Unsigned W128 -> FStar.UInt128.(x >>^ y)
| Signed W8 -> FStar.Int8.(x >>^ y)
| Signed W16 -> FStar.Int16.(x >>^ y)
| Signed W32 -> FStar.Int32.(x >>^ y)
| Signed W64 -> FStar.Int64.(x >>^ y)
| Signed W128 -> FStar.Int128.(x >>^ y) | val op_Greater_Greater_Hat
(#sw: _)
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw)
let op_Greater_Greater_Hat
#sw
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw) = | false | null | false | match sw with
| Unsigned W8 -> let open FStar.UInt8 in x >>^ y
| Unsigned W16 -> let open FStar.UInt16 in x >>^ y
| Unsigned W32 -> let open FStar.UInt32 in x >>^ y
| Unsigned W64 -> let open FStar.UInt64 in x >>^ y
| Unsigned W128 -> let open FStar.UInt128 in x >>^ y
| Signed W8 -> let open FStar.Int8 in x >>^ y
| Signed W16 -> let open FStar.Int16 in x >>^ y
| Signed W32 -> let open FStar.Int32 in x >>^ y
| Signed W64 -> let open FStar.Int64 in x >>^ y
| Signed W128 -> let open FStar.Int128 in x >>^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.b2t",
"FStar.Integers.op_Less_Equals",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.v",
"FStar.Integers.Unsigned",
"FStar.Integers.W32",
"Prims.l_and",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.op_Less",
"FStar.Integers.nat_of_fixed_width",
"FStar.UInt8.op_Greater_Greater_Hat",
"FStar.UInt16.op_Greater_Greater_Hat",
"FStar.UInt32.op_Greater_Greater_Hat",
"FStar.UInt64.op_Greater_Greater_Hat",
"FStar.UInt128.op_Greater_Greater_Hat",
"FStar.Int8.op_Greater_Greater_Hat",
"FStar.Int16.op_Greater_Greater_Hat",
"FStar.Int32.op_Greater_Greater_Hat",
"FStar.Int64.op_Greater_Greater_Hat",
"FStar.Int128.op_Greater_Greater_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >>^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Greater_Hat
(#sw: _)
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw)})
: Tot (int_t sw) | [] | FStar.Integers.op_Greater_Greater_Hat | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw {0 <= FStar.Integers.v x} ->
y:
FStar.Integers.int_t (FStar.Integers.Unsigned FStar.Integers.W32)
{ FStar.Integers.width_of_sw sw <> FStar.Integers.Winfinite /\
FStar.Integers.v y < FStar.Integers.nat_of_fixed_width (FStar.Integers.width_of_sw sw) }
-> FStar.Integers.int_t sw | {
"end_col": 45,
"end_line": 517,
"start_col": 6,
"start_line": 507
} |
Prims.Tot | val op_Slash
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw ((v x) `FStar.Int.op_Slash` (v y))) })
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y) | val op_Slash
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw ((v x) `FStar.Int.op_Slash` (v y))) })
: Tot (int_t sw)
let op_Slash
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw ((v x) `FStar.Int.op_Slash` (v y))) })
: Tot (int_t sw) = | false | null | false | match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> let open FStar.UInt8 in x /^ y
| Unsigned W16 -> let open FStar.UInt16 in x /^ y
| Unsigned W32 -> let open FStar.UInt32 in x /^ y
| Unsigned W64 -> let open FStar.UInt64 in x /^ y
| Signed W8 -> let open FStar.Int8 in x /^ y
| Signed W16 -> let open FStar.Int16 in x /^ y
| Signed W32 -> let open FStar.Int32 in x /^ y
| Signed W64 -> let open FStar.Int64 in x /^ y
| Signed W128 -> let open FStar.Int128 in x /^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Integers.Unsigned",
"FStar.Integers.W128",
"FStar.Integers.int_t",
"Prims.l_and",
"Prims.int",
"FStar.Integers.v",
"FStar.Integers.fixed_width",
"FStar.Integers.within_bounds",
"Prims.op_Division",
"FStar.Integers.width",
"FStar.Int.op_Slash",
"Prims.logical",
"FStar.UInt8.op_Slash_Hat",
"FStar.UInt16.op_Slash_Hat",
"FStar.UInt32.op_Slash_Hat",
"FStar.UInt64.op_Slash_Hat",
"FStar.Int8.op_Slash_Hat",
"FStar.Int16.op_Slash_Hat",
"FStar.Int32.op_Slash_Hat",
"FStar.Int64.op_Slash_Hat",
"FStar.Int128.op_Slash_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Slash
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw ((v x) `FStar.Int.op_Slash` (v y))) })
: Tot (int_t sw) | [] | FStar.Integers.op_Slash | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y:
FStar.Integers.int_t sw
{ 0 <> FStar.Integers.v y /\
(match sw with
| FStar.Integers.Unsigned _ ->
FStar.Integers.within_bounds sw (FStar.Integers.v x / FStar.Integers.v y)
| FStar.Integers.Signed _ ->
FStar.Integers.within_bounds sw (FStar.Integers.v x / FStar.Integers.v y)) }
-> FStar.Integers.int_t sw | {
"end_col": 43,
"end_line": 406,
"start_col": 5,
"start_line": 396
} |
Prims.Tot | val op_Less_Less_Hat
(#sw: _)
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{ width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\
(Signed? sw ==> within_bounds sw (v x * pow2 (v y))) })
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x <<^ y)
| Unsigned W16 -> FStar.UInt16.(x <<^ y)
| Unsigned W32 -> FStar.UInt32.(x <<^ y)
| Unsigned W64 -> FStar.UInt64.(x <<^ y)
| Unsigned W128 -> FStar.UInt128.(x <<^ y)
| Signed W8 -> FStar.Int8.(x <<^ y)
| Signed W16 -> FStar.Int16.(x <<^ y)
| Signed W32 -> FStar.Int32.(x <<^ y)
| Signed W64 -> FStar.Int64.(x <<^ y)
| Signed W128 -> FStar.Int128.(x <<^ y) | val op_Less_Less_Hat
(#sw: _)
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{ width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\
(Signed? sw ==> within_bounds sw (v x * pow2 (v y))) })
: Tot (int_t sw)
let op_Less_Less_Hat
#sw
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{ width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\
(Signed? sw ==> within_bounds sw (v x * pow2 (v y))) })
: Tot (int_t sw) = | false | null | false | match sw with
| Unsigned W8 -> let open FStar.UInt8 in x <<^ y
| Unsigned W16 -> let open FStar.UInt16 in x <<^ y
| Unsigned W32 -> let open FStar.UInt32 in x <<^ y
| Unsigned W64 -> let open FStar.UInt64 in x <<^ y
| Unsigned W128 -> let open FStar.UInt128 in x <<^ y
| Signed W8 -> let open FStar.Int8 in x <<^ y
| Signed W16 -> let open FStar.Int16 in x <<^ y
| Signed W32 -> let open FStar.Int32 in x <<^ y
| Signed W64 -> let open FStar.Int64 in x <<^ y
| Signed W128 -> let open FStar.Int128 in x <<^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.b2t",
"FStar.Integers.op_Less_Equals",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.v",
"FStar.Integers.Unsigned",
"FStar.Integers.W32",
"Prims.l_and",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.op_Less",
"FStar.Integers.nat_of_fixed_width",
"Prims.l_imp",
"FStar.Integers.uu___is_Signed",
"FStar.Integers.within_bounds",
"FStar.Integers.op_Star",
"Prims.pow2",
"FStar.UInt8.op_Less_Less_Hat",
"FStar.UInt16.op_Less_Less_Hat",
"FStar.UInt32.op_Less_Less_Hat",
"FStar.UInt64.op_Less_Less_Hat",
"FStar.UInt128.op_Less_Less_Hat",
"FStar.Int8.op_Less_Less_Hat",
"FStar.Int16.op_Less_Less_Hat",
"FStar.Int32.op_Less_Less_Hat",
"FStar.Int64.op_Less_Less_Hat",
"FStar.Int128.op_Less_Less_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( ^^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x ^^ y)
| Unsigned W16 -> FStar.UInt16.(x ^^ y)
| Unsigned W32 -> FStar.UInt32.(x ^^ y)
| Unsigned W64 -> FStar.UInt64.(x ^^ y)
| Unsigned W128 -> FStar.UInt128.(x ^^ y)
| Signed W8 -> FStar.Int8.(x ^^ y)
| Signed W16 -> FStar.Int16.(x ^^ y)
| Signed W32 -> FStar.Int32.(x ^^ y)
| Signed W64 -> FStar.Int64.(x ^^ y)
| Signed W128 -> FStar.Int128.(x ^^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( &^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x &^ y)
| Unsigned W16 -> FStar.UInt16.(x &^ y)
| Unsigned W32 -> FStar.UInt32.(x &^ y)
| Unsigned W64 -> FStar.UInt64.(x &^ y)
| Unsigned W128 -> FStar.UInt128.(x &^ y)
| Signed W8 -> FStar.Int8.(x &^ y)
| Signed W16 -> FStar.Int16.(x &^ y)
| Signed W32 -> FStar.Int32.(x &^ y)
| Signed W64 -> FStar.Int64.(x &^ y)
| Signed W128 -> FStar.Int128.(x &^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( |^ ) #sw (x:int_t sw) (y:int_t sw{width_of_sw sw <> Winfinite})
: Tot (int_t sw)
= match sw with
| Unsigned W8 -> FStar.UInt8.(x |^ y)
| Unsigned W16 -> FStar.UInt16.(x |^ y)
| Unsigned W32 -> FStar.UInt32.(x |^ y)
| Unsigned W64 -> FStar.UInt64.(x |^ y)
| Unsigned W128 -> FStar.UInt128.(x |^ y)
| Signed W8 -> FStar.Int8.(x |^ y)
| Signed W16 -> FStar.Int16.(x |^ y)
| Signed W32 -> FStar.Int32.(x |^ y)
| Signed W64 -> FStar.Int64.(x |^ y)
| Signed W128 -> FStar.Int128.(x |^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <<^ ) #sw (x:int_t sw{0 <= v x})
(y:int_t (Unsigned W32){width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\ (Signed? sw ==> within_bounds sw (v x * pow2 (v y)))}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Less_Hat
(#sw: _)
(x: int_t sw {0 <= v x})
(y:
int_t (Unsigned W32)
{ width_of_sw sw <> Winfinite /\ v y < nat_of_fixed_width (width_of_sw sw) /\
(Signed? sw ==> within_bounds sw (v x * pow2 (v y))) })
: Tot (int_t sw) | [] | FStar.Integers.op_Less_Less_Hat | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw {0 <= FStar.Integers.v x} ->
y:
FStar.Integers.int_t (FStar.Integers.Unsigned FStar.Integers.W32)
{ FStar.Integers.width_of_sw sw <> FStar.Integers.Winfinite /\
FStar.Integers.v y < FStar.Integers.nat_of_fixed_width (FStar.Integers.width_of_sw sw) /\
(Signed? sw ==>
FStar.Integers.within_bounds sw (FStar.Integers.v x * Prims.pow2 (FStar.Integers.v y)))
}
-> FStar.Integers.int_t sw | {
"end_col": 45,
"end_line": 499,
"start_col": 6,
"start_line": 489
} |
Prims.Tot | val op_Percent
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ ->
within_bounds sw
(FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ ->
within_bounds sw
(FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y)) })
: Tot (int_t sw) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> FStar.UInt8.(x %^ y)
| Unsigned W16 -> FStar.UInt16.(x %^ y)
| Unsigned W32 -> FStar.UInt32.(x %^ y)
| Unsigned W64 -> FStar.UInt64.(x %^ y)
| Signed W8 -> FStar.Int8.(x %^ y)
| Signed W16 -> FStar.Int16.(x %^ y)
| Signed W32 -> FStar.Int32.(x %^ y)
| Signed W64 -> FStar.Int64.(x %^ y)
| Signed W128 -> FStar.Int128.(x %^ y) | val op_Percent
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ ->
within_bounds sw
(FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ ->
within_bounds sw
(FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y)) })
: Tot (int_t sw)
let op_Percent
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ ->
within_bounds sw
(FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ ->
within_bounds sw
(FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y)) })
: Tot (int_t sw) = | false | null | false | match sw with
| Signed Winfinite -> x % y
| Unsigned W8 -> let open FStar.UInt8 in x %^ y
| Unsigned W16 -> let open FStar.UInt16 in x %^ y
| Unsigned W32 -> let open FStar.UInt32 in x %^ y
| Unsigned W64 -> let open FStar.UInt64 in x %^ y
| Signed W8 -> let open FStar.Int8 in x %^ y
| Signed W16 -> let open FStar.Int16 in x %^ y
| Signed W32 -> let open FStar.Int32 in x %^ y
| Signed W64 -> let open FStar.Int64 in x %^ y
| Signed W128 -> let open FStar.Int128 in x %^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Integers.Unsigned",
"FStar.Integers.W128",
"FStar.Integers.int_t",
"Prims.l_and",
"Prims.int",
"FStar.Integers.v",
"FStar.Integers.fixed_width",
"FStar.Integers.within_bounds",
"FStar.UInt.mod",
"FStar.Integers.nat_of_fixed_width",
"FStar.Integers.width_of_sw",
"Prims.l_True",
"FStar.Integers.width",
"FStar.Int.mod",
"Prims.logical",
"FStar.Int.op_Slash",
"Prims.op_Modulus",
"FStar.UInt8.op_Percent_Hat",
"FStar.UInt16.op_Percent_Hat",
"FStar.UInt32.op_Percent_Hat",
"FStar.UInt64.op_Percent_Hat",
"FStar.Int8.op_Percent_Hat",
"FStar.Int16.op_Percent_Hat",
"FStar.Int32.op_Percent_Hat",
"FStar.Int64.op_Percent_Hat",
"FStar.Int128.op_Percent_Hat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( / ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (v x / v y)
| Signed _ -> within_bounds sw (v x `FStar.Int.op_Slash` v y))})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x / y
| Unsigned W8 -> FStar.UInt8.(x /^ y)
| Unsigned W16 -> FStar.UInt16.(x /^ y)
| Unsigned W32 -> FStar.UInt32.(x /^ y)
| Unsigned W64 -> FStar.UInt64.(x /^ y)
| Signed W8 -> FStar.Int8.(x /^ y)
| Signed W16 -> FStar.Int16.(x /^ y)
| Signed W32 -> FStar.Int32.(x /^ y)
| Signed W64 -> FStar.Int64.(x /^ y)
| Signed W128 -> FStar.Int128.(x /^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( % ) (#sw:signed_width{sw <> Unsigned W128})
(x:int_t sw)
(y:int_t sw{0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ -> within_bounds sw (FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ -> within_bounds sw (FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y))}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Percent
(#sw: signed_width{sw <> Unsigned W128})
(x: int_t sw)
(y:
int_t sw
{ 0 <> (v y <: Prims.int) /\
(match sw with
| Unsigned _ ->
within_bounds sw
(FStar.UInt.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))
| Signed Winfinite -> True
| Signed _ ->
within_bounds sw
(FStar.Int.mod #(nat_of_fixed_width (width_of_sw sw)) (v x) (v y))) /\
within_bounds sw (FStar.Int.op_Slash (v x) (v y)) })
: Tot (int_t sw) | [] | FStar.Integers.op_Percent | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.Integers.int_t sw ->
y:
FStar.Integers.int_t sw
{ 0 <> FStar.Integers.v y /\
(match sw with
| FStar.Integers.Unsigned _ ->
FStar.Integers.within_bounds sw
(FStar.UInt.mod (FStar.Integers.v x) (FStar.Integers.v y))
| FStar.Integers.Signed FStar.Integers.Winfinite -> Prims.l_True
| FStar.Integers.Signed _ ->
FStar.Integers.within_bounds sw
(FStar.Int.mod (FStar.Integers.v x) (FStar.Integers.v y))) /\
FStar.Integers.within_bounds sw (FStar.Integers.v x / FStar.Integers.v y) }
-> FStar.Integers.int_t sw | {
"end_col": 43,
"end_line": 430,
"start_col": 5,
"start_line": 420
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n | let within_bounds' sw (x: int) = | false | null | false | match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"Prims.int",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"FStar.Integers.nat_of_width",
"FStar.Integers.width_of_sw",
"FStar.Integers.width",
"Prims.l_True",
"FStar.Int.size",
"FStar.Integers.fixed_width",
"FStar.UInt.size"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract | false | true | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val within_bounds' : sw: FStar.Integers.signed_width -> x: Prims.int -> Type0 | [] | FStar.Integers.within_bounds' | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | sw: FStar.Integers.signed_width -> x: Prims.int -> Type0 | {
"end_col": 45,
"end_line": 83,
"start_col": 2,
"start_line": 80
} |
|
Prims.Tot | val cast (#sw #sw': _) (from: int_t sw {within_bounds sw' (v from)})
: Tot (to: int_t sw' {norm (v from == v to)}) | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from) | val cast (#sw #sw': _) (from: int_t sw {within_bounds sw' (v from)})
: Tot (to: int_t sw' {norm (v from == v to)})
let cast #sw #sw' (from: int_t sw {within_bounds sw' (v from)})
: Tot (to: int_t sw' {norm (v from == v to)}) = | false | null | false | u (v from) | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"FStar.Integers.within_bounds",
"FStar.Integers.v",
"FStar.Integers.u",
"FStar.Integers.norm",
"Prims.eq2",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"Prims.l_or"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)}) | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cast (#sw #sw': _) (from: int_t sw {within_bounds sw' (v from)})
: Tot (to: int_t sw' {norm (v from == v to)}) | [] | FStar.Integers.cast | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | from: FStar.Integers.int_t sw {FStar.Integers.within_bounds sw' (FStar.Integers.v from)}
-> to:
FStar.Integers.int_t sw' {FStar.Integers.norm (FStar.Integers.v from == FStar.Integers.v to)} | {
"end_col": 15,
"end_line": 138,
"start_col": 5,
"start_line": 138
} |
Prims.Tot | val op_Less_Equals (#sw: _) (x y: int_t sw) : bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( <= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> FStar.UInt8.(x <=^ y)
| Unsigned W16 -> FStar.UInt16.(x <=^ y)
| Unsigned W32 -> FStar.UInt32.(x <=^ y)
| Unsigned W64 -> FStar.UInt64.(x <=^ y)
| Unsigned W128 -> FStar.UInt128.(x <=^ y)
| Signed W8 -> FStar.Int8.(x <=^ y)
| Signed W16 -> FStar.Int16.(x <=^ y)
| Signed W32 -> FStar.Int32.(x <=^ y)
| Signed W64 -> FStar.Int64.(x <=^ y)
| Signed W128 -> FStar.Int128.(x <=^ y) | val op_Less_Equals (#sw: _) (x y: int_t sw) : bool
let op_Less_Equals #sw (x: int_t sw) (y: int_t sw) : bool = | false | null | false | match sw with
| Signed Winfinite -> x <= y
| Unsigned W8 -> let open FStar.UInt8 in x <=^ y
| Unsigned W16 -> let open FStar.UInt16 in x <=^ y
| Unsigned W32 -> let open FStar.UInt32 in x <=^ y
| Unsigned W64 -> let open FStar.UInt64 in x <=^ y
| Unsigned W128 -> let open FStar.UInt128 in x <=^ y
| Signed W8 -> let open FStar.Int8 in x <=^ y
| Signed W16 -> let open FStar.Int16 in x <=^ y
| Signed W32 -> let open FStar.Int32 in x <=^ y
| Signed W64 -> let open FStar.Int64 in x <=^ y
| Signed W128 -> let open FStar.Int128 in x <=^ y | {
"checked_file": "FStar.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Integers.fst"
} | [
"total"
] | [
"FStar.Integers.signed_width",
"FStar.Integers.int_t",
"Prims.op_LessThanOrEqual",
"FStar.UInt8.op_Less_Equals_Hat",
"FStar.UInt16.op_Less_Equals_Hat",
"FStar.UInt32.op_Less_Equals_Hat",
"FStar.UInt64.op_Less_Equals_Hat",
"FStar.UInt128.op_Less_Equals_Hat",
"FStar.Int8.op_Less_Equals_Hat",
"FStar.Int16.op_Less_Equals_Hat",
"FStar.Int32.op_Less_Equals_Hat",
"FStar.Int64.op_Less_Equals_Hat",
"FStar.Int128.op_Less_Equals_Hat",
"Prims.bool"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Integers
#set-options "--initial_ifuel 2 --max_ifuel 2 --initial_fuel 0 --max_fuel 0"
irreducible
let mark_for_norm = ()
unfold
let norm (#a:Type) (x:a) = norm [iota; delta_attr [`%mark_for_norm]] x
type width =
| W8
| W16
| W32
| W64
| W128
| Winfinite
[@@mark_for_norm]
let nat_of_width = function
| W8 -> Some 8
| W16 -> Some 16
| W32 -> Some 32
| W64 -> Some 64
| W128 -> Some 128
| Winfinite -> None
let fixed_width = w:width{w <> Winfinite}
[@@mark_for_norm]
let nat_of_fixed_width (w:fixed_width) =
match nat_of_width w with
| Some v -> v
type signed_width =
| Signed of width
| Unsigned of fixed_width //We don't support (Unsigned WInfinite); use nat instead
[@@mark_for_norm]
let width_of_sw = function
| Signed w -> w
| Unsigned w -> w
[@@mark_for_norm]
noextract
inline_for_extraction
let int_t sw : Tot Type0 =
match sw with
| Unsigned W8 -> FStar.UInt8.t
| Unsigned W16 -> FStar.UInt16.t
| Unsigned W32 -> FStar.UInt32.t
| Unsigned W64 -> FStar.UInt64.t
| Unsigned W128 -> FStar.UInt128.t
| Signed Winfinite -> int
| Signed W8 -> FStar.Int8.t
| Signed W16 -> FStar.Int16.t
| Signed W32 -> FStar.Int32.t
| Signed W64 -> FStar.Int64.t
| Signed W128 -> FStar.Int128.t
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let within_bounds' sw (x:int) =
match sw, nat_of_width (width_of_sw sw) with
| Signed _, None -> True
| Signed _, Some n -> FStar.Int.size x n
| Unsigned _, Some n -> FStar.UInt.size x n
unfold
let within_bounds sw x = norm (within_bounds' sw x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let v #sw (x:int_t sw)
: Tot (y:int_t (Signed Winfinite){within_bounds sw y})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.v x
| W16 -> FStar.UInt16.v x
| W32 -> FStar.UInt32.v x
| W64 -> FStar.UInt64.v x
| W128 -> FStar.UInt128.v x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.v x
| W16 -> FStar.Int16.v x
| W32 -> FStar.Int32.v x
| W64 -> FStar.Int64.v x
| W128 -> FStar.Int128.v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let u #sw
(x:int_t (Signed Winfinite){within_bounds sw x})
: Tot (y:int_t sw{norm (v x == v y)})
= match sw with
| Unsigned w ->
(match w with
| W8 -> FStar.UInt8.uint_to_t x
| W16 -> FStar.UInt16.uint_to_t x
| W32 -> FStar.UInt32.uint_to_t x
| W64 -> FStar.UInt64.uint_to_t x
| W128 -> FStar.UInt128.uint_to_t x)
| Signed w ->
(match w with
| Winfinite -> x
| W8 -> FStar.Int8.int_to_t x
| W16 -> FStar.Int16.int_to_t x
| W32 -> FStar.Int32.int_to_t x
| W64 -> FStar.Int64.int_to_t x
| W128 -> FStar.Int128.int_to_t x)
irreducible
noextract
let cast #sw #sw'
(from:int_t sw{within_bounds sw' (v from)})
: Tot (to:int_t sw'{norm (v from == v to)})
= u (v from)
[@@mark_for_norm]
unfold
noextract
let cast_ok #from to (x:int_t from) = within_bounds to (v x)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( + ) #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x + v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x + y
| Unsigned W8 -> FStar.UInt8.(x +^ y)
| Unsigned W16 -> FStar.UInt16.(x +^ y)
| Unsigned W32 -> FStar.UInt32.(x +^ y)
| Unsigned W64 -> FStar.UInt64.(x +^ y)
| Unsigned W128 -> FStar.UInt128.(x +^ y)
| Signed W8 -> FStar.Int8.(x +^ y)
| Signed W16 -> FStar.Int16.(x +^ y)
| Signed W32 -> FStar.Int32.(x +^ y)
| Signed W64 -> FStar.Int64.(x +^ y)
| Signed W128 -> FStar.Int128.(x +^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +? ) (#w:fixed_width)
(x:int_t (Unsigned w))
(y:int_t (Unsigned w))
: Tot (int_t (Unsigned w))
= match w with
| W8 -> FStar.UInt8.(x +?^ y)
| W16 -> FStar.UInt16.(x +?^ y)
| W32 -> FStar.UInt32.(x +?^ y)
| W64 -> FStar.UInt64.(x +?^ y)
| W128 -> FStar.UInt128.(x +?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
noextract
let modulo sw (x:int) (y:pos{Signed? sw ==> y%2=0}) =
match sw with
| Unsigned _ -> x % y
| _ -> FStar.Int.(x @% y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( +% ) (#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x +%^ y)
| W16 -> FStar.UInt16.(x +%^ y)
| W32 -> FStar.UInt32.(x +%^ y)
| W64 -> FStar.UInt64.(x +%^ y)
| W128 -> FStar.UInt128.(x +%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction #sw
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x - v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x - y
| Unsigned W8 -> FStar.UInt8.(x -^ y)
| Unsigned W16 -> FStar.UInt16.(x -^ y)
| Unsigned W32 -> FStar.UInt32.(x -^ y)
| Unsigned W64 -> FStar.UInt64.(x -^ y)
| Unsigned W128 -> FStar.UInt128.(x -^ y)
| Signed W8 -> FStar.Int8.(x -^ y)
| Signed W16 -> FStar.Int16.(x -^ y)
| Signed W32 -> FStar.Int32.(x -^ y)
| Signed W64 -> FStar.Int64.(x -^ y)
| Signed W128 -> FStar.Int128.(x -^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Question
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -?^ y)
| W16 -> FStar.UInt16.(x -?^ y)
| W32 -> FStar.UInt32.(x -?^ y)
| W64 -> FStar.UInt64.(x -?^ y)
| W128 -> FStar.UInt128.(x -?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Subtraction_Percent
(#sw:_{Unsigned? sw})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x -%^ y)
| W16 -> FStar.UInt16.(x -%^ y)
| W32 -> FStar.UInt32.(x -%^ y)
| W64 -> FStar.UInt64.(x -%^ y)
| W128 -> FStar.UInt128.(x -%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let op_Minus
(#sw:_{Signed? sw})
(x:int_t sw{within_bounds sw (0 - v x)})
: Tot (int_t sw)
= let Signed w = sw in
match w with
| Winfinite -> 0 - x
| W8 -> FStar.Int8.(0y -^ x)
| W16 -> FStar.Int16.(0s -^ x)
| W32 -> FStar.Int32.(0l -^ x)
| W64 -> FStar.Int64.(0L -^ x)
| W128 -> FStar.Int128.(int_to_t 0 -^ x)
open FStar.Mul
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( * ) (#sw:signed_width{width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw{within_bounds sw (v x * v y)})
: Tot (int_t sw)
= match sw with
| Signed Winfinite -> x * y
| Unsigned W8 -> FStar.UInt8.(x *^ y)
| Unsigned W16 -> FStar.UInt16.(x *^ y)
| Unsigned W32 -> FStar.UInt32.(x *^ y)
| Unsigned W64 -> FStar.UInt64.(x *^ y)
| Signed W8 -> FStar.Int8.(x *^ y)
| Signed W16 -> FStar.Int16.(x *^ y)
| Signed W32 -> FStar.Int32.(x *^ y)
| Signed W64 -> FStar.Int64.(x *^ y)
| Signed W128 -> FStar.Int128.(x *^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *? ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *?^ y)
| W16 -> FStar.UInt16.(x *?^ y)
| W32 -> FStar.UInt32.(x *?^ y)
| W64 -> FStar.UInt64.(x *?^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( *% ) (#sw:_{Unsigned? sw /\ width_of_sw sw <> W128})
(x:int_t sw)
(y:int_t sw)
: Tot (int_t sw)
= let Unsigned w = sw in
match w with
| W8 -> FStar.UInt8.(x *%^ y)
| W16 -> FStar.UInt16.(x *%^ y)
| W32 -> FStar.UInt32.(x *%^ y)
| W64 -> FStar.UInt64.(x *%^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( > ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x > y
| Unsigned W8 -> FStar.UInt8.(x >^ y)
| Unsigned W16 -> FStar.UInt16.(x >^ y)
| Unsigned W32 -> FStar.UInt32.(x >^ y)
| Unsigned W64 -> FStar.UInt64.(x >^ y)
| Unsigned W128 -> FStar.UInt128.(x >^ y)
| Signed W8 -> FStar.Int8.(x >^ y)
| Signed W16 -> FStar.Int16.(x >^ y)
| Signed W32 -> FStar.Int32.(x >^ y)
| Signed W64 -> FStar.Int64.(x >^ y)
| Signed W128 -> FStar.Int128.(x >^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( >= ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x >= y
| Unsigned W8 -> FStar.UInt8.(x >=^ y)
| Unsigned W16 -> FStar.UInt16.(x >=^ y)
| Unsigned W32 -> FStar.UInt32.(x >=^ y)
| Unsigned W64 -> FStar.UInt64.(x >=^ y)
| Unsigned W128 -> FStar.UInt128.(x >=^ y)
| Signed W8 -> FStar.Int8.(x >=^ y)
| Signed W16 -> FStar.Int16.(x >=^ y)
| Signed W32 -> FStar.Int32.(x >=^ y)
| Signed W64 -> FStar.Int64.(x >=^ y)
| Signed W128 -> FStar.Int128.(x >=^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract
let ( < ) #sw (x:int_t sw) (y:int_t sw) : bool =
match sw with
| Signed Winfinite -> x < y
| Unsigned W8 -> FStar.UInt8.(x <^ y)
| Unsigned W16 -> FStar.UInt16.(x <^ y)
| Unsigned W32 -> FStar.UInt32.(x <^ y)
| Unsigned W64 -> FStar.UInt64.(x <^ y)
| Unsigned W128 -> FStar.UInt128.(x <^ y)
| Signed W8 -> FStar.Int8.(x <^ y)
| Signed W16 -> FStar.Int16.(x <^ y)
| Signed W32 -> FStar.Int32.(x <^ y)
| Signed W64 -> FStar.Int64.(x <^ y)
| Signed W128 -> FStar.Int128.(x <^ y)
[@@mark_for_norm; strict_on_arguments [0]]
unfold
noextract | false | false | FStar.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Equals (#sw: _) (x y: int_t sw) : bool | [] | FStar.Integers.op_Less_Equals | {
"file_name": "ulib/FStar.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int_t sw -> y: FStar.Integers.int_t sw -> Prims.bool | {
"end_col": 43,
"end_line": 384,
"start_col": 4,
"start_line": 373
} |
FStar.Pervasives.Lemma | val hash_is_hash_incremental' (a: hash_alg) (input: bytes { S.length input `less_than_max_input_length` a })
(l: output_length a):
Lemma (S.equal (hash' a input l) (hash_incremental a input l)) | [
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_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_is_hash_incremental' (a: hash_alg) (input: bytes { S.length input `less_than_max_input_length` a }) l =
if is_blake a then
Spec.Blake2.Incremental.blake2_is_hash_incremental a input
else if is_keccak a then
Spec.SHA3.Incremental.sha3_is_incremental a input l
else
Spec.MD.Incremental.md_is_hash_incremental a input (init a) | val hash_is_hash_incremental' (a: hash_alg) (input: bytes { S.length input `less_than_max_input_length` a })
(l: output_length a):
Lemma (S.equal (hash' a input l) (hash_incremental a input l))
let hash_is_hash_incremental'
(a: hash_alg)
(input: bytes{(S.length input) `less_than_max_input_length` a})
l
= | false | null | true | if is_blake a
then Spec.Blake2.Incremental.blake2_is_hash_incremental a input
else
if is_keccak a
then Spec.SHA3.Incremental.sha3_is_incremental a input l
else Spec.MD.Incremental.md_is_hash_incremental a input (init a) | {
"checked_file": "Spec.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.SHA3.Incremental.fsti.checked",
"Spec.MD.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.Incremental.fsti.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Hash.Incremental.fst"
} | [
"lemma"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.bytes",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.output_length",
"Spec.Hash.Definitions.is_blake",
"Spec.Blake2.Incremental.blake2_is_hash_incremental",
"Prims.bool",
"Spec.Hash.Definitions.is_keccak",
"Spec.SHA3.Incremental.sha3_is_incremental",
"Spec.MD.Incremental.md_is_hash_incremental",
"Spec.Agile.Hash.init",
"Prims.unit"
] | [] | module Spec.Hash.Incremental
module S = FStar.Seq
module Blake2 = Spec.Blake2
open Spec.Agile.Hash
open Spec.Hash.Definitions
friend Spec.Agile.Hash
open FStar.Mul
module Loops = Lib.LoopCombinators
#set-options "--fuel 0 --ifuel 0 --z3rlimit 50"
/// A declaration whose sole purpose is to force synchronize the .fst and the .fsti
let _sync_decl = unit | false | false | Spec.Hash.Incremental.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_is_hash_incremental' (a: hash_alg) (input: bytes { S.length input `less_than_max_input_length` a })
(l: output_length a):
Lemma (S.equal (hash' a input l) (hash_incremental a input l)) | [] | Spec.Hash.Incremental.hash_is_hash_incremental' | {
"file_name": "specs/lemmas/Spec.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg ->
input:
Spec.Hash.Definitions.bytes
{Spec.Hash.Definitions.less_than_max_input_length (FStar.Seq.Base.length input) a} ->
l: Spec.Hash.Definitions.output_length a
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (Spec.Agile.Hash.hash' a input l)
(Spec.Hash.Incremental.Definitions.hash_incremental a input l)) | {
"end_col": 63,
"end_line": 27,
"start_col": 2,
"start_line": 22
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.